/* Material / Cloudreve v4 inspired theme. CSP forbids inline styles and external assets,
   so everything lives here and icons are inline SVG injected by app.js. */
:root {
  --primary: #1976d2;
  --primary-dark: #1565c0;
  --primary-tint: rgba(25, 118, 210, .12);
  --primary-hover: rgba(25, 118, 210, .04);
  --primary-select: rgba(25, 118, 210, .08);
  --success: #2e7d32; --success-bg: #edf7ed;
  --warning: #ed6c02; --warning-text: #663c00; --warning-bg: #fff4e5;
  --error: #d32f2f; --error-text: #5f2120; --error-bg: #fdeded;
  --info-text: #014361; --info-bg: #e5f6fd;
  --bg: #f5f7fa;
  --paper: #fff;
  --text: rgba(0, 0, 0, .87);
  --text-2: rgba(0, 0, 0, .6);
  --text-3: rgba(0, 0, 0, .38);
  --divider: rgba(0, 0, 0, .12);
  --line: rgba(224, 224, 224, 1);
  --hover: rgba(0, 0, 0, .04);
  --outline: rgba(0, 0, 0, .23);
  --fill: rgba(0, 0, 0, .06);
  --chip: rgba(0, 0, 0, .08);
  --scrim: rgba(0, 0, 0, .5);
  --snack: #323232;
  --shadow-1: 0 2px 1px -1px rgba(0,0,0,.2), 0 1px 1px 0 rgba(0,0,0,.14), 0 1px 3px 0 rgba(0,0,0,.12);
  --shadow-8: 0 5px 5px -3px rgba(0,0,0,.2), 0 8px 10px 1px rgba(0,0,0,.14), 0 3px 14px 2px rgba(0,0,0,.12);
  --shadow-24: 0 11px 15px -7px rgba(0,0,0,.2), 0 24px 38px 3px rgba(0,0,0,.14), 0 9px 46px 8px rgba(0,0,0,.12);
  --radius: 12px;
  --drawer: 240px;
  --appbar: 64px;
  color-scheme: light;
  font-family: Roboto, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  :root {
    --primary: #90caf9; --primary-dark: #64b5f6;
    --primary-tint: rgba(144, 202, 249, .16); --primary-hover: rgba(144, 202, 249, .08); --primary-select: rgba(144, 202, 249, .12);
    --success: #66bb6a; --success-bg: #0c130d;
    --warning: #ffa726; --warning-text: #ffe2b7; --warning-bg: #191207;
    --error: #f44336; --error-text: #f4c7c7; --error-bg: #160b0b;
    --info-text: #b8e7fb; --info-bg: #071318;
    --bg: #121212; --paper: #1e1e1e;
    --text: #fff; --text-2: rgba(255,255,255,.7); --text-3: rgba(255,255,255,.5);
    --divider: rgba(255,255,255,.12); --line: rgba(81,81,81,1); --hover: rgba(255,255,255,.08);
    --outline: rgba(255,255,255,.23); --fill: rgba(255,255,255,.09); --chip: rgba(255,255,255,.16);
    --snack: #e0e0e0;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; font-size: 12.5px; }
code { background: var(--fill); padding: 2px 6px; border-radius: 6px; }
h1, h2, h3 { font-weight: 500; margin: 0; }
.secondary-text { color: var(--text-2); }
.caption { color: var(--text-2); font-size: 12px; line-height: 1.66; margin: 0; }
.divider { height: 1px; background: var(--divider); margin: 8px 0; flex: none; }
.paper { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.icon { width: 24px; height: 24px; fill: currentColor; flex: none; display: block; }
[data-icon] { display: inline-flex; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 64px; padding: 6px 12px; border: 0; border-radius: var(--radius);
  background: transparent; color: var(--primary); font-size: 14px; font-weight: 500; line-height: 1.75;
  white-space: nowrap; transition: background-color .25s, box-shadow .25s, border-color .25s; position: relative;
}
.btn .icon { width: 20px; height: 20px; margin-left: -4px; }
.btn:hover { background: var(--primary-hover); }
.btn.contained { background: var(--primary); color: #fff; padding: 6px 16px; }
.btn.contained:hover { background: var(--primary-dark); }
.btn.outlined { border: 1px solid color-mix(in srgb, var(--primary) 50%, transparent); padding: 5px 15px; }
.btn.outlined:hover { border-color: var(--primary); }
.btn.danger { color: var(--error); }
.btn.danger:hover { background: color-mix(in srgb, var(--error) 6%, transparent); }
.btn.small { padding: 4px 8px; font-size: 13px; min-width: 0; }
.btn.block { width: 100%; padding: 8px 22px; font-size: 15px; }
.btn:disabled, .icon-btn:disabled { color: var(--text-3); cursor: default; pointer-events: none; }
.btn.contained:disabled { background: var(--divider); }
.btn.outlined:disabled { border-color: var(--divider); }
@media (prefers-color-scheme: dark) { .btn.contained { color: rgba(0,0,0,.87); } }
.icon-btn {
  width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; background: transparent;
  display: inline-grid; place-items: center; color: var(--text-2); transition: background-color .15s;
}
.icon-btn:hover { background: var(--hover); }
.icon-btn.small { width: 34px; height: 34px; }
.icon-btn.small .icon { width: 20px; height: 20px; }
.spin .icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn:focus-visible, .icon-btn:focus-visible, .nav-item:focus-visible, .menu-item:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* App frame */
.shell { min-height: 100vh; }
.appbar {
  position: fixed; inset: 0 0 auto 0; height: var(--appbar); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 0 16px 0 24px; background: var(--bg);
}
.appbar-brand, .login-brand { display: flex; align-items: center; gap: 10px; width: calc(var(--drawer) - 36px); flex: none; }
.appbar-brand strong, .login-brand strong { font-size: 19px; font-weight: 500; letter-spacing: .01em; }
.logo { width: 32px; height: 32px; border-radius: 10px; background: linear-gradient(135deg, #42a5f5, #1565c0); color: #fff; display: grid; place-items: center; }
.logo .icon { width: 20px; height: 20px; }
.menu-toggle { display: none; margin-left: -8px; }
.search {
  flex: 0 1 640px; min-width: 0; height: 46px; border-radius: 99px; background: var(--fill);
  display: flex; align-items: center; gap: 10px; padding: 0 18px; color: var(--text-2); transition: background-color .2s, box-shadow .2s;
}
.search:focus-within { background: var(--paper); box-shadow: var(--shadow-1); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 15px; color: var(--text); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search.disabled { opacity: .5; pointer-events: none; }
.appbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.avatar-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; margin-left: 4px;
  background: var(--primary); color: #fff; font-weight: 500; font-size: 15px;
}
@media (prefers-color-scheme: dark) { .avatar-btn { color: rgba(0,0,0,.87); } }
.menu-anchor { position: relative; }
.menu { position: absolute; right: 0; top: 46px; min-width: 200px; padding: 8px 0; box-shadow: var(--shadow-8); z-index: 40; }
.menu-head { padding: 8px 16px; display: grid; gap: 2px; }
.menu-item { width: 100%; display: flex; align-items: center; gap: 16px; padding: 8px 16px; border: 0; background: transparent; text-align: left; font-size: 15px; }
.menu-item:hover { background: var(--hover); }
.menu-item .icon { color: var(--text-2); width: 20px; height: 20px; }

.drawer {
  position: fixed; top: var(--appbar); bottom: 0; left: 0; width: var(--drawer); z-index: 25;
  padding: 8px 8px 16px; display: flex; flex-direction: column; overflow-y: auto; background: var(--bg);
}
.drawer nav { display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 20px; height: 44px; padding: 0 16px 0 18px; border: 0;
  border-radius: 99px; background: transparent; color: var(--text); text-align: left; font-size: 14.5px; font-weight: 500;
}
.nav-item .icon { color: var(--text-2); width: 22px; height: 22px; }
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--primary-tint); color: var(--primary); }
.nav-item.active .icon { color: var(--primary); }
.drawer .divider { margin: 8px 12px; }
.drawer-footer { margin-top: auto; padding: 12px 18px 0; display: grid; gap: 6px; }
.drawer-footer .meter-label { display: flex; justify-content: space-between; color: var(--text-2); font-size: 12px; }

.content {
  margin: var(--appbar) 16px 16px var(--drawer); min-height: calc(100vh - var(--appbar) - 16px);
  background: var(--paper); border-radius: var(--radius); position: relative; overflow: hidden;
}
#page { padding: 20px 24px 32px; }
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 24; }

/* Linear progress */
.progress { position: absolute; inset: 0 0 auto 0; height: 4px; overflow: hidden; background: var(--primary-tint); z-index: 2; }
.progress::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 40%; background: var(--primary); animation: indeterminate 1.4s cubic-bezier(.65,.815,.735,.395) infinite; }
@keyframes indeterminate { from { left: -40%; } to { left: 100%; } }
progress.meter { appearance: none; -webkit-appearance: none; width: 100%; height: 6px; border: 0; border-radius: 99px; background: var(--primary-tint); overflow: hidden; }
progress.meter::-webkit-progress-bar { background: var(--primary-tint); border-radius: 99px; }
progress.meter::-webkit-progress-value { background: var(--primary); border-radius: 99px; }
progress.meter::-moz-progress-bar { background: var(--primary); border-radius: 99px; }

/* Page structure */
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-height: 48px; margin-bottom: 16px; }
.page-head h1 { font-size: 22px; line-height: 1.3; }
.page-head .caption { width: 100%; margin-top: -8px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.section { margin-top: 24px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.section-title h2 { font-size: 16px; }
.card { background: var(--paper); border: 1px solid var(--divider); border-radius: var(--radius); }
.card-pad { padding: 16px 20px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { display: flex; gap: 16px; align-items: center; padding: 18px 20px; }
.stat-avatar { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--primary-tint); color: var(--primary); }
.stat-avatar.green { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.stat-avatar.orange { background: color-mix(in srgb, var(--warning) 14%, transparent); color: var(--warning); }
.stat-avatar.red { background: color-mix(in srgb, var(--error) 12%, transparent); color: var(--error); }
.stat strong { display: block; font-size: 26px; font-weight: 500; line-height: 1.2; }
.stat .caption { line-height: 1.4; }
.stat .label { color: var(--text-2); font-size: 13px; }

.list { list-style: none; margin: 0; padding: 4px 0; }
.list-item { display: flex; align-items: center; gap: 16px; padding: 10px 16px; min-height: 56px; }
.list-item.clickable { cursor: pointer; border-radius: 8px; }
.list-item.clickable:hover { background: var(--hover); }
.list-item .list-icon { color: var(--text-2); }
.list-item .list-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.list-item .list-text > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.steps { margin: 0; padding: 0 0 0 20px; display: grid; gap: 8px; color: var(--text-2); line-height: 1.6; }

/* Alerts */
.alert { display: flex; gap: 12px; padding: 8px 16px; border-radius: var(--radius); font-size: 14px; line-height: 1.6; margin-bottom: 16px; background: var(--info-bg); color: var(--info-text); }
.alert .icon { width: 22px; height: 22px; margin-top: 7px; color: #0288d1; }
.alert > div { padding: 6px 0; }
.alert.warning { background: var(--warning-bg); color: var(--warning-text); }
.alert.warning .icon { color: var(--warning); }
.alert.error { background: var(--error-bg); color: var(--error-text); }
.alert.error .icon { color: var(--error); }
.alert.success { background: var(--success-bg); color: var(--success); }

/* Chips */
.chip { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 16px; font-size: 12.5px; white-space: nowrap; background: var(--chip); color: var(--text); vertical-align: middle; }
.chip + .chip { margin-left: 4px; }
.chip.green { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }
.chip.orange { background: color-mix(in srgb, var(--warning) 16%, transparent); color: var(--warning); }
.chip.red { background: color-mix(in srgb, var(--error) 13%, transparent); color: var(--error); }
.chip.blue { background: var(--primary-tint); color: var(--primary); }
.chip.outlined { background: transparent; border: 1px solid var(--outline); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-row .chip + .chip { margin: 0; }
.chip.filter { cursor: pointer; height: 32px; padding: 0 12px; font-size: 13.5px; border: 1px solid var(--outline); background: transparent; }
.chip.filter:hover { background: var(--hover); }
.chip.filter.selected { background: var(--primary-tint); border-color: transparent; color: var(--primary); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--divider); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th { text-align: left; font-weight: 500; font-size: 13.5px; color: var(--text); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--paper); }
td { padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; line-height: 1.5; }
tbody tr { transition: background-color .15s; }
tbody tr:hover { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.selected { background: var(--primary-select); }
tbody tr.clickable { cursor: pointer; }
td .sub { display: block; color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
td .sub.error { color: var(--error); }
td.check, th.check { width: 52px; padding: 0 0 0 6px; }
td.actions { white-space: nowrap; text-align: right; }
.name-cell { display: flex; align-items: center; gap: 14px; min-width: 0; }
.name-cell > .icon { color: var(--text-2); }
.name-cell strong { font-weight: 500; }
.domain-list { display: grid; gap: 2px; }
.ip { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; color: var(--text-2); }
.arrow { color: var(--text-3); margin: 0 6px; }
.empty { padding: 56px 16px; text-align: center; color: var(--text-2); display: grid; justify-items: center; gap: 12px; }
.empty .icon { width: 64px; height: 64px; color: var(--text-3); }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.selection-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 52px; padding: 6px 8px 6px 16px; margin-bottom: 12px;
  border-radius: var(--radius); background: var(--primary-tint); color: var(--primary); font-weight: 500;
}
.selection-bar .grow { flex: 1; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 4px; padding: 8px 4px 0; color: var(--text-2); font-size: 13.5px; }
.pagination .range { margin: 0 12px; }

/* Checkbox & switch */
.checkbox-wrap { width: 42px; height: 42px; display: inline-grid; place-items: center; border-radius: 50%; cursor: pointer; }
.checkbox-wrap:hover { background: var(--primary-hover); }
input[type="checkbox"].cb {
  appearance: none; -webkit-appearance: none; width: 18px; height: 18px; margin: 0; border: 2px solid var(--text-2); border-radius: 3px;
  display: grid; place-items: center; cursor: pointer; background: transparent; transition: background-color .15s, border-color .15s;
}
input[type="checkbox"].cb:checked, input[type="checkbox"].cb:indeterminate { background: var(--primary); border-color: var(--primary); }
input[type="checkbox"].cb:checked::after { content: ""; width: 10px; height: 5px; border: solid #fff; border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
input[type="checkbox"].cb:indeterminate::after { content: ""; width: 10px; height: 2px; background: #fff; }
input[type="checkbox"].cb:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.check-label { display: flex; align-items: center; gap: 2px; margin-left: -11px; cursor: pointer; }
.switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 34px; height: 14px; border-radius: 7px; background: var(--text-3); flex: none; margin: 0 8px; transition: background-color .15s; }
.switch .track::after { content: ""; position: absolute; top: -3px; left: -3px; width: 20px; height: 20px; border-radius: 50%; background: #fafafa; box-shadow: 0 2px 1px -1px rgba(0,0,0,.2), 0 1px 1px rgba(0,0,0,.14), 0 1px 3px rgba(0,0,0,.12); transition: transform .15s, background-color .15s; }
.switch input:checked + .track { background: color-mix(in srgb, var(--primary) 50%, transparent); }
.switch input:checked + .track::after { transform: translateX(20px); background: var(--primary); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 6px; }
.switch input:disabled + .track { opacity: .4; }
.switch-text { display: grid; gap: 2px; }

/* Outlined text field (MUI style floating label) */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.field { min-width: 0; }
.field .box { position: relative; }
.switch.wide { grid-column: 1 / -1; }
.nowrap { white-space: nowrap; }
.plain-select { border: 0; background: transparent; color: inherit; padding: 4px; font-size: 13.5px; cursor: pointer; border-radius: 6px; }
.plain-select:hover { background: var(--hover); }
.field input, .field select {
  display: block; width: 100%; height: 56px; padding: 16.5px 14px; border: 0; outline: 0; background: transparent;
  font-size: 15px; color: var(--text); position: relative; z-index: 1;
}
.field select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer; }
.field select option { color: #000; }
.field.select .box::after { content: ""; position: absolute; right: 16px; top: 25px; border: 5px solid transparent; border-top-color: var(--text-2); pointer-events: none; }
.field label { position: absolute; left: 14px; top: 17px; max-width: calc(100% - 28px); color: var(--text-2); font-size: 15px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transform-origin: left top; transition: transform .2s cubic-bezier(0,0,.2,1), color .2s; pointer-events: none; z-index: 2; }
.field fieldset { position: absolute; inset: -5px 0 0 0; margin: 0; padding: 0 8px; border: 1px solid var(--outline); border-radius: var(--radius); pointer-events: none; transition: border-color .15s; min-width: 0; }
.field legend { visibility: hidden; max-width: .01px; height: 11px; padding: 0; font-size: 11.25px; white-space: nowrap; transition: max-width 50ms cubic-bezier(0,0,.2,1); }
.field legend span { display: inline-block; padding: 0 5px; }
.field:hover fieldset { border-color: var(--text); }
.field input:focus ~ fieldset, .field select:focus ~ fieldset { border: 2px solid var(--primary); }
.field input:focus ~ label, .field select:focus ~ label { color: var(--primary); }
.field input:focus ~ label, .field input:not(:placeholder-shown) ~ label, .field select ~ label, .field input[type="date"] ~ label { transform: translate(0, -26px) scale(.75); max-width: calc(133% - 32px); }
.field input:focus ~ fieldset legend, .field input:not(:placeholder-shown) ~ fieldset legend, .field select ~ fieldset legend { max-width: 100%; transition: max-width 100ms cubic-bezier(0,0,.2,1) 50ms; }
.field .helper { margin: 4px 14px 0; color: var(--text-2); font-size: 12px; line-height: 1.66; }
.field.sm input, .field.sm select { height: 40px; padding: 8.5px 14px; font-size: 14px; }
.field.sm label { top: 10px; font-size: 14px; }
.field.sm input:focus ~ label, .field.sm input:not(:placeholder-shown) ~ label, .field.sm select ~ label { transform: translate(0, -19px) scale(.75); }
.field.sm.select .box::after { top: 18px; }
.field.sm { min-width: 180px; }

/* Settings */
.settings-section { padding: 20px 0 28px; border-bottom: 1px solid var(--divider); display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; }
.settings-section:last-of-type { border-bottom: 0; }
.settings-section > header h2 { font-size: 16px; margin-bottom: 6px; }
.settings-section .form-grid { max-width: 760px; }
.status-line { display: flex; align-items: center; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.sticky-actions { position: sticky; bottom: 0; display: flex; gap: 8px; justify-content: flex-end; padding: 12px 0; background: var(--paper); border-top: 1px solid var(--divider); }

/* Dialog */
dialog {
  width: calc(100% - 64px); max-width: 600px; max-height: calc(100% - 64px); padding: 0; border: 0; border-radius: var(--radius);
  background: var(--paper); color: var(--text); box-shadow: var(--shadow-24); overflow: hidden;
}
dialog.wide { max-width: 960px; }
dialog[open] { display: flex; flex-direction: column; animation: dialog-in .2s cubic-bezier(0,0,.2,1); }
dialog::backdrop { background: var(--scrim); }
@keyframes dialog-in { from { opacity: 0; transform: scale(.96); } }
.dialog-title { display: flex; align-items: center; gap: 8px; padding: 16px 12px 8px 24px; }
.dialog-title h2 { flex: 1; font-size: 20px; line-height: 1.6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog-content { padding: 8px 24px 0; overflow-y: auto; line-height: 1.6; }
.dialog-content > form { display: contents; }
.dialog-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 12px 0 16px; margin-top: 16px; background: var(--paper); }
.dialog-content .table-wrap table { min-width: 640px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; color: var(--text-2); font-size: 13px; margin-bottom: 12px; }
.kv b { font-weight: 500; color: var(--text); word-break: break-all; }

/* Snackbar */
#snackbar {
  position: fixed; left: 24px; bottom: 24px; z-index: 100; min-width: 288px; max-width: min(560px, calc(100vw - 48px));
  display: flex; align-items: center; gap: 12px; padding: 6px 16px; min-height: 48px; border-radius: var(--radius);
  background: var(--snack); color: #fff; box-shadow: var(--shadow-8); font-size: 14px; line-height: 1.5;
  opacity: 0; transform: translateY(16px) scale(.96); pointer-events: none; transition: opacity .2s, transform .2s;
}
@media (prefers-color-scheme: dark) { #snackbar { color: rgba(0,0,0,.87); } }
#snackbar.show { opacity: 1; transform: none; pointer-events: auto; }
#snackbar.success { background: var(--success); color: #fff; }
#snackbar.error { background: var(--error); color: #fff; }
#snackbar .icon { width: 22px; height: 22px; }

/* Login */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-card { width: min(420px, 100%); padding: 32px 32px 24px; display: grid; gap: 16px; }
.login-card h1 { font-size: 22px; margin-top: 16px; }
.login-card .secondary-text { margin: -10px 0 8px; }
.login-card .caption { text-align: center; }

/* Responsive */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .settings-section { grid-template-columns: 1fr; gap: 12px; }
}
@media (max-width: 900px) {
  .menu-toggle { display: inline-grid; }
  .appbar { padding: 0 8px 0 16px; }
  .appbar-brand { width: auto; }
  .drawer { transform: translateX(-100%); transition: transform .225s cubic-bezier(0,0,.2,1); background: var(--paper); top: 0; padding-top: 16px; box-shadow: var(--shadow-24); z-index: 35; }
  .drawer.open { transform: none; }
  .content { margin: var(--appbar) 8px 8px 8px; }
  #page { padding: 16px; }
}
@media (max-width: 640px) {
  .appbar-brand { display: none; }
  .appbar { gap: 4px; }
  .search { flex: 1 1 auto; padding: 0 14px; }
  .stats { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .page-head .actions { margin-left: 0; }
  #snackbar { left: 12px; right: 12px; bottom: 12px; min-width: 0; }
  dialog { width: calc(100% - 24px); max-height: calc(100% - 24px); }
}
