:root {
  color-scheme: dark;
  --background: #0d0e11;
  --foreground: #f2ead7;
  --card: #141518;
  --card-foreground: #f4eddd;
  --muted: #1b1c20;
  --muted-foreground: #98999f;
  --border: #37383d;
  --input: #111216;
  --primary: #d7ae5d;
  --primary-foreground: #15120d;
  --destructive: #e07a74;
  --ring: #d7ae5d;
  --radius: 10px;
  --font-serif: Georgia, 'Times New Roman', serif;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

.auth-shell {
  display: grid;
  grid-template-columns: minmax(420px, 44%) 1fr;
  min-height: 100vh;
}

.brand-panel {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: clamp(42px, 6vw, 86px);
  border-right: 1px solid #2b2c30;
  background: #101115;
}

.brand, .mobile-brand {
  display: inline-flex;
  align-items: center;
  gap: 22px;
  color: var(--foreground);
  font-family: var(--font-serif);
  font-size: clamp(30px, 3vw, 50px);
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  color: var(--primary);
}

.brand-mark svg { width: 31px; height: 31px; stroke-width: 1.4; }

.brand-copy { margin-top: clamp(68px, 10vh, 110px); max-width: 365px; }
.brand-rule { display: block; width: 46px; height: 2px; margin-bottom: 32px; background: var(--primary); }
.brand-copy h1 { margin: 0; font-family: var(--font-serif); font-size: clamp(29px, 3vw, 42px); font-weight: 500; line-height: 1.18; letter-spacing: -.025em; }
.brand-copy p { margin: 20px 0 0; color: var(--muted-foreground); font-size: 16px; line-height: 1.65; }

.feature-list { display: flex; flex-direction: column; gap: 23px; padding: 28px 0 0; margin: 28px 0 0; max-width: 350px; border-top: 1px solid #313238; list-style: none; }
.feature-list li { display: flex; align-items: flex-start; gap: 17px; }
.feature-list li > svg { flex: 0 0 auto; width: 26px; height: 26px; color: var(--primary); stroke-width: 1.4; }
.feature-list span { display: flex; flex-direction: column; gap: 2px; }
.feature-list strong { color: #e8e5de; font-size: 14px; font-weight: 500; }
.feature-list small { color: #818289; font-size: 13px; }

.vault-art { position: absolute; right: -34px; bottom: 14%; width: 250px; height: 320px; opacity: .65; color: var(--primary); }
.vault-door { position: absolute; top: 0; right: 20px; width: 170px; height: 240px; border: 1px solid currentColor; border-radius: 14px; box-shadow: inset 0 0 0 12px #101115, inset 0 0 0 13px currentColor; }
.vault-wheel { position: absolute; left: 52px; top: 82px; width: 60px; height: 60px; border: 1px solid currentColor; border-radius: 50%; }
.vault-wheel::before, .vault-wheel::after { content: ''; position: absolute; left: 29px; top: 7px; width: 1px; height: 46px; background: currentColor; }
.vault-wheel::after { transform: rotate(60deg); }
.ledger { position: absolute; right: 0; width: 205px; height: 63px; border: 1px solid currentColor; background: #101115; transform: skewY(-12deg); }
.ledger-one { bottom: 45px; }
.ledger-two { bottom: 25px; right: 8px; }
.ledger-three { bottom: 5px; right: 16px; }

.login-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: clamp(28px, 6vw, 76px); }
.mobile-brand { display: none; }
.auth-card { width: min(100%, 635px); padding: clamp(34px, 4.5vw, 54px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); box-shadow: 0 24px 80px rgba(0,0,0,.25); }
.card-header h2 { margin: 0; font-family: var(--font-serif); font-size: clamp(36px, 4vw, 48px); font-weight: 500; line-height: 1.1; letter-spacing: -.025em; }
.card-header p { margin: 13px 0 0; color: var(--muted-foreground); font-size: 17px; }
.form-stack { display: flex; flex-direction: column; gap: 25px; margin-top: 34px; }
.field { display: flex; flex-direction: column; gap: 9px; }
.field label { color: #efede8; font-size: 14px; font-weight: 500; }
.input-wrap { position: relative; }
.input-wrap input { width: 100%; height: 58px; padding: 0 50px 0 16px; border: 1px solid var(--border); border-radius: 8px; outline: none; background: var(--input); color: var(--card-foreground); transition: border-color .16s ease, box-shadow .16s ease; }
.input-wrap input::placeholder { color: #6f7077; }
.input-wrap input:focus { border-color: var(--ring); box-shadow: 0 0 0 3px rgba(215,174,93,.14); }
.input-wrap input[aria-invalid='true'] { border-color: var(--destructive); }
.input-wrap > svg, .input-action { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); }
.input-wrap > svg { width: 20px; height: 20px; color: #8b8c92; stroke-width: 1.5; pointer-events: none; }
.input-action { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; background: transparent; color: #8b8c92; cursor: pointer; }
.input-action:hover { color: var(--foreground); }
.input-action:focus-visible, .button:focus-visible, a:focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; }
.input-action svg { width: 20px; height: 20px; stroke-width: 1.5; }
.field-error { min-height: 0; color: var(--destructive); font-size: 12px; }
.field-error:empty { display: none; }

.form-options { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.form-options a { color: var(--primary); font-size: 14px; text-underline-offset: 4px; }
.checkbox-label { display: inline-flex; align-items: center; gap: 10px; color: #dedbd4; cursor: pointer; }
.checkbox-label input { position: absolute; opacity: 0; pointer-events: none; }
.checkbox-control { display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid var(--border); border-radius: 5px; background: var(--input); }
.checkbox-control svg { width: 15px; height: 15px; opacity: 0; }
.checkbox-label input:checked + .checkbox-control { border-color: var(--primary); background: var(--primary); color: var(--primary-foreground); }
.checkbox-label input:checked + .checkbox-control svg { opacity: 1; }
.checkbox-label input:focus-visible + .checkbox-control { outline: 2px solid var(--ring); outline-offset: 3px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 48px; padding: 0 20px; border: 1px solid var(--border); border-radius: 8px; background: var(--muted); color: var(--foreground); font-weight: 600; cursor: pointer; }
.button-primary { height: 58px; border-color: var(--primary); background: var(--primary); color: var(--primary-foreground); }
.button:hover { filter: brightness(1.06); }
.button:disabled { opacity: .65; cursor: wait; }
.spinner { display: none; animation: spin .8s linear infinite; }
.button[data-loading='true'] .spinner { display: block; }
.button[data-loading='true'] span { opacity: .75; }

.alert { align-items: flex-start; gap: 10px; margin-top: 24px; padding: 12px 14px; border: 1px solid rgba(224,122,116,.45); border-radius: 8px; background: rgba(224,122,116,.08); color: #efaaa5; font-size: 13px; }
.alert:not([hidden]) { display: flex; }
.alert svg { flex: 0 0 auto; width: 18px; height: 18px; }

.auth-footer { width: min(100%, 510px); margin-top: 30px; text-align: center; color: var(--muted-foreground); }
.auth-footer div { display: flex; align-items: center; justify-content: center; gap: 13px; color: #e5e1d9; font-size: 16px; }
.auth-footer div svg { width: 22px; height: 22px; color: var(--primary); stroke-width: 1.5; }
.footer-rule { display: block; height: 1px; margin: 20px 0; background: #2f3034; }
.auth-footer p { margin: 0; }

.protected-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.placeholder-dashboard { width: min(100%, 620px); padding: 40px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.placeholder-dashboard .brand { color: var(--primary); font-size: 24px; }
.placeholder-dashboard h1 { margin: 30px 0 8px; font-family: var(--font-serif); font-size: 40px; }
.placeholder-dashboard p { margin: 0 0 28px; color: var(--muted-foreground); }

@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
  .auth-shell { grid-template-columns: minmax(360px, 40%) 1fr; }
  .brand-panel { padding: 48px; }
  .vault-art { display: none; }
}

@media (max-width: 1400px) {
  .transaction-main .metric-strip article { padding: 18px; }
  .transaction-main .metric-strip article > strong { font-size: 19px; }
  .transaction-main .data-toolbar { flex-wrap: wrap; }
  .transaction-main .data-toolbar .search-control { flex: 1 1 220px; margin-left: 0; }
  .transaction-table .data-table-head, .transaction-table .data-table-row { grid-template-columns: 82px minmax(145px, 1.35fr) 105px 68px 112px 40px; min-width: 590px; column-gap: 10px; }
  .transaction-table .data-table-head > span:nth-child(6), .transaction-table .data-table-row > span:nth-child(6) { display: none; }
}

@media (max-width: 860px) {
  .auth-shell { display: block; }
  .brand-panel { display: none; }
  .login-panel { min-height: 100vh; justify-content: flex-start; padding: 34px 24px; }
  .mobile-brand { display: inline-flex; align-self: flex-start; gap: 13px; font-size: 28px; }
  .mobile-brand .brand-mark { width: 44px; height: 44px; }
  .mobile-brand .brand-mark svg { width: 23px; height: 23px; }
  .auth-card { margin-top: clamp(52px, 11vh, 92px); }
}

@media (max-width: 520px) {
  .login-panel { padding: 24px 18px 32px; }
  .auth-card { padding: 0; border: 0; background: transparent; box-shadow: none; }
  .card-header h2 { font-size: 36px; }
  .card-header p { font-size: 15px; }
  .form-stack { margin-top: 30px; gap: 22px; }
  .input-wrap input, .button-primary { height: 54px; }
  .form-options { align-items: flex-start; }
  .auth-footer { margin-top: auto; padding-top: 48px; font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Dashboard and loan manager */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.dashboard-page { min-width: 320px; overflow-x: hidden; }
.dashboard-shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.app-sidebar { position: sticky; top: 0; z-index: 20; display: flex; flex-direction: column; height: 100vh; padding: 25px 10px 18px; border-right: 1px solid var(--border); background: #101114; }
.sidebar-brand { padding: 0 18px 25px; border-bottom: 1px solid var(--border); color: var(--foreground); font-family: var(--font-serif); font-size: 32px; font-weight: 700; line-height: 1; text-decoration: none; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; padding-top: 19px; }
.nav-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 48px; padding: 0 18px; border: 0; border-radius: 7px; background: transparent; color: #e3e0da; font: 500 14px/1 var(--font-sans); text-align: left; text-decoration: none; }
.nav-item svg { width: 21px; height: 21px; stroke-width: 1.7; }
.nav-item.is-active { background: rgba(215,174,93,.15); color: var(--primary); }
.nav-disabled { color: #a09fa0; cursor: default; }
.sidebar-signout { margin-top: auto; }
.sidebar-signout .nav-item { cursor: pointer; }
.sidebar-signout .nav-item:hover { background: var(--muted); color: var(--foreground); }
.sidebar-scrim { position: fixed; inset: 0; z-index: 15; border: 0; background: rgba(0,0,0,.62); }

.dashboard-main { min-width: 0; }
.app-topbar { display: flex; align-items: center; gap: 14px; height: 80px; padding: 0 26px; border-bottom: 1px solid var(--border); background: rgba(13,14,17,.96); }
.icon-button { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: #d9d6cf; cursor: pointer; }
.icon-button:hover { border-color: var(--border); background: var(--muted); }
.icon-button:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.icon-button svg { width: 21px; height: 21px; }
.menu-button { display: none; }
.mobile-topbar-brand { display: none; color: var(--foreground); font: 700 23px/1 var(--font-serif); text-decoration: none; }
.vault-switcher { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 10px 0 13px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
.vault-switcher > svg { width: 19px; height: 19px; color: var(--primary); }
.vault-switcher select { min-width: 175px; border: 0; outline: none; background: transparent; color: var(--foreground); font-weight: 500; }
.currency-chip { display: inline-flex; align-items: center; height: 44px; padding: 0 16px; border: 1px solid var(--border); border-radius: 8px; color: #d7d3cc; }
.topbar-user { display: grid; place-items: center; width: 36px; height: 36px; margin-left: auto; border: 1px solid var(--border); border-radius: 50%; color: var(--primary); font-family: var(--font-serif); font-weight: 700; }

.loan-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 390px; min-height: calc(100vh - 80px); }
.loan-main { min-width: 0; padding: 28px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.page-heading h1 { margin: 0; font: 500 38px/1.08 var(--font-serif); letter-spacing: -.025em; }
.page-heading p { margin: 8px 0 0; color: var(--muted-foreground); font-size: 15px; }
.button.compact { min-height: 48px; }
.button.compact { white-space: nowrap; }
.button svg { width: 18px; height: 18px; }
.mobile-action-label { display: none; }

.loan-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 29px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.loan-summary article { display: grid; grid-template-columns: 38px 1fr; grid-template-rows: auto auto; column-gap: 12px; min-width: 0; padding: 20px 18px; }
.loan-summary article + article { border-left: 1px solid var(--border); }
.loan-summary article > svg { grid-row: 1 / 3; align-self: center; width: 23px; height: 23px; padding: 8px; box-sizing: content-box; border-radius: 50%; background: rgba(215,174,93,.12); color: var(--primary); stroke-width: 1.6; }
.loan-summary span { align-self: end; color: var(--muted-foreground); font-size: 13px; }
.loan-summary strong { overflow: hidden; color: var(--foreground); font: 500 clamp(18px, 1.55vw, 22px)/1.2 var(--font-serif); text-overflow: ellipsis; white-space: nowrap; }

.loan-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 28px 0 16px; }
.segmented-control { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented-control button { min-width: 88px; height: 42px; padding: 0 16px; border: 0; border-right: 1px solid var(--border); background: transparent; color: #d6d3cd; cursor: pointer; }
.segmented-control button:last-child { border-right: 0; }
.segmented-control button.is-selected { background: rgba(215,174,93,.15); color: var(--foreground); box-shadow: inset 0 0 0 1px rgba(215,174,93,.5); }
.search-control { position: relative; width: min(100%, 320px); }
.search-control svg { position: absolute; left: 14px; top: 50%; width: 19px; height: 19px; transform: translateY(-50%); color: var(--muted-foreground); }
.search-control input { width: 100%; height: 42px; padding: 0 14px 0 42px; border: 1px solid var(--border); border-radius: 8px; outline: none; background: var(--input); color: var(--foreground); }
.search-control input:focus { border-color: var(--ring); box-shadow: 0 0 0 3px rgba(215,174,93,.12); }

.loan-list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.loan-list-head, .loan-row { display: grid; grid-template-columns: minmax(145px,1.35fr) .75fr .92fr .82fr .95fr .8fr .9fr; align-items: center; column-gap: 12px; }
.loan-list-head { min-height: 54px; padding: 0 18px; border-bottom: 1px solid var(--border); color: #b4b2ae; font-size: 12px; }
.loan-row { position: relative; min-height: 92px; padding: 13px 18px; border-bottom: 1px solid var(--border); color: #e8e5df; text-decoration: none; }
.loan-row:last-child { border-bottom: 0; }
.loan-row:hover { background: rgba(255,255,255,.02); }
.loan-row.is-selected { background: rgba(215,174,93,.06); box-shadow: inset 3px 0 0 var(--primary); }
.loan-row[hidden] { display: none; }
.loan-row > span { min-width: 0; font-size: 12px; }
.loan-name { display: flex; align-items: center; gap: 11px; }
.loan-name > span:last-child { display: flex; min-width: 0; flex-direction: column; }
.loan-name strong, .remaining-cell strong { overflow: hidden; font-size: 13px; font-style: normal; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.loan-name small { display: block; overflow: hidden; color: var(--muted-foreground); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.remaining-cell small { display: none; color: var(--muted-foreground); }
.loan-avatar { display: none; flex: 0 0 auto; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--muted); color: var(--primary); font-family: var(--font-serif); }
.status-badge { display: inline-flex; align-items: center; min-height: 25px; padding: 0 8px; border-radius: 5px; font-size: 11px; font-style: normal; white-space: nowrap; }
.status-badge.borrowed { background: rgba(215,174,93,.14); color: #e3bb6c; }
.status-badge.lent { background: rgba(119,164,91,.14); color: #a7cf8d; }
.progress-cell { display: flex; flex-direction: column; gap: 6px; }
.progress-cell strong { font-weight: 500; }
.progress-track { display: block; width: 100%; height: 6px; overflow: hidden; border: 0; border-radius: 999px; appearance: none; background: #303136; }
.progress-track::-webkit-progress-bar { border-radius: 999px; background: #303136; }
.progress-track::-webkit-progress-value { border-radius: 999px; background: var(--primary); }
.progress-track::-moz-progress-bar { border-radius: 999px; background: var(--primary); }

.loan-detail { position: relative; min-width: 0; padding: 34px 30px; border-left: 1px solid var(--border); background: #111215; }
.loan-detail h2 { margin: 0 42px 0 0; font: 500 29px/1.2 var(--font-serif); }
.detail-close { position: absolute; top: 25px; right: 20px; }
.sheet-handle { display: none; }
.detail-subtitle { display: flex; align-items: center; gap: 9px; margin: 10px 0 27px; color: var(--muted-foreground); }
.loan-facts { display: flex; flex-direction: column; gap: 13px; padding: 22px 0; margin: 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.loan-facts div { display: flex; justify-content: space-between; gap: 20px; }
.loan-facts dt { color: var(--muted-foreground); }
.loan-facts dd { margin: 0; color: #eeeae3; text-align: right; }
.detail-progress { display: flex; flex-direction: column; gap: 9px; margin-top: 20px; }
.detail-progress > span:first-child { display: flex; justify-content: space-between; }
.detail-progress small { color: var(--muted-foreground); font-size: 13px; }
.detail-progress strong { color: var(--primary); }
.loan-notes { margin: 18px 0 0; color: var(--muted-foreground); font-size: 13px; }
.record-payment-button { width: 100%; margin-top: 22px; }
.detail-actions { display: grid; grid-template-columns: .8fr 1.2fr; gap: 10px; margin-top: 22px; }
.detail-actions .button { min-width: 0; padding: 0 12px; }
.payment-history { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--border); }
.payment-history h3 { margin: 0 0 8px; font: 500 21px/1.2 var(--font-serif); }
.payment-history ol { padding: 0; margin: 0; list-style: none; }
.payment-history li { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.payment-history li > span { display: flex; flex-direction: column; gap: 3px; }
.payment-history li strong { font-size: 14px; font-weight: 500; }
.payment-history li small, .payment-history time, .muted-copy { color: var(--muted-foreground); font-size: 12px; }
.loan-empty { display: grid; place-items: center; min-height: 330px; padding: 40px; border: 1px dashed var(--border); border-radius: var(--radius); text-align: center; }
.loan-empty > svg { width: 38px; height: 38px; color: var(--primary); }
.loan-empty h2 { margin: 15px 0 3px; font: 500 25px/1.2 var(--font-serif); }
.loan-empty p { max-width: 430px; margin: 0 0 18px; color: var(--muted-foreground); }

.app-dialog { width: min(94vw, 560px); max-height: min(90vh, 760px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: var(--foreground); box-shadow: 0 30px 100px rgba(0,0,0,.6); }
.app-dialog::backdrop { background: rgba(0,0,0,.72); }
.dialog-form > header, .dialog-form > footer { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 22px 24px; }
.dialog-form > header { border-bottom: 1px solid var(--border); }
.dialog-form > header h2 { margin: 0; font: 500 27px/1.2 var(--font-serif); }
.dialog-form > header p { margin: 4px 0 0; color: var(--muted-foreground); font-size: 13px; }
.dialog-form > footer { justify-content: flex-end; border-top: 1px solid var(--border); }
.dialog-fields { display: flex; flex-direction: column; gap: 17px; max-height: calc(90vh - 190px); padding: 22px 24px; overflow-y: auto; }
.dialog-fields .field { gap: 7px; }
.dialog-fields .field > span { color: #e9e6e0; font-size: 13px; font-weight: 500; }
.dialog-fields .field > span small { color: var(--muted-foreground); font-weight: 400; }
.dialog-fields input, .dialog-fields select, .dialog-fields textarea { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; outline: none; background: var(--input); color: var(--foreground); font: 14px var(--font-sans); }
.dialog-fields textarea { resize: vertical; }
.dialog-fields input:focus, .dialog-fields select:focus, .dialog-fields textarea:focus { border-color: var(--ring); box-shadow: 0 0 0 3px rgba(215,174,93,.12); }
.dialog-fields [aria-invalid='true'] { border-color: var(--destructive); }
.dialog-fields .field > small { color: var(--destructive); font-size: 11px; }
.dialog-fields .field > small:empty { display: none; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dialog-alert { margin: 18px 24px 0; }

@media (max-width: 1180px) {
  .loan-workspace { grid-template-columns: minmax(0, 1fr) 330px; }
  .loan-list-head, .loan-row { grid-template-columns: minmax(135px,1.35fr) .75fr .92fr .95fr .8fr .9fr; }
  .loan-list-head span:nth-child(4), .loan-row > span:nth-child(4) { display: none; }
}

@media (max-width: 960px) {
  .dashboard-shell { grid-template-columns: 1fr; }
  .app-sidebar { position: fixed; left: 0; transform: translateX(-105%); width: 245px; transition: transform .2s ease; }
  .app-sidebar.is-open { transform: translateX(0); }
  .menu-button { display: inline-grid; }
  .mobile-topbar-brand { display: inline; }
  .loan-workspace { grid-template-columns: minmax(0, 1fr) 340px; }
  .loan-main { padding: 24px; }
}

@media (max-width: 760px) {
  .app-topbar { height: 68px; padding: 0 14px; }
  .vault-switcher { margin-left: auto; }
  .vault-switcher select { min-width: 0; max-width: 150px; }
  .currency-chip, .topbar-user { display: none; }
  .loan-workspace { display: block; min-height: calc(100vh - 68px); }
  .loan-main { padding: 25px 18px 40px; }
  .page-heading h1 { font-size: 38px; }
  .page-heading p { max-width: 245px; font-size: 14px; }
  .button.compact { padding: 0 16px; }
  .desktop-action-label { display: none; }
  .mobile-action-label { display: inline; }
  .loan-summary { margin-top: 24px; }
  .loan-summary article { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 15px 7px; text-align: center; }
  .loan-summary article > svg { display: none; }
  .loan-summary span { font-size: 11px; }
  .loan-summary strong { max-width: 100%; font-size: 16px; }
  .loan-toolbar { display: block; margin-top: 22px; }
  .segmented-control { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
  .segmented-control button { min-width: 0; }
  .search-control { display: none; width: 100%; margin-top: 12px; }
  .loan-list { border-width: 1px 0 0; border-radius: 0; }
  .loan-list-head { display: none; }
  .loan-row { grid-template-columns: minmax(0, 1.25fr) auto minmax(105px,.85fr) 46px; min-height: 108px; padding: 14px 4px; column-gap: 9px; }
  .loan-row.is-selected { box-shadow: inset 3px 0 0 var(--primary), inset 0 0 0 1px var(--primary); border-radius: 8px; }
  .loan-row > span:nth-child(2), .loan-row > span:nth-child(5), .loan-row > span:nth-child(6) { display: flex; }
  .loan-row .desktop-cell { display: none; }
  .loan-avatar { display: grid; }
  .loan-name small, .remaining-cell small { display: block; }
  .remaining-cell { flex-direction: column; }
  .remaining-cell strong { font-family: var(--font-serif); font-size: 16px; }
  .progress-cell { width: 46px; color: var(--primary); }
  .loan-detail { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; max-height: 52.5vh; padding: 34px 26px 28px; border: 1px solid var(--border); border-radius: 22px 22px 0 0; overflow-y: auto; transform: translateY(105%); transition: transform .25s ease; box-shadow: 0 -22px 65px rgba(0,0,0,.55); }
  .detail-open::before { content: ''; position: fixed; inset: 0; z-index: 29; background: rgba(0,0,0,.6); }
  .detail-open .loan-detail { transform: translateY(0); }
  .sheet-handle { display: block; width: 68px; height: 6px; margin: -20px auto 23px; border-radius: 999px; background: #5c5d61; }
  .loan-detail h2 { font-size: 30px; }
}

@media (max-width: 460px) {
  .vault-switcher { max-width: 170px; }
  .vault-switcher select { max-width: 104px; }
  .loan-summary strong { font-size: 14px; }
  .field-pair { grid-template-columns: 1fr; }
  .app-dialog { width: calc(100vw - 20px); }
}

@media (max-width: 350px) {
  .mobile-topbar-brand { display: none; }
  .loan-row { grid-template-columns: minmax(0,1fr) minmax(100px,.75fr) 42px; }
  .loan-row > span:nth-child(2) { display: none; }
}

.telegram-topbar-title { margin-right: auto; color: var(--muted-foreground); font-size: 13px; }
.telegram-workspace { width: min(1040px, 100%); padding: 46px clamp(24px, 5vw, 72px); margin: 0 auto; }
.connection-status { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted-foreground); font-size: 13px; }
.connection-status svg { width: 16px; }
.connection-status.is-linked { border-color: rgba(111, 186, 139, .45); color: #8fd3a8; background: rgba(72, 139, 96, .1); }
.telegram-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 34px; }
.telegram-card { padding: 28px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.telegram-card-icon { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 20px; border: 1px solid rgba(215,174,93,.45); border-radius: 9px; color: var(--primary); background: rgba(215,174,93,.06); }
.telegram-card-icon svg { width: 21px; }
.telegram-card h2 { margin: 0; font: 500 26px/1.2 var(--font-serif); }
.telegram-card > p { color: var(--muted-foreground); line-height: 1.65; }
.telegram-card code { color: #e8d6ae; }
.link-code-panel { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 20px; margin: 20px 0; border: 1px dashed var(--primary); border-radius: 9px; background: rgba(215,174,93,.05); }
.link-code-panel span, .link-code-panel small { color: var(--muted-foreground); font-size: 12px; }
.link-code-panel strong { color: var(--primary); font: 500 42px/1.2 var(--font-serif); letter-spacing: .2em; }
.telegram-details { margin: 22px 0; border-top: 1px solid var(--border); }
.telegram-details div { display: flex; justify-content: space-between; gap: 20px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.telegram-details dt { color: var(--muted-foreground); }
.telegram-details dd { margin: 0; text-align: right; }
.button-danger { border-color: rgba(224,122,116,.45); color: var(--destructive); background: rgba(224,122,116,.07); }
.command-preview pre { padding: 18px; overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--input); color: #e8d6ae; line-height: 1.75; }
.text-link { display: inline-flex; align-items: center; gap: 7px; color: var(--primary); text-decoration: none; }
.text-link svg { width: 16px; }
.telegram-message { padding: 12px; border-radius: 7px; color: #8fd3a8 !important; background: rgba(72,139,96,.1); }
.telegram-message.is-error { color: var(--destructive) !important; background: rgba(224,122,116,.08); }
.telegram-notice { display: flex; gap: 14px; padding: 19px 21px; margin-top: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: #111216; }
.telegram-notice > svg { flex: 0 0 auto; width: 22px; color: var(--primary); }
.telegram-notice p { margin: 3px 0 0; color: var(--muted-foreground); }
.command-reference-page { width: min(960px, calc(100% - 36px)); margin: 0 auto; padding: 38px 0 70px; }
.command-reference-page > pre { padding: clamp(18px, 4vw, 38px); margin-top: 24px; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); color: #e6e1d8; font: 14px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; }

/* Shared finance data surfaces */
.data-workspace { width: min(1380px, 100%); padding: 32px clamp(22px, 3vw, 42px) 54px; margin: 0 auto; }
.transaction-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 370px; min-height: calc(100vh - 80px); }
.transaction-main { width: 100%; margin: 0; }
.transaction-detail { min-width: 0; }
.data-table-row.is-selected { box-shadow: inset 3px 0 0 var(--primary); background: rgba(215,174,93,.045); }
.side-editor { display: flex; flex-direction: column; gap: 15px; margin-top: 24px; }
.side-editor .field { display: flex; flex-direction: column; gap: 6px; }
.side-editor .field > span { color: #e9e6e0; font-size: 12px; font-weight: 500; }
.side-editor input, .side-editor select { width: 100%; min-height: 43px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px; outline: none; background: var(--input); color: var(--foreground); font: 13px var(--font-sans); }
.side-editor input:focus, .side-editor select:focus { border-color: var(--ring); box-shadow: 0 0 0 3px rgba(215,174,93,.12); }
.side-editor .field > small { color: var(--destructive); font-size: 11px; }
.side-editor .field > small:empty { display: none; }
.data-workspace > .loan-empty { margin-top: 30px; }
.metric-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 28px; }
.metric-strip-four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-strip article { position: relative; min-width: 0; padding: 22px 24px; border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(135deg, #17181b, #131417); }
.metric-strip article > span { display: block; margin-bottom: 7px; color: var(--muted-foreground); font-size: 12px; }
.metric-strip article > strong { display: block; overflow: hidden; font: 500 clamp(18px, 2vw, 26px)/1.2 var(--font-serif); text-overflow: ellipsis; white-space: nowrap; }
.metric-strip article > svg { position: absolute; top: 18px; right: 18px; width: 21px; color: var(--primary); opacity: .75; }
.metric-income > strong, .money-cell.income, .list-amount.income { color: #9bcf79; }
.metric-expense > strong, .money-cell.expense, .list-amount.expense { color: #e58173; }
.status-badge.income, .status-badge.completed { color: #9bcf79; background: rgba(116,164,84,.14); }
.status-badge.expense, .status-badge.cancelled { color: #e58173; background: rgba(204,91,75,.14); }
.status-badge.active { color: #e3bb6c; background: rgba(215,174,93,.14); }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, .8fr); gap: 20px; margin-top: 22px; }
.overview-side-stack { display: flex; flex-direction: column; gap: 20px; }
.data-panel, .data-table-panel { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: #141518; }
.data-panel > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.data-panel h2 { margin: 0; font: 500 23px/1.2 var(--font-serif); }
.data-panel header p { margin: 4px 0 0; color: var(--muted-foreground); font-size: 12px; }
.panel-empty { padding: 28px 22px; margin: 0; color: var(--muted-foreground); }
.compact-list > a, .mini-loan-list > a { display: flex; align-items: center; gap: 13px; min-height: 66px; padding: 10px 20px; border-bottom: 1px solid var(--border); text-decoration: none; }
.compact-list > a:last-child, .mini-loan-list > a:last-child { border-bottom: 0; }
.compact-list > a:hover, .mini-loan-list > a:hover, .progress-list > a:hover { background: rgba(255,255,255,.02); }
.list-icon { display: inline-grid; flex: 0 0 auto; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--primary); background: rgba(215,174,93,.1); }
.list-icon svg { width: 18px; }
.list-icon.income { color: #9bcf79; background: rgba(116,164,84,.12); }
.list-icon.expense { color: #e58173; background: rgba(204,91,75,.12); }
.list-copy, .integration-row > span:last-child, .vault-settings-list > div > span:last-child { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.list-copy strong { overflow: hidden; font-size: 13px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.list-copy small, .mini-loan-list small, .progress-list small, .integration-row small, .vault-settings-list small { color: var(--muted-foreground); font-size: 11px; }
.list-amount { margin-left: auto; font-size: 12px; white-space: nowrap; }
.progress-list > a { display: flex; flex-direction: column; gap: 9px; padding: 14px 20px; border-bottom: 1px solid var(--border); text-decoration: none; }
.progress-list > a:last-child { border-bottom: 0; }
.progress-list > a > span { display: flex; flex-direction: column; }
.mini-loan-list > a { justify-content: space-between; }
.mini-loan-list > a > span { display: flex; min-width: 0; flex-direction: column; }
.mini-loan-list > a > strong { font-size: 12px; white-space: nowrap; }
.data-toolbar { display: flex; align-items: center; gap: 12px; margin-top: 24px; }
.data-toolbar .search-control { width: min(340px, 100%); margin-left: auto; }
.toolbar-select { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 11px; border: 1px solid var(--border); border-radius: 7px; color: var(--muted-foreground); background: var(--input); }
.toolbar-select svg { width: 17px; }
.toolbar-select select { border: 0; outline: none; background: transparent; color: var(--foreground); }
.data-table-panel { margin-top: 16px; overflow: hidden; }
.data-table-panel > footer { padding: 15px 18px; border-top: 1px solid var(--border); color: var(--muted-foreground); font-size: 12px; }
.data-table { overflow-x: auto; }
.data-table-head, .data-table-row { display: grid; grid-template-columns: 105px minmax(190px, 1.6fr) minmax(110px, .8fr) 85px minmax(125px, .8fr) 80px 44px; align-items: center; min-width: 880px; column-gap: 15px; padding: 0 16px; }
.data-table-head { min-height: 48px; color: #c7c4bd; font-size: 12px; }
.data-table-row { min-height: 66px; border-top: 1px solid var(--border); color: #d9d6cf; font-size: 12px; }
.data-table-row:hover { background: rgba(255,255,255,.018); }
.data-table-row time, .data-table-row > span { min-width: 0; }
.primary-cell { display: flex; flex-direction: column; }
.primary-cell strong { overflow: hidden; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.primary-cell small { color: var(--muted-foreground); }
.money-cell { font-weight: 500; white-space: nowrap; }
.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 28px; }
.plan-card { display: flex; min-width: 0; flex-direction: column; gap: 11px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); text-decoration: none; }
.plan-card:hover, .plan-card.is-selected { border-color: rgba(215,174,93,.65); background: rgba(215,174,93,.045); }
.plan-card > strong { font: 500 20px/1.2 var(--font-serif); }
.plan-card > small { color: var(--muted-foreground); }
.plan-card-top, .plan-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.plan-card-bottom b { color: var(--primary); font-size: 12px; }
.category-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 28px; }
.category-card { display: grid; grid-template-columns: 44px minmax(0, 1fr) 40px; align-items: center; gap: 14px; min-height: 92px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
.category-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 9px; color: var(--primary); background: rgba(215,174,93,.1); }
.category-icon svg { width: 21px; }
.category-card h2 { margin: 0 0 3px; font-size: 14px; font-weight: 600; }
.category-card p { margin: 0; color: var(--muted-foreground); font-size: 11px; }
.footer-spacer { flex: 1; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 28px; }
.settings-vaults { grid-column: 1 / -1; }
.settings-list { margin: 0; padding: 8px 22px; }
.settings-list div { display: flex; justify-content: space-between; gap: 20px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.settings-list div:last-child { border-bottom: 0; }
.settings-list dt { color: var(--muted-foreground); }
.settings-list dd { margin: 0; text-align: right; }
.integration-row { display: flex; align-items: center; gap: 13px; padding: 22px; }
.vault-settings-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 20px; }
.vault-settings-list > div { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--input); }

@media (max-width: 1180px) {
  .transaction-workspace { grid-template-columns: minmax(0, 1fr) 330px; }
  .metric-strip-four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .overview-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .settings-vaults { grid-column: auto; }
  .vault-settings-list { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  .telegram-workspace { padding: 26px 18px 40px; }
  .telegram-grid { grid-template-columns: 1fr; margin-top: 25px; }
  .telegram-card { padding: 22px; }
  .connection-status { align-self: flex-start; }
  .telegram-topbar-title { display: none; }
  .data-workspace { padding: 25px 18px 40px; }
  .transaction-workspace { display: block; min-height: calc(100vh - 68px); }
  .metric-strip, .metric-strip-four { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-strip article { padding: 17px 14px; }
  .metric-strip article > strong { font-size: 17px; }
  .metric-strip article > svg { display: none; }
  .data-toolbar { align-items: stretch; flex-direction: column; }
  .data-toolbar .segmented-control { width: 100%; }
  .data-toolbar .toolbar-select, .data-toolbar .search-control { width: 100%; margin: 0; }
  .data-toolbar .search-control { display: flex; }
  .data-table-head { display: none; }
  .data-table-row, .transaction-table .data-table-row { grid-template-columns: minmax(0, 1fr) auto 40px; min-width: 0; padding: 14px 10px; gap: 5px 10px; }
  .data-table-row time { grid-column: 1; grid-row: 2; color: var(--muted-foreground); }
  .data-table-row .primary-cell { grid-column: 1; grid-row: 1; }
  .data-table-row > span:nth-child(3), .data-table-row > span:nth-child(4), .data-table-row > span:nth-child(6) { display: none; }
  .data-table-row .money-cell { grid-column: 2; grid-row: 1 / span 2; }
  .data-table-row .icon-button { grid-column: 3; grid-row: 1 / span 2; }
  .plan-grid, .category-grid { grid-template-columns: 1fr; }
  .vault-settings-list { grid-template-columns: 1fr; }
  .detail-actions { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 460px) {
  .metric-strip, .metric-strip-four { grid-template-columns: 1fr; }
  .overview-grid { margin-top: 14px; }
  .category-card { padding: 15px; }
  .page-heading .button.compact { padding: 0 12px; font-size: 12px; }
}
