:root {
  --pageGrad: radial-gradient(1200px 700px at 70% -10%, #17103A 0%, #0A0518 42%, #07040F 100%);
  --shellBg: rgba(10,5,24,0.35);
  --panelBg: rgba(12,7,32,0.45);
  --border: rgba(255,255,255,0.07);
  --hair: rgba(255,255,255,0.07);
  --fieldBg: rgba(255,255,255,0.03);
  --fieldBorder: rgba(255,255,255,0.11);
  --text: #F4EFE6;
  --text2: #D8D2E4;
  --text3: #8A82A0;
  --muted: #7E769A;
  --accent: #D4C5A9;
  --accentBorder: rgba(212,197,169,0.14);
  --segOn: rgba(212,197,169,0.10);
  --segActive: rgba(212,197,169,0.16);
  --toggleOff: rgba(255,255,255,0.14);
}
[data-theme="light"] {
  --pageGrad: radial-gradient(1200px 700px at 70% -10%, #FBF7EE 0%, #F6F2EA 45%, #F1EBDD 100%);
  --shellBg: rgba(255,253,248,0.55);
  --panelBg: rgba(246,242,234,0.7);
  --border: rgba(42,32,24,0.10);
  --hair: rgba(42,32,24,0.09);
  --fieldBg: rgba(255,255,255,0.75);
  --fieldBorder: rgba(42,32,24,0.16);
  --text: #2A2018;
  --text2: #463A2C;
  --text3: #8A7E6B;
  --muted: #9A8E7B;
  --accent: #B79A63;
  --accentBorder: rgba(183,154,99,0.30);
  --segOn: rgba(183,154,99,0.14);
  --segActive: rgba(183,154,99,0.22);
  --toggleOff: rgba(42,32,24,0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'Manrope', system-ui, sans-serif; background: #07040F; color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { opacity: .8; }
::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-thumb { background: rgba(128,128,128,0.25); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(128,128,128,0.4); }
input::placeholder, textarea::placeholder { color: #9A8E7B; }
input:focus, textarea:focus, select:focus { outline: none; }
.field:focus, input:focus, textarea:focus, select:focus { border-color: var(--accent) !important; }

.page { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; background: var(--pageGrad); }
.shell {
  width: 100%; max-width: 1180px; height: 100vh; display: flex;
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  background: var(--shellBg); backdrop-filter: blur(2px); overflow: hidden;
}

/* Sidebar */
.sidebar { flex: none; width: 290px; display: flex; flex-direction: column; border-right: 1px solid var(--border); padding: 20px 14px; background: var(--panelBg); }
.wordmark-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px 18px; }
.wordmark-row .mark { font-family: 'Instrument Serif', serif; font-style: italic; font-size: 20px; color: var(--text); }
.search { position: relative; margin-bottom: 22px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text3); }
.search input { width: 100%; height: 42px; padding: 0 14px 0 40px; border-radius: 12px; border: 1px solid var(--fieldBorder); background: var(--fieldBg); color: var(--text); font-family: inherit; font-size: 14.5px; transition: border-color .15s; }
.nav-label { padding: 4px 12px 10px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; cursor: pointer; margin-bottom: 2px; color: var(--text); border: 1px solid transparent; transition: filter .15s; }
.nav-item svg { flex: none; color: var(--accent); }
.nav-item span { font-size: 14.5px; font-weight: 600; }
.nav-item:hover { filter: brightness(1.15); }
.nav-item.active { background: var(--segOn); border-color: var(--accentBorder); }
.spacer { flex: 1; }
.account-chip { display: flex; align-items: center; gap: 11px; padding: 10px 8px; border-top: 1px solid var(--hair); }
.avatar-sm { width: 34px; height: 34px; flex: none; border-radius: 50%; background: rgba(212,197,169,0.16); border: 1px solid rgba(212,197,169,0.35); display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700; color: var(--accent); }
.account-meta { flex: 1; min-width: 0; }
.account-name { font-size: 13.5px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-plan { font-size: 11.5px; color: var(--text3); }

/* Panel */
.panel { flex: 1; min-width: 0; overflow-y: auto; position: relative; }
.close-btn { position: absolute; top: 22px; right: 24px; width: 38px; height: 38px; border: none; background: transparent; color: var(--text2); cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: 11px; z-index: 5; transition: filter .15s; text-decoration: none; }
.close-btn:hover { filter: brightness(1.3); }
.content { max-width: 760px; padding: 46px 56px 80px; }
.content.wide { max-width: 820px; }

h2.serif { font-family: 'Instrument Serif', serif; font-weight: 400; font-size: 30px; color: var(--text); }
h3.sub { font-size: 17px; font-weight: 700; color: var(--text); }

/* Rows */
.row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 22px 0; }
.row.top { border-top: 1px solid var(--hair); }
.row.bottom { border-bottom: 1px solid var(--hair); }
.row.hair { border-bottom: 1px solid var(--hair); }
.row.align-start { align-items: flex-start; }
.row-label { font-size: 15px; font-weight: 600; color: var(--text2); }
.row-strong { font-size: 15px; font-weight: 700; color: var(--text); }

.field { height: 46px; padding: 0 15px; border-radius: 12px; border: 1px solid var(--fieldBorder); background: var(--fieldBg); color: var(--text); font-family: inherit; font-size: 14.5px; transition: border-color .15s; }
input.field { width: 300px; }
.select-wrap { position: relative; width: 220px; flex: none; }
select.field { width: 100%; padding: 0 40px 0 15px; appearance: none; cursor: pointer; }
.select-wrap .caret { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--text3); font-size: 11px; }

.btn { height: 40px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--fieldBorder); background: var(--fieldBg); color: var(--text); font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: filter .15s; }
.btn:hover { filter: brightness(1.15); }
.btn.lg { height: 42px; padding: 0 20px; border-radius: 11px; }
.btn.danger-outline { border-color: rgba(228,98,63,0.4); background: rgba(228,98,63,0.08); color: #E4623F; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.avatar-lg { width: 46px; height: 46px; border-radius: 50%; border: 1px solid rgba(212,197,169,0.35); display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; color: var(--accent); background: rgba(212,197,169,0.14); }
.mono { display: flex; align-items: center; height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--fieldBorder); background: var(--fieldBg); color: var(--text3); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; letter-spacing: 0.02em; word-break: break-all; }

/* segmented (appearance) */
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--fieldBg); border: 1px solid var(--fieldBorder); }
.seg button { width: 44px; height: 36px; border: none; border-radius: 9px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text3); background: transparent; transition: all .15s; }
.seg button:hover { filter: brightness(1.4); }
.seg button.active { color: var(--text); background: var(--segActive); }

/* toggle */
.toggle { width: 48px; height: 28px; flex: none; border: none; border-radius: 20px; cursor: pointer; position: relative; background: var(--toggleOff); transition: background .2s; }
.toggle .knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .2s; box-shadow: 0 1px 3px rgba(0,0,0,0.4); }
.toggle.on { background: var(--accent); }
.toggle.on .knob { left: 23px; background: #1A1030; }

.desc { font-size: 13px; line-height: 1.5; color: var(--text3); max-width: 520px; }
.pref-title { font-size: 15px; font-weight: 600; color: var(--text2); margin-bottom: 5px; }
.para { font-size: 14.5px; line-height: 1.6; color: var(--text3); }

/* collapsible */
.collapse-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 0; border-top: 1px solid var(--hair); cursor: pointer; }
.collapse-head .title { font-size: 15.5px; font-weight: 600; color: var(--text); }
.collapse-head .chev { flex: none; color: var(--text3); font-size: 13px; transition: transform .2s; }
.collapse-head.open .chev { transform: rotate(90deg); }
.collapse-body { padding: 8px 0 8px 20px; display: none; flex-direction: column; gap: 12px; }
.collapse-body.open { display: flex; }
.collapse-body li { font-size: 14px; line-height: 1.55; color: var(--text3); list-style: disc; margin-left: 4px; }

/* table */
.table-head, .table-row { display: grid; gap: 8px 20px; align-items: center; }
.invoices-tbl .table-head, .invoices-tbl .table-row { grid-template-columns: 1.2fr 1fr 1fr; }
.table-head { padding: 14px 0 10px; border-bottom: 1px solid var(--hair); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.table-row { padding: 16px 0; border-bottom: 1px solid var(--hair); }
.cell-muted { font-size: 13.5px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-strong { font-size: 14.5px; color: var(--text); }

/* billing plan */
.plan-head { display: flex; align-items: flex-start; gap: 20px; padding-bottom: 8px; }
.plan-icon { width: 56px; height: 56px; flex: none; border-radius: 14px; border: 1px solid var(--fieldBorder); display: flex; align-items: center; justify-content: center; background: var(--fieldBg); }
.plan-icon svg { color: var(--accent); }
.plan-meta { flex: 1; min-width: 0; }
.plan-name { font-size: 19px; font-weight: 700; color: var(--text); }
.plan-tag { font-size: 14.5px; color: var(--text2); margin: 2px 0 6px; }
.plan-renew { font-size: 13.5px; color: var(--text3); }
.pay-line { display: flex; align-items: center; justify-content: space-between; gap: 24px; }

.mt44 { margin-top: 44px; }
.mb14 { margin-bottom: 14px; }
.mb18 { margin-bottom: 18px; }
.mb22 { margin-bottom: 22px; }
.mb6 { margin-bottom: 6px; }
.instr-block { padding: 26px 0 8px; }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); background: #1A1526; border: 1px solid rgba(255,255,255,0.14); color: var(--text); font-size: 13.5px; font-weight: 600; padding: 11px 18px; border-radius: 12px; box-shadow: 0 20px 50px -20px rgba(0,0,0,0.7); z-index: 80; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

.mobile-header { display: none; }
.tabs { display: none; }

@media (max-width: 860px) {
  .page { align-items: stretch; }
  .shell { border: none; height: 100vh; }
  .sidebar { display: none; }
  .panel { width: 100%; }
  .mobile-header { display: flex; align-items: center; padding: 22px 56px 4px 20px; }
  .mobile-header .sheet-title { font-family: 'Instrument Serif', serif; font-weight: 400; font-size: 26px; color: var(--text); }
  .tabs { display: flex; gap: 8px; padding: 12px 20px 14px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--hair); }
  .tabs::-webkit-scrollbar { height: 0; }
  .tab { flex: none; height: 38px; padding: 0 18px; border: 1px solid var(--fieldBorder); border-radius: 20px; background: var(--fieldBg); color: var(--text3); font-family: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all .15s; }
  .tab.active { background: var(--segActive); border-color: var(--accentBorder); color: var(--text); }
  .close-btn { top: 20px; right: 16px; }
  .content, .content.wide { max-width: 100%; padding: 20px 20px 80px; }
  input.field { width: 100%; }
  .select-wrap { width: 100%; }
}
