:root {
  color-scheme: light;
  --primary: #0f8fa4;
  --primary-strong: #087185;
  --primary-soft: #e0f5f6;
  --bg: #f3f7f8;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #edf3f5;
  --ink: #112b36;
  --ink-soft: #385560;
  --muted: #70858e;
  --line: #dce6e9;
  --line-strong: #c7d7dc;
  --success: #15803d;
  --success-soft: #e9f8ed;
  --warning: #c66a08;
  --warning-soft: #fff5df;
  --danger: #dc2626;
  --danger-soft: #fff0f0;
  --info: #2563eb;
  --shadow-sm: 0 2px 8px rgb(27 62 74 / 7%);
  --shadow-md: 0 14px 40px rgb(27 62 74 / 12%);
  --shadow-lg: 0 28px 80px rgb(18 48 61 / 20%);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --sidebar-width: 272px;
  --topbar-height: 74px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Tahoma, Arial, sans-serif;
  font-size: 15px;
}

html[data-theme='dark'] {
  color-scheme: dark;
  --primary: #22b8c7;
  --primary-strong: #67d5dd;
  --primary-soft: #133d46;
  --bg: #0d171d;
  --surface: #132129;
  --surface-raised: #172832;
  --surface-muted: #1b2d36;
  --ink: #edf8fa;
  --ink-soft: #c3d5da;
  --muted: #8fa8b0;
  --line: #293d46;
  --line-strong: #38515b;
  --success: #4ade80;
  --success-soft: #173926;
  --warning: #fbbf24;
  --warning-soft: #3b2d13;
  --danger: #fb7185;
  --danger-soft: #3d1d25;
  --info: #60a5fa;
  --shadow-sm: 0 2px 8px rgb(0 0 0 / 20%);
  --shadow-md: 0 14px 40px rgb(0 0 0 / 28%);
  --shadow-lg: 0 28px 80px rgb(0 0 0 / 45%);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); scroll-behavior: smooth; }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--ink); background: var(--bg); overflow-x: hidden; }
body.sidebar-open { overflow: hidden; }
button, input, select, textarea { color: inherit; font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
.hidden { display: none !important; }
.ltr, [dir='ltr'] { unicode-bidi: isolate; }
.skip-link { position: fixed; inset-block-start: 8px; inset-inline-start: 8px; z-index: 9999; transform: translateY(-150%); padding: .65rem 1rem; border-radius: 8px; color: white; background: var(--primary); }
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }

.boot-screen { position: fixed; inset: 0; z-index: 5000; display: grid; place-content: center; justify-items: center; gap: 1rem; color: var(--ink); background: var(--bg); transition: opacity .2s ease; }
.loading-dots { display: flex; gap: .35rem; }
.loading-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); animation: loading .9s infinite alternate; }
.loading-dots i:nth-child(2) { animation-delay: .18s; }
.loading-dots i:nth-child(3) { animation-delay: .36s; }
@keyframes loading { to { transform: translateY(-7px); opacity: .35; } }

.app-logo { width: 43px; height: 43px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 14px; color: white; background: linear-gradient(145deg, #16adbd, #087185); box-shadow: 0 9px 23px rgb(15 143 164 / 24%); font-size: 1.25rem; font-weight: 900; }
.app-logo.large { width: 68px; height: 68px; border-radius: 22px; font-size: 2rem; }
.eyebrow { display: block; margin-bottom: .45rem; color: var(--primary-strong); font-size: .78rem; font-weight: 800; letter-spacing: .02em; }

.login-view { min-height: 100vh; display: grid; grid-template-columns: minmax(300px, 1fr) minmax(380px, 520px); align-items: center; gap: clamp(2rem, 8vw, 9rem); padding: clamp(1rem, 7vw, 7rem); background: radial-gradient(circle at 12% 15%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 34%), var(--bg); }
.login-art { max-width: 620px; }
.login-art h1 { margin: .7rem 0 1.2rem; font-size: clamp(2.6rem, 6vw, 5.7rem); line-height: 1.16; letter-spacing: -.045em; }
.login-art p { max-width: 500px; color: var(--muted); font-size: 1.05rem; line-height: 2; }
.login-card { display: grid; gap: 1.15rem; padding: clamp(1.4rem, 4vw, 2.5rem); border: 1px solid color-mix(in srgb, var(--line) 72%, transparent); border-radius: 28px; background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: var(--shadow-lg); backdrop-filter: blur(14px); }
.login-card h2 { margin: .2rem 0 .35rem; font-size: 1.85rem; }
.login-card p { margin: 0; color: var(--muted); }
.login-card > label { display: grid; gap: .5rem; color: var(--ink-soft); font-size: .9rem; font-weight: 700; }
.login-card > small { color: var(--muted); text-align: center; line-height: 1.7; }
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-inline-end: 3.2rem; }
.password-wrap button { position: absolute; inset-block-start: 50%; inset-inline-end: .35rem; transform: translateY(-50%); }

input, select, textarea { width: 100%; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 11px; padding: .67rem .8rem; color: var(--ink); background: var(--surface); outline: none; transition: border-color .15s, box-shadow .15s, background .15s; }
textarea { min-height: 110px; resize: vertical; line-height: 1.8; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--line)); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }
input[type='color'] { min-height: 44px; padding: .25rem; cursor: pointer; }
input[type='checkbox'] { width: 20px; min-height: 20px; accent-color: var(--primary); }
.field-help { color: var(--muted); font-size: .75rem; font-weight: 400; line-height: 1.6; }

.button, .icon-button, .chip-button { min-height: 44px; border: 0; cursor: pointer; transition: transform .15s, opacity .15s, background .15s, border-color .15s; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .65rem 1rem; border-radius: 11px; font-weight: 800; text-decoration: none; white-space: nowrap; }
.button.primary { color: white; background: linear-gradient(135deg, var(--primary), #087185); box-shadow: 0 7px 18px rgb(15 143 164 / 20%); }
.button.secondary { color: var(--primary-strong); background: var(--primary-soft); }
.button.ghost { color: var(--ink-soft); border: 1px solid var(--line); background: var(--surface); }
.button.danger { color: var(--danger); background: var(--danger-soft); }
.button.small { min-height: 36px; padding: .45rem .7rem; font-size: .82rem; }
.button.full { width: 100%; }
.button:hover, .icon-button:hover, .chip-button:hover { transform: translateY(-1px); }
.button:disabled, .icon-button:disabled { cursor: not-allowed; opacity: .5; transform: none; }
.icon-button { width: 44px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 11px; color: var(--ink-soft); background: transparent; font-size: 1.25rem; }
.icon-button:hover { background: var(--surface-muted); }
.icon-button.compact { width: 38px; min-height: 38px; }
.chip-button { display: inline-flex; align-items: center; gap: .35rem; min-height: 36px; padding: .4rem .7rem; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-soft); background: var(--surface); font-size: .8rem; }

.app-shell { min-height: 100vh; display: grid; direction: ltr; grid-template: 'top side' var(--topbar-height) 'main side' minmax(calc(100vh - var(--topbar-height)), auto) / minmax(0, 1fr) var(--sidebar-width); transition: grid-template-columns .2s ease; }
.app-shell > * { direction: rtl; }
.app-shell.sidebar-collapsed { grid-template-columns: minmax(0, 1fr) 82px; }
.sidebar { position: sticky; inset-block-start: 0; z-index: 40; grid-area: side; height: 100vh; display: flex; flex-direction: column; padding: 1rem .85rem; border-inline-start: 1px solid var(--line); background: var(--surface); overflow: hidden; transition: transform .2s ease; }
.sidebar-backdrop { display: none; }
.sidebar-brand { min-height: 56px; display: flex; align-items: center; gap: .75rem; padding: 0 .2rem 1rem; border-bottom: 1px solid var(--line); }
.sidebar-brand > span { min-width: 0; flex: 1; }
.sidebar-brand strong, .sidebar-brand small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-brand strong { font-size: .92rem; }
.sidebar-brand small { margin-top: .23rem; color: var(--muted); font-size: .72rem; }
.sidebar-toggle { transform: rotate(180deg); }
.sidebar-collapsed .sidebar-brand > span, .sidebar-collapsed .sidebar-toggle, .sidebar-collapsed .nav-label, .sidebar-collapsed .nav-section-label, .sidebar-collapsed .user-chip > span:not(.avatar) { display: none; }
.sidebar-collapsed .sidebar { padding-inline: .7rem; }
.sidebar-collapsed .sidebar-brand { justify-content: center; }
.primary-nav { flex: 1; display: flex; flex-direction: column; gap: .25rem; padding-block: 1rem; overflow-y: auto; scrollbar-width: thin; }
.nav-section-label { margin: .9rem .75rem .35rem; color: var(--muted); font-size: .68rem; font-weight: 800; }
.nav-item { position: relative; min-height: 45px; display: flex; align-items: center; gap: .75rem; width: 100%; padding: .55rem .7rem; border: 0; border-radius: 11px; color: var(--ink-soft); background: transparent; cursor: pointer; text-align: start; }
.nav-item:hover { color: var(--ink); background: var(--surface-muted); }
.nav-item.active { color: var(--primary-strong); background: var(--primary-soft); font-weight: 800; }
.nav-icon { width: 24px; display: grid; place-items: center; flex: 0 0 auto; font-size: 1.05rem; }
.nav-dot { width: 9px; height: 9px; border-radius: 3px; background: var(--item-color, var(--primary)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--item-color, var(--primary)) 15%, transparent); }
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-count { min-width: 24px; padding: .15rem .4rem; border-radius: 999px; color: var(--muted); background: var(--surface-muted); font-size: .7rem; text-align: center; }
.sidebar-footer { padding-top: .8rem; border-top: 1px solid var(--line); }
.user-chip { width: 100%; min-height: 53px; display: flex; align-items: center; gap: .75rem; padding: .4rem; border: 0; border-radius: 12px; color: inherit; background: transparent; cursor: pointer; text-align: start; }
.user-chip:hover { background: var(--surface-muted); }
.avatar { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; color: var(--primary-strong); background: var(--primary-soft); font-weight: 900; }
.user-chip > span:not(.avatar) { min-width: 0; }
.user-chip strong, .user-chip small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { margin-top: .2rem; color: var(--muted); font-size: .7rem; }

.topbar { position: sticky; inset-block-start: 0; z-index: 35; grid-area: top; min-width: 0; height: var(--topbar-height); display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem clamp(1rem, 3vw, 2.2rem); border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); }
.topbar-actions { display: flex; align-items: center; gap: .35rem; }
.global-search-trigger { width: min(480px, 48vw); min-height: 44px; display: flex; align-items: center; gap: .65rem; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: var(--surface); cursor: text; text-align: start; }
.global-search-trigger span:nth-child(2) { flex: 1; }
kbd { padding: .15rem .42rem; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--muted); background: var(--surface-muted); font: .72rem inherit; }
.notification-button { position: relative; }
.badge { position: absolute; inset-block-start: 2px; inset-inline-start: 1px; min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 .25rem; border: 2px solid var(--bg); border-radius: 999px; color: white; background: var(--danger); font-size: .63rem; font-weight: 800; }
.mobile-menu { display: none; }

.main-content { grid-area: main; min-width: 0; padding: clamp(1rem, 3vw, 2.2rem); outline: none; }
.page { width: min(100%, 1540px); margin-inline: auto; animation: page-in .18s ease; }
@keyframes page-in { from { opacity: .35; transform: translateY(5px); } }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-title-wrap { min-width: 0; }
.page-title { display: flex; align-items: center; gap: .65rem; margin: 0; font-size: clamp(1.45rem, 3vw, 2.05rem); letter-spacing: -.025em; }
.page-title-dot { width: 15px; height: 31px; flex: 0 0 auto; border-radius: 6px; background: var(--item-color, var(--primary)); }
.page-description { margin: .45rem 0 0; color: var(--muted); line-height: 1.8; }
.page-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }

.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat-card { position: relative; min-height: 132px; padding: 1.15rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.stat-card::after { content: ''; position: absolute; inset-block-end: -35px; inset-inline-end: -30px; width: 90px; height: 90px; border-radius: 50%; background: color-mix(in srgb, var(--stat-color, var(--primary)) 10%, transparent); }
.stat-label { color: var(--muted); font-size: .8rem; font-weight: 700; }
.stat-value { display: block; margin-top: .6rem; font-size: 2rem; font-weight: 900; letter-spacing: -.04em; }
.stat-hint { display: block; margin-top: .45rem; color: var(--muted); font-size: .72rem; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(310px, .7fr); gap: 1rem; align-items: start; }
.dashboard-stack { display: grid; gap: 1rem; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 62px; padding: .9rem 1rem; border-bottom: 1px solid var(--line); }
.panel-header h2, .panel-header h3 { margin: 0; font-size: 1rem; }
.panel-body { padding: 1rem; }
.money-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .7rem; }
.money-card { padding: .9rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-muted); }
.money-card small { color: var(--muted); }
.money-card strong { display: block; margin-top: .4rem; font-size: 1.1rem; direction: ltr; text-align: right; unicode-bidi: isolate; }
.chart-wrap { position: relative; min-height: 280px; }
.chart-empty { min-height: 260px; display: grid; place-items: center; color: var(--muted); text-align: center; }

.due-list, .activity-list, .notification-list { display: grid; gap: .2rem; }
.due-item, .activity-item, .notification-item { display: flex; align-items: center; gap: .8rem; padding: .75rem .25rem; border-bottom: 1px solid var(--line); }
.due-item:last-child, .activity-item:last-child, .notification-item:last-child { border-bottom: 0; }
.item-accent { width: 5px; height: 42px; flex: 0 0 auto; border-radius: 5px; background: var(--item-color, var(--primary)); }
.due-main, .activity-main, .notification-main { min-width: 0; flex: 1; }
.due-main strong, .notification-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.due-meta, .activity-meta, .notification-meta { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem .7rem; margin-top: .35rem; color: var(--muted); font-size: .72rem; }
.due-time { min-width: 76px; color: var(--ink-soft); text-align: end; font-size: .78rem; font-weight: 800; }
.due-time.overdue { color: var(--danger); }
.due-time.soon { color: var(--warning); }

.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.sheet-card { position: relative; min-height: 190px; display: flex; flex-direction: column; padding: 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); color: inherit; background: var(--surface); box-shadow: var(--shadow-sm); text-decoration: none; overflow: hidden; cursor: pointer; }
.sheet-card::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 6px; background: var(--item-color, var(--primary)); }
.sheet-card:hover { border-color: color-mix(in srgb, var(--item-color, var(--primary)) 55%, var(--line)); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.sheet-card-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.sheet-icon { width: 43px; height: 43px; display: grid; place-items: center; border-radius: 13px; color: var(--item-color, var(--primary)); background: color-mix(in srgb, var(--item-color, var(--primary)) 12%, transparent); font-size: 1.15rem; }
.sheet-card h3 { margin: 1rem 0 .4rem; font-size: 1.15rem; }
.sheet-card p { min-height: 44px; margin: 0; color: var(--muted); line-height: 1.7; font-size: .8rem; }
.sheet-card-footer { display: flex; align-items: center; justify-content: space-between; gap: .7rem; margin-top: auto; padding-top: .9rem; color: var(--muted); font-size: .75rem; }
.new-sheet-card { place-items: center; justify-content: center; border-style: dashed; text-align: center; }
.new-sheet-card::before { display: none; }

.sheet-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; padding: .7rem; margin-bottom: .8rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.sheet-search { min-width: 220px; max-width: 440px; flex: 1; position: relative; }
.sheet-search input { padding-inline-start: 2.5rem; }
.sheet-search span { position: absolute; inset-block-start: 50%; inset-inline-start: .8rem; transform: translateY(-50%); color: var(--muted); }
.toolbar-select { width: auto; min-width: 145px; max-width: 210px; }
.active-filters { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.view-switch { display: flex; padding: .2rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-muted); }
.view-switch button { min-width: 38px; min-height: 34px; border: 0; border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; }
.view-switch button.active { color: var(--primary-strong); background: var(--surface); box-shadow: var(--shadow-sm); }

.data-panel { min-width: 0; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.table-scroll { max-width: 100%; overflow: auto; overscroll-behavior-inline: contain; }
.data-table { width: 100%; min-width: 850px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.data-table th { position: sticky; inset-block-start: 0; z-index: 2; height: 49px; padding: .65rem .75rem; border-bottom: 1px solid var(--line-strong); color: var(--muted); background: var(--surface-muted); font-size: .73rem; text-align: start; white-space: nowrap; }
.data-table th:first-child { position: sticky; inset-inline-start: 0; z-index: 3; }
.data-table td:first-child { position: sticky; inset-inline-start: 0; z-index: 1; background: color-mix(in srgb, var(--row-color, var(--surface)) 9%, var(--surface)); box-shadow: -8px 0 12px -12px rgb(0 0 0 / 25%); }
.data-table th button { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: .4rem; padding: 0; border: 0; color: inherit; background: transparent; cursor: pointer; text-align: start; }
.data-table td { height: 53px; padding: .35rem .7rem; border-bottom: 1px solid var(--line); color: var(--ink-soft); background: color-mix(in srgb, var(--row-color, transparent) 8%, var(--surface)); font-size: .82rem; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.data-table td[data-editable='true'] { cursor: cell; }
.data-table td[data-editable='true']:hover { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 40%, transparent); }
.data-table td.saving { position: relative; opacity: .7; }
.data-table td.saving::after { content: ''; position: absolute; inset-block-end: 2px; inset-inline: 5px; height: 2px; background: var(--primary); animation: saving 1s infinite; }
@keyframes saving { 50% { opacity: .25; transform: scaleX(.45); } }
.cell-editor { min-height: 38px; padding: .35rem .5rem; border-radius: 7px; font-size: .82rem; }
.row-title { color: var(--ink); font-weight: 800; }
.status-pill, .tag { display: inline-flex; align-items: center; gap: .35rem; max-width: 100%; padding: .28rem .55rem; border-radius: 999px; color: var(--status-color, var(--ink-soft)); background: color-mix(in srgb, var(--status-color, var(--muted)) 12%, transparent); font-size: .7rem; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-pill::before { content: ''; width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--status-color, var(--muted)); }
.amount { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.link-cell { color: var(--primary-strong); text-decoration: none; }
.row-actions { display: flex; justify-content: flex-end; gap: .15rem; }
.row-actions .icon-button { width: 34px; min-height: 34px; font-size: 1rem; }
.card-list { display: none; gap: .7rem; padding: .7rem; }
.record-card { position: relative; padding: .9rem; border: 1px solid var(--line); border-radius: 14px; background: color-mix(in srgb, var(--row-color, transparent) 8%, var(--surface)); overflow: hidden; }
.record-card::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 5px; background: var(--row-color, var(--sheet-color, var(--primary))); }
.record-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .7rem; }
.record-card-title { min-width: 0; }
.record-card-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-card-title small { display: block; margin-top: .35rem; color: var(--muted); }
.record-card-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; margin-top: .85rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.record-card-field { min-width: 0; }
.record-card-field small { display: block; margin-bottom: .25rem; color: var(--muted); font-size: .68rem; }
.record-card-field span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .8rem; }
.record-card-actions { display: flex; justify-content: flex-end; gap: .4rem; margin-top: .75rem; }

.pagination { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .75rem; }
.pagination-actions { display: flex; align-items: center; gap: .35rem; }
.empty-state { min-height: 290px; display: grid; place-content: center; justify-items: center; gap: .65rem; padding: 2rem; color: var(--muted); text-align: center; }
.empty-icon { width: 62px; height: 62px; display: grid; place-items: center; border-radius: 20px; color: var(--primary-strong); background: var(--primary-soft); font-size: 1.8rem; }
.empty-state h3 { margin: .35rem 0 0; color: var(--ink); }
.empty-state p { max-width: 410px; margin: 0 0 .5rem; line-height: 1.8; }

.customer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .8rem; }
.customer-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .75rem; padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.customer-avatar { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 14px; color: var(--customer-color, var(--primary)); background: color-mix(in srgb, var(--customer-color, var(--primary)) 13%, transparent); font-weight: 900; }
.customer-info { min-width: 0; }
.customer-info strong, .customer-info small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.customer-info small { margin-top: .3rem; color: var(--muted); }

.modal-backdrop { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 1rem; background: rgb(5 18 24 / 58%); backdrop-filter: blur(5px); animation: fade-in .15s ease; }
@keyframes fade-in { from { opacity: 0; } }
.modal { width: min(100%, 650px); max-height: min(90vh, 920px); display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 22px; background: var(--surface-raised); box-shadow: var(--shadow-lg); animation: modal-in .18s ease; overflow: hidden; }
.modal.wide { width: min(100%, 980px); }
@keyframes modal-in { from { opacity: .4; transform: translateY(12px) scale(.985); } }
.modal-header { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 1.1rem; }
.modal-body { flex: 1; padding: 1.1rem; overflow-y: auto; overscroll-behavior: contain; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: .55rem; padding: .85rem 1.1rem; border-top: 1px solid var(--line); background: var(--surface); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem; }
.form-field { display: grid; align-content: start; gap: .4rem; min-width: 0; color: var(--ink-soft); font-size: .82rem; font-weight: 700; }
.form-field.wide { grid-column: 1 / -1; }
.checkbox-field { min-height: 44px; display: flex; align-items: center; gap: .6rem; padding: .65rem .75rem; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.checkbox-field input { flex: 0 0 auto; }
.color-row { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: .6rem; }
.date-input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; }
.date-input-row .date-clear { min-width: 76px; }
.form-section { margin-bottom: 1.35rem; }
.form-section:last-child { margin-bottom: 0; }
.form-section-title { display: flex; align-items: center; justify-content: space-between; gap: .7rem; margin: 0 0 .8rem; padding-bottom: .65rem; border-bottom: 1px solid var(--line); font-size: .9rem; }
.segmented-tabs { display: flex; gap: .25rem; padding: .25rem; margin-bottom: 1rem; border-radius: 11px; background: var(--surface-muted); overflow-x: auto; }
.segmented-tabs button { min-height: 38px; padding: .45rem .8rem; border: 0; border-radius: 9px; color: var(--muted); background: transparent; cursor: pointer; white-space: nowrap; }
.segmented-tabs button.active { color: var(--primary-strong); background: var(--surface); box-shadow: var(--shadow-sm); font-weight: 800; }
.settings-list { display: grid; gap: .55rem; }
.settings-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .7rem; min-height: 54px; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.drag-handle { color: var(--muted); cursor: grab; }
.settings-row-main { min-width: 0; }
.settings-row-main strong, .settings-row-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-row-main small { margin-top: .25rem; color: var(--muted); font-size: .68rem; }
.settings-row-actions { display: flex; gap: .2rem; }
.options-builder { display: grid; gap: .4rem; }
.option-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 42px; gap: .4rem; }

.search-overlay { position: fixed; inset: 0; z-index: 250; display: grid; align-items: start; justify-items: center; padding: min(11vh, 90px) 1rem 1rem; background: rgb(8 21 27 / 58%); backdrop-filter: blur(7px); }
.search-dialog { width: min(100%, 720px); max-height: min(76vh, 750px); display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 20px; background: var(--surface-raised); box-shadow: var(--shadow-lg); overflow: hidden; }
.search-input-wrap { display: flex; align-items: center; gap: .7rem; padding: .75rem; border-bottom: 1px solid var(--line); }
.search-input-wrap input { border: 0; box-shadow: none; background: transparent; font-size: 1.05rem; }
.search-results { overflow-y: auto; }
.search-result { width: 100%; display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; border: 0; border-bottom: 1px solid var(--line); color: inherit; background: transparent; cursor: pointer; text-align: start; }
.search-result:hover { background: var(--surface-muted); }
.search-result-main { min-width: 0; flex: 1; }
.search-result-main strong, .search-result-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result-main small { margin-top: .3rem; color: var(--muted); }

.toast-region { position: fixed; inset-block-end: calc(1rem + var(--safe-bottom)); inset-inline-start: 1rem; z-index: 400; width: min(calc(100% - 2rem), 390px); display: grid; gap: .55rem; pointer-events: none; }
.toast { display: flex; align-items: center; gap: .7rem; padding: .8rem .9rem; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); background: var(--surface-raised); box-shadow: var(--shadow-md); pointer-events: auto; animation: toast-in .2s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.toast.success { border-inline-start: 4px solid var(--success); }
.toast.error { border-inline-start: 4px solid var(--danger); }
.toast.warning { border-inline-start: 4px solid var(--warning); }
.toast span { flex: 1; line-height: 1.7; font-size: .8rem; }
.inline-alert { padding: .75rem .85rem; border-radius: 10px; line-height: 1.7; font-size: .8rem; }
.inline-alert.error { color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); background: var(--danger-soft); }
.inline-alert.success { color: var(--success); border: 1px solid color-mix(in srgb, var(--success) 30%, transparent); background: var(--success-soft); }
.network-status { position: fixed; inset-block-end: calc(1rem + var(--safe-bottom)); inset-inline-end: 1rem; z-index: 450; padding: .6rem .85rem; border-radius: 10px; color: white; background: #172a34; box-shadow: var(--shadow-md); font-size: .78rem; }
.bottom-nav { display: none; }

.skeleton { position: relative; min-height: 14px; border-radius: 7px; background: var(--surface-muted); overflow: hidden; }
.skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 80%, transparent), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.progress { height: 9px; border-radius: 999px; background: var(--surface-muted); overflow: hidden; }
.progress > span { display: block; height: 100%; width: var(--progress, 0%); border-radius: inherit; background: var(--primary); transition: width .2s; }
.code-box { padding: .8rem; border: 1px solid var(--line); border-radius: 10px; color: var(--ink-soft); background: var(--surface-muted); direction: ltr; text-align: left; font: .75rem ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; user-select: all; }
.trash-section { margin-bottom: 1.5rem; }
.trash-section h2 { font-size: 1rem; }

#jdp-container { z-index: 600 !important; font-family: Tahoma, Arial, sans-serif !important; }

@media (max-width: 1240px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  :root { --topbar-height: 64px; }
  body { padding-bottom: calc(70px + var(--safe-bottom)); }
  .app-shell, .app-shell.sidebar-collapsed { display: grid; grid-template: 'top' var(--topbar-height) 'main' auto / minmax(0, 1fr); }
  .sidebar { position: fixed; inset-block: 0; inset-inline-end: 0; width: min(86vw, 310px); z-index: 120; transform: translateX(105%); box-shadow: var(--shadow-lg); }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 110; display: block; border: 0; padding: 0; background: rgb(5 18 24 / 52%); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .2s ease, visibility .2s ease; }
  .sidebar.mobile-open + .sidebar-backdrop { opacity: 1; visibility: visible; pointer-events: auto; }
  .sidebar-toggle { display: none; }
  .topbar { padding-inline: .75rem; }
  .mobile-menu { display: inline-grid; }
  .global-search-trigger { width: auto; flex: 1; justify-content: center; }
  .global-search-trigger span:nth-child(2), .global-search-trigger kbd { display: none; }
  .quick-add { width: 44px; padding: 0; border-radius: 12px; }
  .quick-add span:last-child { display: none; }
  .main-content { padding: 1rem .75rem; }
  .bottom-nav { position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 90; height: calc(65px + var(--safe-bottom)); display: grid; grid-template-columns: repeat(5, 1fr); align-items: start; padding: .35rem .35rem var(--safe-bottom); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent); box-shadow: 0 -8px 24px rgb(25 54 66 / 8%); backdrop-filter: blur(14px); }
  .bottom-nav button { min-height: 56px; display: grid; place-content: center; justify-items: center; gap: .18rem; border: 0; border-radius: 11px; color: var(--muted); background: transparent; cursor: pointer; }
  .bottom-nav button.active { color: var(--primary-strong); }
  .bottom-nav button span { font-size: 1.2rem; }
  .bottom-nav button small { font-size: .62rem; }
  .bottom-nav .bottom-fab { width: 54px; min-height: 54px; place-self: center; margin-top: -18px; border: 5px solid var(--bg); border-radius: 18px; color: white; background: linear-gradient(135deg, var(--primary), #087185); box-shadow: 0 10px 22px rgb(15 143 164 / 30%); font-size: 1.7rem; }
  .toast-region { inset-block-end: calc(76px + var(--safe-bottom)); }
  .network-status { inset-block-end: calc(76px + var(--safe-bottom)); }
  .stats-grid { grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: .7rem; }
  .stat-card { min-height: 116px; padding: .9rem; }
  .stat-value { font-size: 1.65rem; }
  .page-header { align-items: center; }
  .page-header .page-description { display: none; }
  .page-actions .button.ghost .desktop-label { display: none; }
  .sheet-toolbar { position: sticky; inset-block-start: calc(var(--topbar-height) + .35rem); z-index: 20; }
  .sheet-search { min-width: 160px; order: -2; }
  .toolbar-select { max-width: 48%; flex: 1; }
  .table-scroll { display: none; }
  .card-list { display: grid; }
  .data-panel.force-table .table-scroll { display: block; }
  .data-panel.force-table .card-list { display: none; }
  .pagination { padding-inline: .75rem; }
  .pagination > span { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: calc(100vh - 38px); max-height: calc(100dvh - 38px); border-radius: 22px 22px 0 0; padding-bottom: var(--safe-bottom); animation-name: sheet-in; }
  @keyframes sheet-in { from { transform: translateY(100%); } }
  .modal.wide { width: 100%; }
  .modal-header { position: relative; }
  .modal-header::before { content: ''; position: absolute; inset-block-start: 7px; inset-inline-start: calc(50% - 25px); width: 50px; height: 4px; border-radius: 99px; background: var(--line-strong); }
  .search-overlay { padding: 0; align-items: stretch; }
  .search-dialog { width: 100%; max-height: 100vh; border: 0; border-radius: 0; }
}

@media (max-width: 640px) {
  :root { font-size: 14px; }
  .login-view { grid-template-columns: 1fr; align-content: center; gap: 1.2rem; padding: 1rem; }
  .login-art { text-align: center; }
  .login-art .app-logo { margin-inline: auto; }
  .login-art h1 { margin-block: .6rem; font-size: 2.25rem; }
  .login-art p:not(.eyebrow) { display: none; }
  .login-card { border-radius: 22px; }
  .page-header { margin-bottom: 1rem; }
  .page-title { font-size: 1.4rem; }
  .page-actions { gap: .3rem; }
  .page-actions .button { min-width: 44px; padding-inline: .7rem; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card:nth-child(5) { grid-column: 1 / -1; }
  .dashboard-grid { gap: .7rem; }
  .panel-body { padding: .75rem; }
  .chart-wrap { min-height: 240px; }
  .sheet-grid { grid-template-columns: 1fr; gap: .7rem; }
  .sheet-card { min-height: 160px; }
  .sheet-toolbar { padding: .55rem; }
  .sheet-search { width: calc(100% - 90px); max-width: none; flex-basis: calc(100% - 90px); }
  .toolbar-select { min-width: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field.wide { grid-column: auto; }
  .modal-footer { position: sticky; inset-block-end: 0; }
  .modal-footer .button { flex: 1; }
  .record-card-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .customer-grid { grid-template-columns: 1fr; }
  .due-time { min-width: 64px; }
}

@media (max-width: 390px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: .55rem; }
  .stat-card { min-height: 108px; padding: .75rem; }
  .stat-value { font-size: 1.45rem; }
  .topbar-actions { gap: 0; }
  .record-card-fields { grid-template-columns: 1fr; }
}

@media (min-width: 901px) {
  .data-panel.force-cards .table-scroll { display: none; }
  .data-panel.force-cards .card-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
}

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