:root {
  --navy: #071a33;
  --navy-2: #0c274a;
  --blue: #0d6efd;
  --blue-soft: #eaf3ff;
  --gold: #f2b84b;
  --ink: #16233a;
  --muted: #6d7a8d;
  --line: #dfe6ef;
  --paper: #ffffff;
  --bg: #f2f5f9;
  --green: #16825d;
  --red: #c43f4d;
  --shadow: 0 16px 40px rgba(13, 31, 58, .12);
}
* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.eyebrow { margin: 0 0 5px; font-size: 10px; font-weight: 800; letter-spacing: .15em; color: #77869a; }
.eyebrow.pale { color: #93acd0; }
.brand-mark { display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 13px; background: linear-gradient(145deg, var(--gold), #d99524); color: var(--navy); font-weight: 900; font-size: 25px; box-shadow: 0 8px 22px rgba(242,184,75,.24); }
.brand-lockup { display: flex; align-items: center; gap: 14px; }
.brand-lockup h1 { margin: 0; font-size: 25px; }
.brand-lockup.compact { color: #fff; }
.brand-lockup.compact .brand-mark { width: 38px; height: 38px; font-size: 21px; border-radius: 10px; }
.brand-lockup.compact .eyebrow { color: #8099bb; margin: 0; }
.brand-lockup.compact strong { font-size: 14px; }
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 520px) 1fr; background: #fff; }
.login-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(36px, 7vw, 94px); }
.login-panel > .muted { line-height: 1.6; margin: 24px 0; }
.login-visual { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; padding: clamp(50px, 9vw, 130px); color: #dbe8fa; background: radial-gradient(circle at 70% 20%, #144d83 0, #0b2a50 38%, #06172d 78%); }
.login-visual::before, .login-visual::after { content: ""; position: absolute; border: 1px solid rgba(145,190,240,.13); border-radius: 50%; }
.login-visual::before { width: 600px; height: 600px; right: -200px; top: -220px; }
.login-visual::after { width: 400px; height: 400px; right: -110px; top: -120px; }
.login-visual h2 { position: relative; margin: 12px 0 20px; color: #fff; font-size: clamp(38px, 5vw, 72px); line-height: 1.02; letter-spacing: -.05em; }
.login-visual p { position: relative; max-width: 570px; line-height: 1.7; }
.signal { position: absolute; width: 180px; height: 180px; right: 12%; bottom: 12%; border-radius: 50%; background: radial-gradient(circle, rgba(242,184,75,.55) 0 3%, transparent 4% 19%, rgba(242,184,75,.25) 20% 21%, transparent 22% 42%, rgba(242,184,75,.14) 43% 44%, transparent 45%); }
.stack { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: #3d4a5e; font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 43px; border: 1px solid #ccd7e4; border-radius: 9px; padding: 10px 12px; color: var(--ink); background: #fff; outline: none; transition: .15s; }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #4f93e9; box-shadow: 0 0 0 3px rgba(13,110,253,.1); }
.button { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 9px 15px; border: 1px solid transparent; border-radius: 9px; font-weight: 750; font-size: 13px; pointer-events: auto; }
.button.primary { background: var(--blue); color: #fff; box-shadow: 0 8px 18px rgba(13,110,253,.19); }
.button.secondary { background: var(--navy); color: #fff; }
.button.ghost { border-color: var(--line); color: #40516a; background: #fff; }
.button.danger { background: #fff0f1; color: var(--red); border-color: #f5cdd2; }
.button.wide { width: 100%; }
.button:disabled { opacity: .55; cursor: wait; pointer-events: none; }
.text-button { padding: 4px; border: 0; color: #a9bad0; background: none; }
.secure-note { margin-top: 24px; color: #8290a2; font-size: 11px; }
.notice { margin: 15px 0; padding: 12px 14px; border-radius: 9px; font-size: 13px; line-height: 1.5; }
.notice.danger { color: #8d2330; background: #fff0f2; border: 1px solid #f4c9cf; }
.notice.success { color: #116044; background: #ecf9f4; border: 1px solid #bce8d6; }
.notice.info { color: #24527f; background: #edf5ff; border: 1px solid #c7ddf7; }
.modal-status { margin: -7px 0 17px; }
.install-page { display: grid; min-height: 100vh; place-items: center; padding: 25px; background: radial-gradient(circle at 30% 0%, #174775, var(--navy) 55%); }
.install-card { width: min(700px, 100%); padding: clamp(28px, 5vw, 55px); background: #fff; border-radius: 20px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.install-card h1 { margin: 8px 0; }
.install-card > .brand-mark { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 25px; }
.span-2 { grid-column: 1 / -1; }
.divider { display: flex; align-items: center; gap: 12px; color: #8290a2; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px 1fr; }
.sidebar { position: fixed; z-index: 30; inset: 0 auto 0 0; width: 238px; display: flex; flex-direction: column; padding: 22px 14px; background: linear-gradient(180deg, var(--navy), #051426); box-shadow: 7px 0 24px rgba(6,24,47,.12); }
.sidebar .brand-lockup { padding: 0 8px 23px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar nav { display: grid; gap: 5px; margin-top: 23px; }
.sidebar nav button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 13px; border: 0; border-radius: 8px; color: #a9bad0; background: transparent; text-align: left; font-weight: 650; font-size: 13px; }
.sidebar nav button span { width: 20px; color: #7792b5; text-align: center; }
.sidebar nav button:hover, .sidebar nav button.active { color: #fff; background: rgba(255,255,255,.09); }
.sidebar nav button.active span { color: var(--gold); }
.sidebar-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding: 14px 8px 2px; border-top: 1px solid rgba(255,255,255,.08); }
.sync-badge { display: flex; align-items: center; gap: 7px; color: #a9bad0; font-size: 11px; font-weight: 700; }
.sync-badge i { width: 8px; height: 8px; border-radius: 50%; background: #36ca8c; box-shadow: 0 0 0 4px rgba(54,202,140,.1); }
.sync-badge.offline i { background: #e09a38; }
.sync-badge.error i { background: #e25766; }
.build-tag { display: block; margin: 5px 0 0 15px; color: #6f86a5; font-size: 9px; font-weight: 800; letter-spacing: .08em; }
.main { grid-column: 2; min-width: 0; }
.topbar { position: sticky; z-index: 20; top: 0; display: flex; justify-content: space-between; align-items: center; min-height: 82px; padding: 14px clamp(18px, 3vw, 40px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); backdrop-filter: blur(10px); }
.topbar h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding-left: 13px; border-left: 1px solid var(--line); }
.user-chip > span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; background: var(--navy-2); font-weight: 800; }
.user-chip div { display: grid; }
.user-chip strong { font-size: 12px; }
.user-chip small { color: var(--muted); font-size: 10px; text-transform: capitalize; }
.content { padding: clamp(18px, 3vw, 38px); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar-group { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; min-height: 40px; }
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card { position: relative; overflow: hidden; min-height: 132px; padding: 20px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); box-shadow: 0 5px 18px rgba(13,31,58,.04); }
.stat-card::after { content: ""; position: absolute; width: 70px; height: 70px; right: -22px; top: -22px; border-radius: 50%; background: var(--blue-soft); }
.stat-card .label { color: var(--muted); font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.stat-card .value { margin-top: 17px; font-size: 28px; font-weight: 850; letter-spacing: -.04em; color: var(--navy); }
.stat-card .hint { color: #95a1b0; font-size: 11px; margin-top: 3px; }
.panel { overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: #fff; box-shadow: 0 5px 18px rgba(13,31,58,.04); }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 17px 19px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 14px; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 11px 13px; color: #65758b; background: #f7f9fc; text-align: left; font-size: 10px; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
td { padding: 12px 13px; border-top: 1px solid #edf1f6; vertical-align: middle; }
tbody tr:hover { background: #fbfcfe; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; color: #174e8b; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 20px; color: #315b88; background: var(--blue-soft); font-weight: 700; font-size: 10px; }
.badge.green { color: #116044; background: #e8f7f1; }
.balance.positive { color: var(--red); font-weight: 800; }
.balance.negative { color: var(--green); font-weight: 800; }
.row-actions { display: flex; gap: 5px; justify-content: flex-end; }
.row-actions button { border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; color: #506078; background: #fff; font-size: 10px; }
.row-actions button:hover { color: var(--blue); border-color: #adcaec; }
.table-link { display: inline; padding: 0; border: 0; color: var(--navy); background: transparent; font-weight: 800; text-align: left; }
.table-link:hover { color: var(--blue); text-decoration: underline; }
.empty { padding: 50px 20px; color: #7d8998; text-align: center; }
.empty strong { display: block; margin-bottom: 6px; color: #45556b; }
.modal { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; overflow: auto; overscroll-behavior: contain; padding: 18px; background: rgba(4,16,31,.65); }
.modal-card { position: relative; isolation: isolate; width: min(830px, 100%); max-height: calc(100vh - 36px); max-height: calc(100dvh - 36px); overflow: auto; overscroll-behavior: contain; padding: 22px; border-radius: 15px; background: #fff; box-shadow: 0 30px 80px rgba(0,0,0,.32); }
.modal-card.wide { width: min(1180px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 22px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 20px; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border: 1px solid var(--line); border-radius: 8px; color: #506078; background: #fff; }
.modal .form-grid { margin-top: 0; }
.form-actions { position: relative; z-index: 5; display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; padding-top: 17px; border-top: 1px solid var(--line); background: #fff; pointer-events: auto; }
.form-actions .button { min-width: 118px; }
.toast { position: fixed; z-index: 150; right: 22px; bottom: 22px; max-width: 370px; padding: 13px 17px; border-radius: 9px; color: #fff; background: #173b64; box-shadow: var(--shadow); font-size: 13px; }
.toast.danger { background: #9d2e3a; }
.manifest-builder { display: grid; gap: 16px; }
.manifest-grid td input { min-width: 90px; min-height: 35px; padding: 6px 8px; font-size: 11px; }
.manifest-grid td input.wide { min-width: 150px; }
.totals-bar { display: flex; justify-content: flex-end; gap: 24px; padding: 13px 16px; color: #4e6078; background: #f7f9fc; font-size: 12px; }
.totals-bar strong { color: var(--navy); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(260px, .7fr); gap: 18px; }
.admin-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.action-card { padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.action-card h3 { margin: 0 0 7px; font-size: 14px; }
.action-card p { min-height: 38px; margin: 0 0 15px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.loading { min-height: 260px; display: grid; place-items: center; color: #7a8798; }
.loading::before { content: ""; width: 26px; height: 26px; border: 3px solid #dce7f3; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.mobile-only { display: none; }
.print-head { display: none; }
.vendor-profile { display: grid; gap: 18px; }
.profile-hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px; border-radius: 13px; color: #dceaff; background: linear-gradient(135deg, var(--navy), var(--navy-2)); }
.profile-hero h3 { margin: 2px 0 6px; color: #fff; font-size: 24px; }
.profile-balance { display: grid; gap: 6px; min-width: 165px; text-align: right; }
.profile-balance span { color: #9fb7d8; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.profile-balance strong { color: #fff; font-size: 22px; }
.profile-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.profile-metrics > div, .profile-details > div { display: grid; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #f9fbfd; }
.profile-metrics span, .profile-details span { color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.profile-metrics strong { font-size: 15px; }
.profile-details { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.profile-details strong { overflow-wrap: anywhere; font-size: 12px; }
.profile-actions { flex-wrap: wrap; margin-top: 0; }

@media (max-width: 1050px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { padding: 34px 24px; }
  .app-shell { display: block; }
  .main { margin-left: 0; }
  .sidebar { transform: translateX(-102%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: grid; }
  .topbar { min-height: 72px; padding: 12px 15px; }
  .topbar > div:first-of-type { margin-right: auto; margin-left: 10px; }
  .topbar-actions .button { display: none; }
  .user-chip div { display: none; }
  .content { padding: 15px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { min-height: 112px; padding: 15px; }
  .stat-card .value { font-size: 22px; }
  .toolbar { align-items: stretch; }
  .toolbar-group { width: 100%; }
  .toolbar input, .toolbar select { flex: 1; min-width: 125px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .admin-actions { grid-template-columns: 1fr; }
  .modal { place-items: end center; padding: 0; }
  .modal-card { width: 100%; max-height: 96vh; max-height: 96dvh; padding: 18px 16px 0; border-radius: 18px 18px 0 0; }
  .modal-head { position: sticky; z-index: 8; top: -18px; margin: 0 -16px 18px; padding: 18px 16px 14px; background: #fff; }
  .form-actions { position: sticky; bottom: 0; margin-right: -16px; margin-left: -16px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 22px rgba(13,31,58,.08); }
  .form-actions .button { flex: 1; min-height: 48px; min-width: 0; }
  .profile-hero { align-items: flex-start; flex-direction: column; }
  .profile-balance { min-width: 0; text-align: left; }
  .profile-metrics { grid-template-columns: 1fr 1fr; }
  .profile-details { grid-template-columns: 1fr; }
  .profile-actions { position: static; margin-right: 0; margin-left: 0; padding-right: 0; padding-left: 0; box-shadow: none; }
}
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .toolbar, .row-actions, .button, .modal-head .icon-button { display: none !important; }
  .main { margin: 0; }
  .content, .modal, .modal-card { position: static; display: block !important; max-height: none; width: 100%; padding: 0; background: #fff; box-shadow: none; }
  .modal-card > * { display: none; }
  .modal-card .printable { display: block !important; }
  .print-head { display: block; margin-bottom: 24px; text-align: center; }
  .print-head h1 { margin: 3px 0; }
  table { font-size: 10px; }
  th, td { padding: 7px; }
}
