:root {
  --ink: #18314b;
  --muted: #62758a;
  --blue: #153f69;
  --teal: #087d71;
  --line: #dce4ed;
  --surface: #f3f6fa;
  --red: #bc3e4c;
  --gold: #976600;
  --radius: 14px;
  font-family: "Thonburi", "Noto Sans Thai", "Tahoma", sans-serif;
  color: var(--ink);
  background: var(--surface);
  font-size: 16px;
  line-height: 1.6;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
select,
textarea {
  outline-offset: 4px;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 9px;
  padding: 9px 15px;
  font-weight: 600;
}
button:hover {
  border-color: #8ca4bb;
  background: #f4f8fc;
}
button:disabled {
  cursor: wait;
  opacity: 0.55;
}
button.primary {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}
button.danger {
  color: var(--red);
}
button.small {
  padding: 5px 10px;
  font-size: 0.875rem;
}
a {
  color: var(--blue);
}
.shell {
  display: grid;
  grid-template-columns: 234px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  padding: 26px 16px;
  background: #fff;
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 10px 25px;
}
.brand-mark {
  background: var(--blue);
  color: white;
  border-radius: 11px;
  padding: 7px 12px;
  font-weight: 800;
  font-size: 1.35rem;
}
.brand strong {
  display: block;
}
.brand span,
.subtle {
  color: var(--muted);
  font-size: 0.875rem;
}
.nav {
  display: grid;
  gap: 5px;
}
.nav a {
  padding: 11px 14px;
  text-decoration: none;
  color: var(--muted);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.94rem;
}
.nav a.active {
  background: #e9f1fa;
  color: var(--blue);
  font-weight: 700;
}
.nav-icon {
  width: 22px;
  font-size: 1.1rem;
}
.profile {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 20px 9px 0;
}
.main {
  padding: 32px clamp(20px, 3vw, 48px);
  max-width: 1550px;
  width: 100%;
  margin: auto;
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 28px;
}
h1 {
  font-size: 1.7rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.035em;
}
h2 {
  font-size: 1.15rem;
  margin: 0 0 16px;
}
h3 {
  font-size: 1rem;
  margin: 0 0 8px;
}
p {
  margin: 8px 0 16px;
}
.eyebrow {
  font-size: 0.875rem;
  color: var(--teal);
  font-weight: 700;
  margin-bottom: 4px;
}
.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.balance-strip {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 0;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}
.balance-main {
  padding: 26px;
  background: var(--blue);
  color: #fff;
}
.balance-main .subtle {
  color: #c9dcee;
}
.balance-main strong {
  font-family: ui-monospace, monospace;
  font-size: 2.3rem;
  display: block;
  line-height: 1.45;
}
.balance-part {
  padding: 26px;
  border-left: 1px solid var(--line);
}
.big {
  display: block;
  font-family: ui-monospace, monospace;
  font-size: 1.7rem;
  font-weight: 700;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 20px 0;
}
.stat,
.panel {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.stat .value {
  font-family: ui-monospace, monospace;
  font-size: 1.4rem;
  font-weight: 700;
  margin: 10px 0 0;
}
.stat .subtle {
  font-size: 0.875rem;
}
.columns {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 20px;
}
.panel {
  margin-bottom: 20px;
  min-width: 0;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-header h2 {
  margin: 0;
}
.table-wrap {
  overflow: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  text-align: left;
  font-size: 0.875rem;
}
th {
  font-weight: 500;
  color: var(--muted);
  background: #f7f9fc;
  white-space: nowrap;
}
td,
th {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
tbody tr:last-child td {
  border-bottom: 0;
}
td.money,
th.money {
  text-align: right;
  white-space: nowrap;
  font-family: ui-monospace, monospace;
}
.positive {
  color: var(--teal);
}
.negative {
  color: var(--red);
}
.badge {
  display: inline-block;
  font-size: 0.8rem;
  border-radius: 6px;
  padding: 2px 8px;
  background: #edf2f7;
  color: var(--muted);
  white-space: nowrap;
}
.badge.company {
  background: #e7f0fa;
  color: var(--blue);
}
.badge.personal {
  background: #f1ecfa;
  color: #7149a0;
}
.badge.pending {
  background: #fff4d9;
  color: var(--gold);
}
.notice {
  background: #fff6df;
  border: 1px solid #f2db9c;
  color: #795511;
  border-radius: 10px;
  padding: 13px 16px;
  font-size: 0.875rem;
  margin: 16px 0;
}
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}
.empty strong {
  display: block;
  color: var(--ink);
  margin-bottom: 7px;
}
.account-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid var(--line);
}
.bank-logo {
  width: 43px;
  height: 43px;
  border-radius: 12px;
  background: #eaf0f8;
  display: grid;
  place-items: center;
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.bank-logo.SCB {
  background: #f0eafb;
  color: #643895;
}
.bank-logo.KBANK {
  background: #e7f5ec;
  color: #15854b;
}
.bank-logo.KKP {
  background: #edeafa;
  color: #67549a;
}
.account-row .amount {
  margin-left: auto;
  text-align: right;
  font-family: ui-monospace, monospace;
}
.row-main {
  min-width: 0;
}
.row-main strong {
  display: block;
  font-size: 0.9rem;
}
.filter {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter label {
  min-width: 130px;
}
.filter input {
  max-width: 280px;
}
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}
.full {
  grid-column: 1/-1;
}
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
}
input,
select,
textarea {
  display: block;
  width: 100%;
  min-height: 43px;
  padding: 9px 11px;
  border: 1px solid #cbd6e2;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  margin-top: 5px;
  max-width: 100%;
}
input[type="checkbox"] {
  display: inline-block;
  width: 18px;
  min-height: 18px;
  margin-right: 8px;
  vertical-align: middle;
}
textarea {
  resize: vertical;
  min-height: 85px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
}
.check input {
  flex-shrink: 0;
}
.helper {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}
.divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 22px 0;
}
.split-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  background: #f8fafc;
}
.split-row .grid {
  grid-template-columns: repeat(3, 1fr);
}
.split-total {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  padding: 10px 0;
}
.split-total.bad {
  color: var(--red);
}
dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  width: min(880px, 94vw);
  max-height: 92vh;
  box-shadow: 0 24px 80px #142d4b33;
  color: var(--ink);
}
dialog::backdrop {
  background: #18314b80;
  backdrop-filter: blur(3px);
}
#dialog-content {
  padding: 26px;
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 20px;
}
.dialog-head h2 {
  font-size: 1.25rem;
}
.dialog-head button {
  padding: 4px 11px;
}
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.error {
  color: var(--red);
  font-size: 0.9rem;
  white-space: pre-wrap;
}
.login-wrap {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #edf4fc 0%, #f7f9fc 70%);
}
.login {
  width: min(440px, 92vw);
  padding: 36px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 20px 70px #153f6910;
}
.login label {
  margin: 18px 0;
}
.login button {
  width: 100%;
  margin-top: 10px;
}
.login .brand {
  padding-left: 0;
}
.login h1 {
  font-size: 1.4rem;
}
#notice {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  border-radius: 10px;
  padding: 12px 20px;
  box-shadow: 0 5px 30px #18314b33;
  z-index: 10;
  display: none;
  max-width: 90vw;
}
.loading {
  padding: 60px;
  text-align: center;
  color: var(--muted);
}
.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}
.attachment {
  padding: 5px 10px;
  background: #eef3fa;
  border-radius: 6px;
  font-size: 0.875rem;
}
.tabbar {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin: 12px 0 22px;
}
.tabbar button.selected {
  background: var(--blue);
  color: white;
}
.detail-list {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 10px;
  font-size: 0.94rem;
}
.detail-list dt {
  color: var(--muted);
}
.detail-list dd {
  margin: 0;
}
.checkbox-line {
  font-weight: 400;
}
.nowrap {
  white-space: nowrap;
}
.muted {
  color: var(--muted);
}
pre {
  font-size: 0.8rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.mobile-brand {
  display: none;
}
@media (max-width: 1100px) {
  .columns {
    grid-template-columns: 1fr;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .shell {
    grid-template-columns: 205px minmax(0, 1fr);
  }
  .main {
    padding: 24px;
  }
  .balance-main strong {
    font-size: 1.85rem;
  }
}
@media (max-width: 760px) {
  .shell {
    display: block;
  }
  .sidebar {
    position: static;
    height: auto;
    padding: 13px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar .brand {
    padding: 0 5px 12px;
  }
  .nav {
    display: flex;
    overflow: auto;
    gap: 3px;
  }
  .nav a {
    padding: 8px 11px;
    white-space: nowrap;
  }
  .nav-icon {
    display: none;
  }
  .profile {
    display: none;
  }
  .main {
    padding: 20px 14px;
  }
  .topbar {
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 10px;
  }
  .topbar h1 {
    font-size: 1.4rem;
  }
  .topbar button {
    font-size: 0.875rem;
    padding: 8px 10px;
  }
  .balance-strip {
    grid-template-columns: 1fr 1fr;
  }
  .balance-main {
    grid-column: 1/-1;
    padding: 22px;
  }
  .balance-part {
    padding: 17px;
  }
  .big {
    font-size: 1.35rem;
  }
  .stats {
    gap: 10px;
  }
  .stat,
  .panel {
    padding: 16px;
  }
  .stat .value {
    font-size: 1.2rem;
  }
  .grid,
  .split-row .grid {
    grid-template-columns: 1fr;
  }
  .full {
    grid-column: auto;
  }
  #dialog-content {
    padding: 18px;
  }
  .detail-list {
    grid-template-columns: 100px 1fr;
  }
  .filter label {
    flex: 1;
  }
  td,
  th {
    padding: 11px 9px;
  }
  .eyebrow {
    font-size: 0.8rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
[hidden] {
  display: none !important;
}
