:root {
  color-scheme: light;
  --ink: #15202d;
  --soft: #53606f;
  --faint: #7c8897;
  --nav: #0d1b2a;
  --nav-soft: #162638;
  --canvas: #f3f5f6;
  --surface: #ffffff;
  --line: #dfe4e8;
  --line-soft: #ecf0f2;
  --teal: #147d79;
  --teal-dark: #0f615f;
  --mint: #21b889;
  --mint-bright: #74dbc2;
  --mint-pale: #e7f8f2;
  --danger: #b5473c;
  --danger-pale: #fff0ee;
  --shadow: 0 14px 40px rgba(13, 27, 42, 0.09);
  --sidebar: 244px;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font: 14px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid rgba(20, 125, 121, 0.28); outline-offset: 2px; }
.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; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; font-size: 19px; font-weight: 780; letter-spacing: -0.02em; text-decoration: none; }
.brand-mark { position: relative; display: inline-grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; overflow: hidden; border-radius: 10px; color: var(--nav); background: var(--mint-bright); box-shadow: 0 8px 25px rgba(116, 219, 194, 0.16); }
.brand-mark::before, .brand-mark::after { position: absolute; width: 14px; height: 3px; border-radius: 9px; background: currentColor; content: ""; transform: rotate(-46deg); }
.brand-mark::before { translate: -4px 3px; }
.brand-mark::after { translate: 4px -3px; }

/* Access */
.access-page { background: radial-gradient(circle at 76% 18%, rgba(116, 219, 194, 0.16), transparent 28%), linear-gradient(135deg, #eef5f5 0%, #f8faf9 52%, #edf4f3 100%); }
.access-layout { display: grid; grid-template-columns: minmax(330px, 0.92fr) minmax(520px, 1.08fr); min-height: 100vh; }
.access-story { position: relative; display: flex; min-height: 100vh; overflow: hidden; padding: 44px clamp(36px, 5vw, 76px); color: #fff; background: var(--nav); }
.access-story::before, .access-story::after { position: absolute; border-radius: 999px; content: ""; pointer-events: none; }
.access-story::before { top: -130px; right: -170px; width: 440px; height: 440px; border: 1px solid rgba(116, 219, 194, 0.17); box-shadow: 0 0 0 70px rgba(116, 219, 194, 0.035), 0 0 0 145px rgba(116, 219, 194, 0.025); }
.access-story::after { bottom: -120px; left: -90px; width: 330px; height: 330px; background: rgba(20, 125, 121, 0.18); }
.story-inner { position: relative; z-index: 1; display: flex; width: 100%; max-width: 560px; flex: 1; flex-direction: column; margin: 0 auto; }
.story-copy { margin: auto 0; padding: 70px 0; }
.story-copy .eyebrow { color: var(--mint-bright); }
.story-copy h1 { max-width: 520px; margin: 0; color: #fff; font-size: clamp(40px, 5vw, 64px); font-weight: 720; line-height: 0.99; letter-spacing: -0.055em; }
.story-copy .intro { max-width: 465px; margin: 25px 0 38px; color: #aebcc8; font-size: 16px; line-height: 1.7; }
.benefits { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.benefits li { display: flex; align-items: center; gap: 12px; color: #d8e3e6; font-weight: 570; }
.benefit-check { display: grid; width: 24px; height: 24px; flex: 0 0 auto; place-items: center; border: 1px solid rgba(116, 219, 194, 0.33); border-radius: 50%; color: var(--mint-bright); background: rgba(116, 219, 194, 0.08); }
.benefit-check .icon { width: 13px; height: 13px; }
.story-foot { color: #718394; font-size: 12px; }
.access-shell { display: grid; min-height: 100vh; padding: 48px clamp(28px, 6vw, 96px); place-items: center; }
.access-card { width: min(100%, 540px); }
.mobile-brand { display: none; }
.welcome { margin-bottom: 27px; }
.welcome h2 { margin: 0 0 9px; font-size: 32px; line-height: 1.15; letter-spacing: -0.04em; }
.welcome p { margin: 0; color: var(--soft); line-height: 1.55; }
.access-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 28px; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: #eaf0f1; }
.access-tab { min-height: 44px; border: 0; border-radius: 8px; color: var(--soft); background: transparent; font-size: 13px; font-weight: 740; }
.access-tab[aria-selected="true"] { color: var(--ink); background: #fff; box-shadow: 0 3px 12px rgba(20, 43, 55, 0.08); }
.access-form { display: grid; gap: 19px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field { min-width: 0; }
.field label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 7px; color: #2c3e4d; font-size: 12px; font-weight: 750; }
.optional { color: #92a0aa; font-size: 10px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; }
.input-wrap { position: relative; }
.access-form input, .settings-form input, .settings-form textarea { width: 100%; border: 1px solid #cddade; border-radius: 10px; outline: 0; color: var(--ink); background: #fff; }
.access-form input { height: 49px; padding: 0 15px; }
.access-form input::placeholder { color: #a1adb5; }
.access-form input:focus, .settings-form input:focus, .settings-form textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(20, 125, 121, 0.09); }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(181, 71, 60, 0.08); }
.with-toggle { padding-right: 66px !important; }
.password-toggle { position: absolute; top: 50%; right: 8px; min-width: 50px; padding: 6px 7px; border: 0; border-radius: 6px; color: var(--teal-dark); background: transparent; font-size: 11px; font-weight: 760; transform: translateY(-50%); }
.password-toggle:hover { background: var(--mint-pale); }
.field-hint, .field-error { margin: 7px 1px 0; font-size: 11px; line-height: 1.4; }
.field-hint { color: #84929c; }
.field-error { color: var(--danger); font-weight: 650; }
.field-error:empty { display: none; }
.password-requirements { display: grid; gap: 3px; margin-top: 7px; color: var(--soft); font-size: 11px; }
.password-requirements span::before { display: inline-block; width: 1.3em; color: var(--danger); content: "○"; }
.password-requirements span[data-met="true"] { color: var(--teal-dark); }
.password-requirements span[data-met="true"]::before { content: "✓"; }
.access-message { min-height: 21px; margin: 0; color: var(--soft); font-size: 12px; }
.access-message[data-state="error"] { color: var(--danger); }
.access-message[data-state="success"] { color: var(--teal-dark); }
.access-note { margin: 2px 0 0; color: #84929c; font-size: 11px; line-height: 1.55; text-align: center; }

/* Shared buttons */
.primary-btn, .secondary-btn { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border-radius: 9px; font-weight: 750; text-decoration: none; }
.primary-btn { border: 1px solid var(--teal); color: #fff; background: var(--teal); box-shadow: 0 10px 25px rgba(20, 125, 121, 0.16); }
.primary-btn:hover { background: var(--teal-dark); }
.secondary-btn { border: 1px solid var(--line); color: var(--ink); background: #fff; }
.primary-btn:disabled, .secondary-btn:disabled { cursor: wait; opacity: 0.58; }
.access-form .primary-btn { width: 100%; min-height: 50px; }

/* Authenticated shell */
.sidebar { position: fixed; z-index: 50; inset: 0 auto 0 0; display: flex; width: var(--sidebar); flex-direction: column; padding: 26px 18px 20px; color: #d9e0e7; background: var(--nav); transition: transform 0.22s; }
.sidebar .brand { padding: 0 9px 30px; color: #fff; }
.nav-label { margin: 0 12px 8px; color: #748397; font-size: 10px; font-weight: 750; letter-spacing: 0.14em; text-transform: uppercase; }
.nav-list { display: grid; gap: 4px; margin: 0 0 25px; }
.nav-link { display: flex; width: 100%; min-height: 43px; align-items: center; gap: 11px; padding: 0 12px; border: 0; border-radius: 8px; color: #9eacbb; background: transparent; text-align: left; text-decoration: none; }
.nav-link:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
.nav-link.active { color: #fff; background: var(--nav-soft); }
.nav-link.active .icon { color: #53dcaf; }
.sidebar-spacer { flex: 1; }
.sidebar-profile { display: flex; align-items: center; gap: 10px; padding: 15px 8px 10px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.avatar { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: #17372e; background: #8ce4c8; font-size: 12px; font-weight: 800; }
.profile-copy { min-width: 0; }
.profile-copy strong, .profile-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy strong { color: #eef3f7; font-size: 13px; }
.profile-copy small { color: #78889a; font-size: 11px; }
.logout-button { margin-top: 2px; }
.main-shell { min-height: 100vh; margin-left: var(--sidebar); }
.topbar { position: sticky; z-index: 30; top: 0; display: flex; height: 72px; align-items: center; justify-content: space-between; padding: 0 clamp(22px, 4vw, 54px); border-bottom: 1px solid var(--line-soft); background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(12px); }
.crumb { color: var(--faint); font-size: 12px; }
.crumb strong { color: var(--ink); }
.topbar-user { color: var(--soft); font-size: 12px; font-weight: 700; }
.icon-btn { display: grid; width: 39px; height: 39px; place-items: center; border: 1px solid var(--line); border-radius: 9px; color: var(--soft); background: #fff; }
.icon-btn.mobile-menu { display: none; }
.content { max-width: 1180px; margin: 0 auto; padding: 38px clamp(22px, 4vw, 54px) 56px; }
.page-head { margin-bottom: 28px; }
.eyebrow { margin: 0 0 5px; color: var(--teal-dark); font-size: 11px; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(30px, 4vw, 36px); line-height: 1.15; letter-spacing: -0.035em; }
.intro { margin: 7px 0 0; color: var(--soft); }
.panel { padding: 0; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 3px 14px rgba(13, 27, 42, 0.06); }
.empty-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.empty-panel { min-height: 230px; padding: 28px; }
.empty-panel.wide { grid-column: 1 / -1; }
.empty-icon { display: grid; width: 46px; height: 46px; place-items: center; margin-bottom: 23px; border-radius: 12px; color: var(--teal-dark); background: var(--mint-pale); }
.empty-icon .icon { width: 22px; height: 22px; }
.empty-panel h2 { margin: 0 0 8px; font-size: 18px; }
.empty-panel p { max-width: 48ch; margin: 0; color: var(--soft); }
.empty-panel > .primary-btn, .empty-panel > .secondary-btn { margin-top: 20px; }
.placeholder-note { display: inline-flex; margin-top: 22px; padding: 7px 10px; border-radius: 999px; color: #37685a; background: var(--mint-pale); font-size: 11px; font-weight: 700; }

/* Settings */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.7fr); gap: 18px; align-items: start; }
.panel-head { padding: 21px 23px 17px; border-bottom: 1px solid var(--line-soft); }
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-head p { margin: 4px 0 0; color: var(--faint); font-size: 11px; }
.settings-form { padding: 22px 23px; }
.settings-form[aria-busy="true"] { opacity: 0.65; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.settings-fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
.field.full { grid-column: 1 / -1; }
.settings-form input { height: 42px; padding: 0 11px; }
.settings-form textarea { min-height: 100px; padding: 10px 11px; resize: vertical; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.form-status { min-height: 21px; margin: 0 auto 0 0; color: var(--soft); font-size: 12px; }
.form-status[data-state="error"] { color: var(--danger); }
.form-status[data-state="success"] { color: var(--teal-dark); }
.invoice-preview { padding: 25px; }
.preview-label { color: #155765; font-size: 10px; font-weight: 850; letter-spacing: 0.14em; text-transform: uppercase; }
.preview-org { margin: 8px 0 18px; overflow-wrap: anywhere; font-size: 26px; font-weight: 800; letter-spacing: -0.04em; }
.preview-rule { height: 1px; margin: 18px 0; background: #d6e5e9; }
.preview-title { margin-bottom: 10px; color: #155765; font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; }
.preview-copy { color: var(--soft); white-space: pre-line; overflow-wrap: anywhere; }
.preview-copy strong { display: block; margin-bottom: 6px; color: var(--ink); }
.preview-hint { display: flex; gap: 9px; margin-top: 18px; padding: 12px; border: 1px solid #ccebe1; border-radius: 9px; color: #37685a; background: var(--mint-pale); font-size: 11px; }
.preview-hint .icon { color: var(--teal-dark); }
.load-error { padding: 24px; color: var(--danger); background: var(--danger-pale); }

/* Clients */
.client-page-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.client-stats, .project-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 3px 14px rgba(13, 27, 42, 0.05); }
.client-stat { min-width: 0; padding: 19px 22px; border-right: 1px solid var(--line); }
.client-stat:last-child { border-right: 0; }
.client-stat span, .client-stat strong, .client-stat small { display: block; }
.client-stat span { color: var(--faint); font-size: 10px; font-weight: 780; letter-spacing: 0.07em; text-transform: uppercase; }
.client-stat strong { margin-top: 5px; overflow: hidden; color: var(--ink); font-size: clamp(20px, 2.4vw, 25px); letter-spacing: -0.03em; text-overflow: ellipsis; white-space: nowrap; }
.client-stat small { margin-top: 2px; color: var(--teal-dark); font-size: 10px; }
.clients-panel { overflow: hidden; }
.clients-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 19px 22px; border-bottom: 1px solid var(--line-soft); }
.clients-panel-head h2 { margin: 0; font-size: 15px; }
.clients-panel-head p { margin: 3px 0 0; color: var(--faint); font-size: 11px; }
.client-tools { display: flex; gap: 8px; }
.client-search { position: relative; display: block; }
.client-search .icon { position: absolute; top: 10px; left: 11px; width: 16px; height: 16px; color: var(--faint); pointer-events: none; }
.client-search input, .client-tools select { height: 38px; border: 1px solid var(--line); border-radius: 8px; outline: 0; color: var(--ink); background: #fff; }
.client-search input { width: 240px; padding: 0 12px 0 35px; }
.client-tools select { min-width: 124px; padding: 0 30px 0 11px; color: var(--soft); }
.client-search input:focus, .client-tools select:focus, .client-form input:focus, .client-form select:focus, .client-form textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(20, 125, 121, 0.09); }
.client-state { display: grid; min-height: 310px; padding: 54px 24px; place-items: center; align-content: center; text-align: center; }
.client-state-icon { display: grid; width: 48px; height: 48px; margin-bottom: 16px; place-items: center; border-radius: 13px; color: var(--teal-dark); background: var(--mint-pale); font-size: 20px; font-weight: 800; }
.client-state-icon .icon { width: 22px; height: 22px; }
.client-state h3 { margin: 0 0 5px; font-size: 17px; }
.client-state p { max-width: 460px; margin: 0; color: var(--faint); font-size: 12px; }
.client-state .secondary-btn { margin-top: 18px; }
.client-state-error .client-state-icon { color: var(--danger); background: var(--danger-pale); }
.client-loading-mark::before { width: 20px; height: 20px; border: 2px solid rgba(20, 125, 121, 0.2); border-top-color: var(--teal); border-radius: 50%; content: ""; animation: client-spin 0.8s linear infinite; }
@keyframes client-spin { to { transform: rotate(360deg); } }
.client-table-wrap { overflow-x: auto; }
.client-table { width: 100%; min-width: 790px; border-collapse: collapse; color: var(--ink); text-align: left; }
.client-table th { padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--faint); background: #fafbfb; font-size: 10px; font-weight: 760; letter-spacing: 0.06em; text-transform: uppercase; }
.client-table th:first-child, .client-table td:first-child { padding-left: 22px; }
.client-table th:last-child, .client-table td:last-child { padding-right: 22px; }
.client-table td { height: 70px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
.client-table tbody tr { cursor: pointer; transition: background 0.12s; }
.client-table tbody tr:hover, .client-table tbody tr:focus { background: #f7fbfa; }
.client-table tbody tr:focus { outline: 3px solid rgba(20, 125, 121, 0.2); outline-offset: -3px; }
.client-cell { display: flex; min-width: 190px; align-items: center; gap: 11px; }
.client-mark { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border-radius: 9px; color: #226c60; background: #e3f4ef; font-size: 10px; font-weight: 820; }
.client-cell strong, .client-cell small, .client-contact strong, .client-contact small { display: block; }
.client-cell strong, .client-contact strong { font-size: 12px; }
.client-cell small, .client-contact small { max-width: 230px; overflow: hidden; color: var(--faint); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.client-contact { color: var(--soft); }
.client-number, .client-money { font-size: 12px; font-variant-numeric: tabular-nums; }
.client-money { font-weight: 760; }
.client-status { display: inline-flex; min-height: 25px; align-items: center; padding: 2px 9px; border-radius: 20px; color: var(--teal-dark); background: var(--mint-pale); font-size: 10px; font-weight: 760; }
.client-status.inactive { color: #66717d; background: #edf0f2; }
.client-action-heading, .client-action { width: 62px; text-align: right; }
.client-action button { display: inline-grid; width: 32px; height: 32px; padding: 0; place-items: center; border: 0; border-radius: 7px; color: var(--faint); background: transparent; }
.client-action button:hover { color: var(--teal-dark); background: var(--mint-pale); }
.client-table-footer { display: flex; min-height: 62px; align-items: center; justify-content: space-between; gap: 18px; padding: 11px 22px; color: var(--faint); font-size: 11px; }
.client-table-footer p { margin: 0; }
.client-pagination { display: flex; align-items: center; gap: 10px; }
.client-pagination .secondary-btn { min-height: 34px; padding-inline: 12px; font-size: 11px; }
.client-drawer-open { overflow: hidden; }
.client-drawer-overlay { position: fixed; z-index: 100; inset: 0; width: 100%; padding: 0; border: 0; background: rgba(8, 18, 29, 0.48); opacity: 0; pointer-events: none; transition: opacity 0.18s; }
.client-drawer-overlay.open { opacity: 1; pointer-events: auto; }
.client-drawer { position: fixed; z-index: 110; inset: 0 0 0 auto; width: min(480px, 100vw); overflow-y: auto; color: var(--ink); background: #fff; box-shadow: -20px 0 50px rgba(8, 18, 29, 0.18); transform: translateX(105%); transition: transform 0.22s; }
.client-drawer.open { transform: translateX(0); }
.client-drawer-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; padding: 24px; border-bottom: 1px solid var(--line); }
.client-drawer-head h2 { margin: 0; font-size: 22px; letter-spacing: -0.025em; }
.client-drawer-head p { margin: 4px 0 0; color: var(--faint); font-size: 11px; }
.client-drawer-close { display: grid; width: 34px; height: 34px; flex: 0 0 auto; padding: 0; place-items: center; border: 0; border-radius: 8px; color: var(--soft); background: #f1f3f4; }
.client-form { padding: 24px; }
.client-identity { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line-soft); }
.client-identity .client-mark { width: 48px; height: 48px; font-size: 13px; }
.client-identity strong, .client-identity span { display: block; }
.client-identity span { color: var(--faint); font-size: 11px; }
.client-form-status { min-height: 20px; margin: 0 0 13px; color: var(--soft); font-size: 12px; }
.client-form-status:empty { min-height: 0; margin-bottom: 0; }
.client-form-status[data-state="error"] { padding: 10px 12px; border-radius: 8px; color: var(--danger); background: var(--danger-pale); }
.client-form-fields { min-width: 0; padding: 0; margin: 0; border: 0; }
.client-form[aria-busy="true"] .client-form-fields { opacity: 0.62; }
.client-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.client-form .field label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; color: var(--soft); font-size: 11px; font-weight: 720; }
.client-form input, .client-form select, .client-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; outline: 0; color: var(--ink); background: #fff; }
.client-form input, .client-form select { height: 42px; padding: 0 11px; }
.client-form textarea { min-height: 92px; padding: 10px 11px; resize: vertical; }
.client-toggle { display: flex !important; align-items: center !important; justify-content: space-between !important; padding: 14px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.client-toggle span strong, .client-toggle span small { display: block; }
.client-toggle span strong { color: var(--ink); font-size: 12px; }
.client-toggle span small { margin-top: 2px; color: var(--faint); font-size: 10px; font-weight: 500; }
.client-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.client-toggle i { position: relative; width: 42px; height: 24px; flex: 0 0 auto; border-radius: 20px; background: #c8cfd5; transition: 0.16s; }
.client-toggle i::after { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2); content: ""; transition: 0.16s; }
.client-toggle input:checked + i { background: var(--mint); }
.client-toggle input:checked + i::after { transform: translateX(18px); }
.client-toggle input:focus-visible + i { outline: 3px solid rgba(20, 125, 121, 0.28); outline-offset: 2px; }
.client-form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line-soft); }

/* Projects */
.project-page-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.project-stat span { display: flex; align-items: center; gap: 7px; }
.project-stat-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #4d78d0; }
.project-stat:nth-child(2) .project-stat-dot { background: var(--mint); }
.project-stat:nth-child(3) .project-stat-dot { background: #d79528; }
.project-stat:nth-child(4) .project-stat-dot { background: #7c5bb2; }
.project-tools select { min-width: 138px; }
.project-filters { display: flex; gap: 3px; overflow-x: auto; padding: 0 22px 13px; border-bottom: 1px solid var(--line-soft); scrollbar-width: thin; }
.project-filter { min-height: 34px; flex: 0 0 auto; padding: 7px 11px; border: 0; border-radius: 7px; color: var(--soft); background: transparent; font-size: 11px; font-weight: 720; }
.project-filter:hover { color: var(--ink); background: #f2f5f5; }
.project-filter.active { color: #fff; background: var(--nav); }
.project-table-wrap { overflow-x: auto; }
.project-table { width: 100%; min-width: 900px; border-collapse: collapse; color: var(--ink); text-align: left; }
.project-table th { padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--faint); background: #fafbfb; font-size: 10px; font-weight: 760; letter-spacing: 0.06em; text-transform: uppercase; }
.project-table th:first-child, .project-table td:first-child { padding-left: 22px; }
.project-table th:last-child, .project-table td:last-child { padding-right: 22px; }
.project-table td { height: 72px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
.project-table tbody tr { cursor: pointer; transition: background 0.12s; }
.project-table tbody tr:hover, .project-table tbody tr:focus { background: #f7fbfa; }
.project-table tbody tr:focus { outline: 3px solid rgba(20, 125, 121, 0.2); outline-offset: -3px; }
.project-cell { display: flex; min-width: 230px; align-items: center; gap: 11px; }
.project-mark { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border-radius: 9px; color: #4d68a3; background: #edf2ff; }
.project-mark .icon { width: 17px; height: 17px; }
.project-cell strong, .project-cell small, .project-date { display: block; }
.project-cell strong { font-size: 12px; }
.project-cell small { max-width: 310px; overflow: hidden; color: var(--faint); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.project-client-name, .project-date { color: var(--soft); font-size: 11px; }
.project-date + .project-date { color: var(--faint); font-size: 10px; }
.project-status { display: inline-flex; min-height: 25px; align-items: center; padding: 2px 9px; border-radius: 20px; color: #66717d; background: #edf0f2; font-size: 10px; font-weight: 760; }
.project-status.scheduled { color: #4968a9; background: #edf2ff; }
.project-status.in-progress { color: #936515; background: #fff7e4; }
.project-status.completed { color: var(--teal-dark); background: var(--mint-pale); }
.project-status.canceled { color: #b74632; background: #fff0ec; }
.project-active { display: inline-flex; align-items: center; gap: 6px; color: var(--soft); font-size: 10px; }
.project-active::before { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); content: ""; }
.project-active.inactive::before { background: #aab2ba; }
.project-drawer-open { overflow: hidden; }
.project-drawer { width: min(520px, 100vw); }
.project-identity .project-mark { width: 48px; height: 48px; }
.project-identity strong, .project-identity span { display: block; }
.project-identity span { color: var(--faint); font-size: 11px; }

/* Invoices */
.invoice-page-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.invoice-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.invoice-stat span { display: flex; align-items: center; gap: 7px; }
.invoice-stat-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #4d78d0; }
.invoice-stat:nth-child(2) .invoice-stat-dot { background: var(--mint); }
.invoice-stat:nth-child(3) .invoice-stat-dot { background: var(--danger); }
.invoice-stat:nth-child(4) .invoice-stat-dot { background: #d79528; }
.invoice-panel { overflow: hidden; }
.invoice-panel-head { align-items: center; }
.invoice-title-row { display: flex; align-items: center; gap: 9px; }
.invoice-title-row h2 { margin: 0; }
.invoice-total { padding: 2px 8px; border-radius: 20px; color: var(--soft); background: #edf0f2; font-size: 10px; font-weight: 760; }
.invoice-tools select { min-width: 154px; }
.invoice-filters { padding-top: 0; }
.invoice-table-wrap { overflow-x: auto; }
.invoice-table { width: 100%; min-width: 870px; border-collapse: collapse; color: var(--ink); text-align: left; }
.invoice-table th { padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--faint); background: #fafbfb; font-size: 10px; font-weight: 760; letter-spacing: 0.06em; text-transform: uppercase; }
.invoice-table th:first-child, .invoice-table td:first-child { padding-left: 22px; }
.invoice-table th:last-child, .invoice-table td:last-child { padding-right: 22px; }
.invoice-table td { height: 70px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
.invoice-table tbody tr { cursor: pointer; transition: background 0.12s; }
.invoice-table tbody tr:hover, .invoice-table tbody tr:focus { background: #f7fbfa; }
.invoice-table tbody tr:focus { outline: 3px solid rgba(20, 125, 121, 0.2); outline-offset: -3px; }
.invoice-code { color: var(--soft); font-size: 12px; font-weight: 780; }
.invoice-client-cell { display: flex; min-width: 210px; align-items: center; gap: 10px; }
.invoice-client-mark { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border-radius: 8px; color: #4b67a6; background: #edf2ff; font-size: 9px; font-weight: 820; }
.invoice-client-cell strong, .invoice-client-cell small { display: block; }
.invoice-client-cell strong { font-size: 12px; }
.invoice-client-cell small { max-width: 240px; overflow: hidden; color: var(--faint); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.invoice-date { color: var(--soft); font-size: 11px; white-space: nowrap; }
.invoice-date.overdue { color: var(--danger); font-weight: 720; }
.invoice-amount { font-size: 12px; font-weight: 780; font-variant-numeric: tabular-nums; white-space: nowrap; }
.invoice-status { display: inline-flex; min-width: 66px; min-height: 25px; align-items: center; justify-content: center; padding: 2px 9px; border-radius: 20px; color: #4968a9; background: #edf2ff; font-size: 10px; font-weight: 760; text-transform: capitalize; white-space: nowrap; }
.invoice-status.overdue { color: #b74632; background: #fff0ec; }
.invoice-status.due-soon { color: #936515; background: #fff7e4; }
.invoice-status.draft { color: #66717d; background: #edf0f2; }
.invoice-status.void { color: #68717a; background: #e5e8ea; text-decoration: line-through; }
.invoice-status.partially-paid { color: #7d5a13; background: #fff4d7; }
.invoice-status.paid { color: var(--teal-dark); background: var(--mint-pale); }
.invoice-status.overpaid { color: #4d5fa8; background: #eef0ff; }
.invoice-row-action { display: inline-grid; width: 32px; height: 32px; padding: 0; place-items: center; border: 0; border-radius: 7px; color: var(--faint); background: transparent; }
.invoice-row-action:hover, .invoice-row-action[aria-expanded="true"] { color: var(--teal-dark); background: var(--mint-pale); }
.invoice-row-menu { position: fixed; z-index: 90; width: 168px; padding: 6px; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: 0 12px 32px rgba(8, 18, 29, 0.18); }
.invoice-row-menu button { display: flex; width: 100%; min-height: 34px; align-items: center; padding: 7px 10px; border: 0; border-radius: 6px; color: var(--ink); background: transparent; font-size: 11px; font-weight: 700; text-align: left; }
.invoice-row-menu button:hover, .invoice-row-menu button:focus-visible { color: var(--teal-dark); background: var(--mint-pale); outline: 0; }
.invoice-row-menu button:disabled { color: #9aa3aa; background: transparent; cursor: not-allowed; }

.invoice-layer-open { overflow: hidden; }
.invoice-layer-overlay { position: fixed; z-index: 100; inset: 0; width: 100%; padding: 0; border: 0; background: rgba(8, 18, 29, 0.48); opacity: 0; pointer-events: none; transition: opacity 0.18s; }
.invoice-layer-overlay.open { opacity: 1; pointer-events: auto; }
.invoice-detail-drawer { position: fixed; z-index: 110; inset: 0 0 0 auto; width: min(490px, 100vw); overflow-y: auto; color: var(--ink); background: #fff; box-shadow: -20px 0 50px rgba(8, 18, 29, 0.18); transform: translateX(105%); transition: transform 0.22s; }
.invoice-detail-drawer.open { transform: translateX(0); }
.invoice-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.invoice-detail-head > span { color: var(--faint); font-size: 10px; font-weight: 780; letter-spacing: 0.1em; text-transform: uppercase; }
.invoice-detail-body { padding: 25px 24px 32px; }
.invoice-detail-title { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
.invoice-detail-title h2 { margin: 0; font-size: 27px; letter-spacing: -0.035em; }
.invoice-detail-title p { margin: 5px 0 0; color: var(--faint); font-size: 11px; }
.invoice-detail-client { display: flex; align-items: center; gap: 12px; margin: 24px 0; padding: 15px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfb; }
.invoice-detail-client .invoice-client-mark { width: 40px; height: 40px; }
.invoice-detail-client strong, .invoice-detail-client span { display: block; }
.invoice-detail-client span { color: var(--faint); font-size: 11px; }
.invoice-detail-grid { display: grid; grid-template-columns: 1fr 1fr; border-block: 1px solid var(--line-soft); }
.invoice-detail-item { padding: 16px 0; }
.invoice-detail-item:nth-child(even) { padding-left: 18px; border-left: 1px solid var(--line-soft); }
.invoice-detail-item span { display: block; margin-bottom: 3px; color: var(--faint); font-size: 9px; font-weight: 720; letter-spacing: 0.06em; text-transform: uppercase; }
.invoice-detail-item strong { font-size: 12px; }
.invoice-party-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.invoice-party { min-width: 0; padding: 13px; border: 1px solid var(--line-soft); border-radius: 9px; }
.invoice-party > span { display: block; margin-bottom: 8px; color: var(--faint); font-size: 9px; font-weight: 760; letter-spacing: 0.07em; text-transform: uppercase; }
.invoice-party strong { display: block; overflow-wrap: anywhere; font-size: 11px; }
.invoice-party p { margin: 4px 0 0; color: var(--soft); font-size: 10px; line-height: 1.45; white-space: pre-line; overflow-wrap: anywhere; }
.invoice-detail-lines { margin: 22px 0; }
.invoice-detail-lines h3, .invoice-detail-section h3 { margin: 0 0 8px; font-size: 12px; }
.invoice-detail-line, .invoice-detail-total-row { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); color: var(--soft); font-size: 11px; }
.invoice-detail-line span { min-width: 0; }
.invoice-detail-line small { display: block; margin-top: 2px; color: var(--faint); font-size: 9px; }
.invoice-detail-line strong, .invoice-detail-total-row strong { color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.invoice-detail-total-row.grand { padding-top: 14px; border-top: 1px solid var(--line); border-bottom: 0; color: var(--ink); font-size: 15px; font-weight: 800; }
.invoice-detail-section { margin-top: 16px; padding: 13px; border: 1px solid var(--line-soft); border-radius: 9px; background: #fafbfb; }
.invoice-detail-section p { margin: 0; color: var(--soft); font-size: 11px; white-space: pre-line; overflow-wrap: anywhere; }
.invoice-history-note { margin-top: 17px; padding: 12px 13px; border: 1px solid #d7dce0; border-radius: 9px; color: #5e6871; background: #f3f5f6; font-size: 11px; }
.invoice-detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 21px; }
.invoice-detail-actions .wide { grid-column: 1 / -1; }
.danger-btn { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; border: 1px solid #e2aaa4; border-radius: 9px; color: var(--danger); background: #fff; font-weight: 750; }
.danger-btn:hover { border-color: var(--danger); background: var(--danger-pale); }
.invoice-action-panel { grid-column: 1 / -1; padding: 14px; border: 1px solid var(--line); border-radius: 9px; background: #fafbfb; }
.invoice-action-panel h3 { margin: 0 0 5px; font-size: 12px; }
.invoice-action-panel p { margin: 0 0 11px; color: var(--soft); font-size: 10px; }
.invoice-action-panel textarea { width: 100%; min-height: 82px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; resize: vertical; }
.invoice-action-panel textarea:focus { border-color: var(--teal); outline: 3px solid rgba(20, 125, 121, 0.1); }
.invoice-action-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.invoice-action-status { min-height: 18px; margin: 8px 0 0; color: var(--danger); font-size: 10px; }
.invoice-detail-total-row.balance { margin-top: 5px; padding: 13px 0; border-top: 2px solid var(--ink); color: var(--ink); font-size: 14px; font-weight: 800; }
.invoice-detail-total-row.balance.paid { color: var(--teal-dark); }
.invoice-detail-total-row.balance.credit { color: #4d5fa8; }
.invoice-payment-workspace { margin-top: 22px; }
.invoice-document-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px 16px; padding: 14px; border: 1px solid #cfe2df; border-radius: 10px; background: #f2faf8; }
.invoice-document-actions h3, .invoice-payment-head h3 { margin: 0; font-size: 12px; }
.invoice-document-actions p, .invoice-payment-head p { margin: 3px 0 0; color: var(--faint); font-size: 10px; }
.invoice-document-actions > div:last-of-type { display: flex; justify-content: flex-end; gap: 7px; }
.invoice-document-actions .secondary-btn { min-height: 34px; padding-inline: 11px; font-size: 10px; }
.payment-document-status { grid-column: 1 / -1; min-height: 0; color: var(--soft); }
.payment-document-status:not(:empty) { min-height: 16px; margin-top: 3px; }
.invoice-payment-section { margin-top: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
.invoice-payment-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.invoice-payment-head .primary-btn { min-height: 34px; padding-inline: 12px; font-size: 10px; white-space: nowrap; }
.invoice-payment-history { margin-top: 10px; }
.payment-empty { margin: 14px 0 2px; color: var(--faint); font-size: 10px; }
.invoice-payment-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 11px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.invoice-payment-row:first-child { border-top: 0; }
.invoice-payment-row strong, .invoice-payment-row small { display: block; }
.invoice-payment-row strong { font-size: 11px; }
.invoice-payment-row small { margin-top: 2px; color: var(--faint); font-size: 9px; }
.invoice-payment-amount { color: var(--teal-dark); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.payment-edit { padding: 5px 7px; border: 0; border-radius: 6px; color: var(--teal-dark); background: transparent; font-size: 10px; font-weight: 760; }
.payment-edit:hover { background: var(--mint-pale); }
.invoice-payment-form { margin-top: 13px; padding: 13px; border: 1px solid #cfe2df; border-radius: 9px; background: #f7fbfa; }
.invoice-payment-form[aria-busy="true"] { opacity: 0.68; }
.invoice-payment-form-head h4 { margin: 0; font-size: 12px; }
.invoice-payment-form-head p { margin: 3px 0 10px; color: var(--faint); font-size: 10px; }
.invoice-payment-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.invoice-payment-fields label { color: var(--soft); font-size: 10px; font-weight: 720; }
.invoice-payment-fields input { width: 100%; height: 38px; margin-top: 5px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; outline: 0; color: var(--ink); background: #fff; }
.invoice-payment-fields input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(20, 125, 121, 0.09); }
.invoice-payment-money { position: relative; display: block; }
.invoice-payment-money i { position: absolute; z-index: 1; top: 15px; left: 10px; color: var(--faint); font-style: normal; font-weight: 500; }
.invoice-payment-money input { padding-left: 23px; }
.invoice-payment-form-status { min-height: 16px; margin: 8px 0 0; color: var(--danger); font-size: 10px; }
.invoice-payment-form-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 8px; }
.invoice-payment-form-actions button { min-height: 34px; padding-inline: 12px; font-size: 10px; }

.invoice-editor-dialog { position: fixed; z-index: 110; top: 50%; left: 50%; width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 38px); overflow-y: auto; border-radius: 14px; color: var(--ink); background: #fff; box-shadow: 0 30px 80px rgba(8, 18, 29, 0.28); opacity: 0; pointer-events: none; transform: translate(-50%, -48%) scale(0.98); transition: opacity 0.18s, transform 0.18s; }
.invoice-editor-dialog.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
.invoice-editor-head { display: flex; align-items: start; justify-content: space-between; gap: 20px; padding: 23px 25px 18px; border-bottom: 1px solid var(--line-soft); }
.invoice-editor-head h2 { margin: 0; font-size: 20px; letter-spacing: -0.025em; }
.invoice-editor-head p { margin: 4px 0 0; color: var(--faint); font-size: 11px; }
.invoice-editor-form { padding: 20px 25px 24px; }
.invoice-form-status:empty { min-height: 0; margin: 0; }
.invoice-form-status[data-state="error"] { margin-bottom: 13px; }
.invoice-editor-fields { min-width: 0; padding: 0; margin: 0; border: 0; }
.invoice-editor-form[aria-busy="true"] .invoice-editor-fields { opacity: 0.62; }
.invoice-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.invoice-form-grid .field label { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; color: var(--soft); font-size: 11px; font-weight: 720; }
.invoice-form-grid input, .invoice-form-grid select, .invoice-form-grid textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; outline: 0; color: var(--ink); background: #fff; }
.invoice-form-grid input, .invoice-form-grid select { height: 42px; padding: 0 11px; }
.invoice-form-grid textarea { min-height: 82px; padding: 10px 11px; resize: vertical; }
.invoice-form-grid input:focus, .invoice-form-grid select:focus, .invoice-form-grid textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(20, 125, 121, 0.09); }
.invoice-form-grid input[readonly] { color: var(--soft); background: #f5f7f7; }
.invoice-line-editor { grid-column: 1 / -1; min-width: 0; }
.invoice-line-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 9px; }
.invoice-line-head h3 { margin: 0; font-size: 12px; }
.invoice-line-head p { margin: 2px 0 0; color: var(--faint); font-size: 10px; }
.invoice-add-line { display: inline-flex; min-height: 32px; align-items: center; gap: 6px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; font-size: 11px; font-weight: 720; }
.invoice-add-line .icon { width: 14px; height: 14px; }
.invoice-line-grid { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.invoice-line-grid-head, .invoice-line-row { display: grid; min-width: 780px; grid-template-columns: 128px minmax(190px, 1fr) 85px 120px 105px 34px; align-items: center; gap: 9px; }
.invoice-line-grid-head { padding: 9px 11px; color: var(--faint); background: #f7f9f9; font-size: 9px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.invoice-line-grid-head span:nth-child(5) { text-align: right; }
.invoice-line-row { padding: 9px 11px; border-top: 1px solid var(--line-soft); }
.invoice-line-row:first-child { border-top: 0; }
.invoice-line-row input { width: 100%; height: 36px; min-width: 0; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; }
.invoice-line-total { text-align: right; font-size: 11px; font-weight: 760; font-variant-numeric: tabular-nums; }
.invoice-remove-line { display: grid; width: 30px; height: 30px; padding: 0; place-items: center; border: 0; border-radius: 6px; color: var(--faint); background: transparent; }
.invoice-remove-line:hover { color: var(--danger); background: var(--danger-pale); }
.invoice-remove-line .icon { width: 15px; height: 15px; }
.invoice-adjustment-panel { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 20px; padding: 14px; border: 1px solid var(--line-soft); border-radius: 10px; background: #fafbfb; }
.invoice-adjustment-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.invoice-adjustment-group h3 { margin: 0 0 8px; font-size: 11px; }
.invoice-adjustment-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.invoice-adjustment-fields label { color: var(--soft); font-size: 9px; font-weight: 720; }
.invoice-money-input, .invoice-percent-input { position: relative; display: block; margin-top: 4px; }
.invoice-money-input i, .invoice-percent-input i { position: absolute; top: 8px; color: var(--faint); font-style: normal; font-size: 11px; pointer-events: none; }
.invoice-money-input i { left: 10px; }
.invoice-percent-input i { right: 10px; }
.invoice-money-input input { height: 35px; padding-left: 23px; }
.invoice-percent-input input { height: 35px; padding-right: 25px; }
.invoice-preview-totals { display: grid; align-content: end; gap: 6px; }
.invoice-preview-totals > div { display: flex; justify-content: space-between; gap: 20px; color: var(--soft); font-size: 10px; }
.invoice-preview-totals strong { color: var(--ink); font-size: 11px; font-variant-numeric: tabular-nums; }
.invoice-preview-grand { margin-top: 3px; padding-top: 8px; border-top: 1px solid var(--line); font-weight: 780; }
.invoice-preview-grand strong { font-size: 18px; }
.invoice-preview-totals small { margin-top: 4px; color: var(--faint); font-size: 9px; }
.invoice-editor-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 21px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.toast { position: fixed; z-index: 200; right: 22px; bottom: 22px; max-width: min(360px, calc(100vw - 44px)); padding: 13px 16px; border-radius: 10px; color: #fff; background: var(--nav); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(12px); transition: 0.18s; }
.toast.show { opacity: 1; transform: translateY(0); }
.overlay { position: fixed; z-index: 40; inset: 0; background: rgba(8, 18, 29, 0.45); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.overlay.open { opacity: 1; pointer-events: auto; }

/* Generic server gate state */
.standalone-state { display: grid; padding: 24px; place-items: center; background: radial-gradient(circle at 70% 20%, rgba(116, 219, 194, 0.15), transparent 30%), #eef5f5; }
.state-card { width: min(100%, 520px); padding: 42px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.state-card h1 { margin-top: 8px; }
.state-card p:not(.eyebrow) { margin: 12px 0 24px; color: var(--soft); }

@media (max-width: 960px) {
  .access-layout { grid-template-columns: minmax(310px, 0.78fr) minmax(470px, 1.22fr); }
  .access-story { padding: 36px; }
  .story-copy h1 { font-size: 44px; }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-105%); box-shadow: 25px 0 60px rgba(8, 18, 29, 0.25); }
  .sidebar.open { transform: translateX(0); }
  .main-shell { margin-left: 0; }
  .icon-btn.mobile-menu { display: grid; }
  .crumb { display: none; }
  .settings-grid { grid-template-columns: 1fr; }
  .client-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .client-stat:nth-child(2) { border-right: 0; }
  .client-stat:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .clients-panel-head { align-items: start; flex-direction: column; }
  .client-tools { width: 100%; }
  .client-search { flex: 1; }
  .client-search input { width: 100%; }
  .project-tools { flex-wrap: wrap; }
  .project-search { min-width: 240px; }
  .invoice-panel-head { align-items: start; flex-direction: column; }
  .invoice-tools { width: 100%; }
  .invoice-search { flex: 1; }
  .invoice-search input { width: 100%; }
  .invoice-table .invoice-column-due { display: none; }
  .invoice-table td:nth-child(4) { display: none; }
}

@media (max-width: 780px) {
  .access-layout { display: block; }
  .access-story { display: none; }
  .access-shell { min-height: 100vh; padding: 32px 22px 48px; }
  .access-card { max-width: 560px; }
  .mobile-brand { display: inline-flex; margin-bottom: 52px; }
}

@media (max-width: 600px) {
  .empty-grid, .form-grid { grid-template-columns: 1fr; }
  .empty-panel.wide, .field.full { grid-column: auto; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-status { width: 100%; margin-bottom: 4px; }
  .client-page-head { align-items: stretch; flex-direction: column; }
  .client-page-head .primary-btn { width: 100%; }
  .client-stats { grid-template-columns: 1fr; }
  .client-stat { border-right: 0; border-bottom: 1px solid var(--line); }
  .client-stat:last-child { border-bottom: 0; }
  .client-tools { display: grid; grid-template-columns: 1fr; }
  .client-tools select { width: 100%; }
  .client-table { min-width: 520px; }
  .client-column-invoices, .client-column-billed { display: none; }
  .client-table-footer { align-items: stretch; flex-direction: column; }
  .client-pagination { justify-content: space-between; }
  .client-form-grid { grid-template-columns: 1fr; }
  .client-form .field.full { grid-column: auto; }
  .client-form-actions { align-items: stretch; flex-direction: column-reverse; }
  .project-page-head { align-items: stretch; flex-direction: column; }
  .project-page-head .primary-btn { width: 100%; }
  .project-tools { display: grid; grid-template-columns: 1fr; }
  .project-tools select { width: 100%; }
  .project-table { min-width: 520px; }
  .project-column-client, .project-column-schedule, .project-column-active { display: none; }
  .invoice-page-head { align-items: stretch; flex-direction: column; }
  .invoice-page-head .primary-btn { width: 100%; }
  .invoice-tools { display: grid; grid-template-columns: 1fr; }
  .invoice-tools select { width: 100%; }
  .invoice-table { min-width: 560px; }
  .invoice-column-code, .invoice-table td:nth-child(1),
  .invoice-column-issued, .invoice-table td:nth-child(3) { display: none; }
  .invoice-table th:nth-child(2), .invoice-table td:nth-child(2) { padding-left: 18px; }
  .invoice-table-footer { align-items: stretch; flex-direction: column; }
  .invoice-detail-drawer { width: 100vw; }
  .invoice-editor-dialog { inset: 0; width: 100vw; max-height: 100vh; border-radius: 0; transform: translateY(3%); }
  .invoice-editor-dialog.open { transform: none; }
  .invoice-editor-head, .invoice-editor-form { padding-inline: 18px; }
  .invoice-form-grid { grid-template-columns: 1fr; }
  .invoice-form-grid .field.full, .invoice-line-editor, .invoice-adjustment-panel { grid-column: auto; }
  .invoice-adjustment-panel { grid-template-columns: 1fr; }
  .invoice-editor-actions { align-items: stretch; flex-direction: column-reverse; }
  .invoice-party-grid { grid-template-columns: 1fr; }
  .invoice-document-actions { grid-template-columns: 1fr; align-items: stretch; }
  .invoice-document-actions > div:last-of-type { justify-content: stretch; }
  .invoice-document-actions > div:last-of-type button { flex: 1; }
  .payment-document-status { grid-column: auto; }
}

@media (max-width: 520px) {
  .access-shell { align-items: start; padding-inline: 18px; }
  .mobile-brand { margin-bottom: 38px; }
  .welcome h2 { font-size: 28px; }
  .field-row { grid-template-columns: 1fr; gap: 19px; }
  .topbar-user { max-width: 45vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .invoice-adjustment-groups, .invoice-adjustment-fields { grid-template-columns: 1fr; }
  .invoice-detail-actions { grid-template-columns: 1fr; }
  .invoice-detail-actions .wide { grid-column: auto; }
  .invoice-action-buttons { align-items: stretch; flex-direction: column-reverse; }
  .invoice-payment-fields { grid-template-columns: 1fr; }
  .invoice-payment-head { align-items: stretch; flex-direction: column; }
  .invoice-payment-head .primary-btn { width: 100%; }
  .invoice-payment-row { grid-template-columns: minmax(0, 1fr) auto; }
  .invoice-payment-row .payment-edit { grid-column: 1 / -1; justify-self: end; }
  .invoice-payment-form-actions { align-items: stretch; flex-direction: column-reverse; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
  .client-loading-mark::before { animation: none; }
}
