/* ========================================================= AWS Bank UI ===
   Redeploy brand: near-black, lime accent, warm off-white. Light is the base
   palette; dark redefines only the tokens. Both are reachable via
   data-theme (explicit) and prefers-color-scheme (auto).
   ========================================================================= */

:root {
  --bg: #fffcf5;
  --bg-tint: #f6f2e8;
  --surface: #ffffff;
  --surface-2: #f3efe4;
  --surface-raised: #ffffff;
  --border: #e7e0d0;
  --border-strong: #d3c9b3;
  --text: #01081a;
  --text-muted: #4b5266;
  --text-subtle: #6b7286;

  --accent: #0f9d5c;      /* darkened lime, keeps 4.5:1+ as text/border on light bg */
  --accent-bright: #20fb87; /* the true brand lime, used for fills/glow, not text */
  --accent-hover: #0c7f49;
  --accent-contrast: #01081a;
  --accent-soft: #e3fbee;
  --accent-border: #a9f2cb;
  --accent-glow: rgba(32, 251, 135, .28);

  --success: #187a4a;
  --success-soft: #e2f2e8;
  --success-border: #b7dbc6;
  --success-contrast: #ffffff;
  --warning: #9a6400;
  --warning-soft: #fcf0df;
  --warning-border: #eccb9f;
  --warning-contrast: #ffffff;
  --danger: #b3261e;
  --danger-hover: #96201a;
  --danger-soft: #fbe9e7;
  --danger-border: #f0b6b0;
  --danger-contrast: #ffffff;

  --shadow-xs: 0 1px 2px rgba(1, 8, 26, .06);
  --shadow-sm: 0 1px 2px rgba(1, 8, 26, .05), 0 1px 3px rgba(1, 8, 26, .05);
  --shadow-md: 0 4px 12px rgba(1, 8, 26, .08), 0 2px 4px rgba(1, 8, 26, .04);
  --shadow-lg: 0 16px 40px rgba(1, 8, 26, .16), 0 4px 12px rgba(1, 8, 26, .06);

  --dur-fast: .14s;
  --dur: .2s;
  --dur-slow: .28s;
  --ease: cubic-bezier(.22, .8, .3, 1);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --nav-width: 240px;
  --header-height: 58px;

  /* The brand mark and the login hero are a fixed piece of identity, not a
     themed surface — they stay near-black-with-lime in both light and dark
     mode, the way a logo does not repaint itself when the OS switches theme.
     Deliberately not derived from --text/--bg, which do flip. */
  --brand-ink: #01081a;
  --brand-lime: #20fb87;
  --brand-cream: #fffcf5;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #01081a;
    --bg-tint: #060f28;
    --surface: #0a1330;
    --surface-2: #101b3c;
    --surface-raised: #101b3c;
    --border: #22305a;
    --border-strong: #34447a;
    --text: #fffcf5;
    --text-muted: #b7bccb;
    --text-subtle: #8b91a6;

    --accent: #20fb87;
    --accent-bright: #20fb87;
    --accent-hover: #6bffab;
    --accent-contrast: #01081a;
    --accent-soft: rgba(32, 251, 135, .12);
    --accent-border: rgba(32, 251, 135, .35);
    --accent-glow: rgba(32, 251, 135, .3);

    --success: #5cc492;
    --success-soft: rgba(92, 196, 146, .14);
    --success-border: rgba(92, 196, 146, .35);
    --success-contrast: #0d241a;
    --warning: #e2b25a;
    --warning-soft: rgba(226, 178, 90, .14);
    --warning-border: rgba(226, 178, 90, .35);
    --warning-contrast: #2b1f07;
    --danger: #f08b83;
    --danger-hover: #f5a8a1;
    --danger-soft: rgba(240, 139, 131, .14);
    --danger-border: rgba(240, 139, 131, .35);
    --danger-contrast: #2b0f0c;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px rgba(0, 0, 0, .24);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .34), 0 2px 4px rgba(0, 0, 0, .2);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5), 0 4px 12px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #01081a;
  --bg-tint: #060f28;
  --surface: #0a1330;
  --surface-2: #101b3c;
  --surface-raised: #101b3c;
  --border: #22305a;
  --border-strong: #34447a;
  --text: #fffcf5;
  --text-muted: #b7bccb;
  --text-subtle: #8b91a6;

  --accent: #20fb87;
  --accent-bright: #20fb87;
  --accent-hover: #6bffab;
  --accent-contrast: #01081a;
  --accent-soft: rgba(32, 251, 135, .12);
  --accent-border: rgba(32, 251, 135, .35);
  --accent-glow: rgba(32, 251, 135, .3);

  --success: #5cc492;
  --success-soft: rgba(92, 196, 146, .14);
  --success-border: rgba(92, 196, 146, .35);
  --success-contrast: #0d241a;
  --warning: #e2b25a;
  --warning-soft: rgba(226, 178, 90, .14);
  --warning-border: rgba(226, 178, 90, .35);
  --warning-contrast: #2b1f07;
  --danger: #f08b83;
  --danger-hover: #f5a8a1;
  --danger-soft: rgba(240, 139, 131, .14);
  --danger-border: rgba(240, 139, 131, .35);
  --danger-contrast: #2b0f0c;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px rgba(0, 0, 0, .24);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .34), 0 2px 4px rgba(0, 0, 0, .2);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5), 0 4px 12px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

@font-face {
  font-family: 'Inter';
  src: url('/InterVariable-4.1.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ------------------------------------------------------------- reset --- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p, ul, ol, form { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.subtle { color: var(--text-subtle); font-size: .88rem; }
.muted { color: var(--text-muted); font-size: .92rem; }

.icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ------------------------------------------------------------- brand --- */
.brand { display: flex; align-items: center; gap: 11px; font-weight: 650; font-size: 1.12rem; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px;
  background: var(--brand-ink);
  color: var(--brand-lime);
  display: grid; place-items: center; flex: none;
}
.brand-mark svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 6; stroke-linecap: round; }
.brand-home { background: none; border: 0; padding: 0; cursor: pointer; display: flex; align-items: center; gap: 11px; text-align: left; }
.brand-text { display: flex; flex-direction: column; }

/* --------------------------------------------------------------- btn --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: .92rem; cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.primary { background: var(--accent-bright); color: var(--accent-contrast); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn.secondary:hover:not(:disabled) { border-color: var(--border-strong); }
.btn.ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.btn.danger:hover:not(:disabled) { background: var(--danger); color: var(--danger-contrast); }
.btn.wide { width: 100%; }
.btn.small { padding: 6px 11px; font-size: .82rem; }
.link-btn {
  background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600;
  cursor: pointer; font-size: .9rem; text-decoration: none;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.strong { font-weight: 700; }
:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }

/* -------------------------------------------------------------- form --- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: .83rem; font-weight: 600; color: var(--text-muted); }
.field-inline { display: flex; flex-direction: column; gap: 5px; }
input, select, textarea {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-xs); padding: 10px 12px; font-size: .95rem; width: 100%;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
input:disabled { opacity: .6; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { resize: vertical; font-family: inherit; }
.password-hint { font-size: .8rem; color: var(--text-subtle); margin: -6px 0 14px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 180px; }
.settings-form { max-width: 420px; }

/* ------------------------------------------------------------- login --- */
.login-screen { display: flex; min-height: 100vh; }
.login-aside {
  flex: 1 1 46%; max-width: 560px; background: var(--brand-ink); color: var(--brand-cream);
  padding: 48px 52px; display: flex; flex-direction: column; justify-content: space-between;
}
.login-aside .brand { color: var(--brand-cream); }
.login-aside .brand .brand-mark { background: var(--brand-lime); color: var(--brand-ink); }
.aside-copy h2 { font-size: 1.7rem; line-height: 1.25; margin: 40px 0 14px; font-weight: 700; }
.aside-copy p { color: #cfd3e0; font-size: 1rem; line-height: 1.6; }
.aside-list { list-style: none; padding: 0; margin: 26px 0 0; display: flex; flex-direction: column; gap: 14px; }
.aside-list li { display: flex; align-items: flex-start; gap: 10px; color: #e4e7f0; }
.aside-list .icon { color: var(--accent-bright); margin-top: 2px; }
.aside-foot { color: #8890a8; font-size: .85rem; }

.login-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.login-card { width: 100%; max-width: 400px; }
.login-card .brand { justify-content: center; margin-bottom: 26px; }
.auth-form { display: flex; flex-direction: column; }
.auth-head { margin-bottom: 20px; }
.auth-head h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; }
.auth-head p { color: var(--text-muted); }
.auth-foot { text-align: center; margin-top: 14px; }
.auth-note { font-size: .84rem; color: var(--text-subtle); margin-top: 16px; text-align: center; line-height: 1.5; }
.auth-message { padding: 10px 13px; border-radius: var(--radius-xs); font-size: .88rem; margin-bottom: 4px; }
.auth-message.error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-border); }
.auth-message.ok { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-border); }

/* ---------------------------------------------------------- app shell --- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--nav-width); flex: none; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 18px;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 40; transition: transform var(--dur) var(--ease);
}
.sidebar .brand { justify-content: space-between; padding: 0 4px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-subtle); font-weight: 700; margin: 16px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: none; border: 0; color: var(--text-muted); font-weight: 600; font-size: .93rem;
  cursor: pointer; text-align: left; width: 100%;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-platform { border-top: 1px solid var(--border); padding-top: 4px; margin-top: 8px; }
.side-user { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; flex: none;
}
.user-chip-text { display: flex; flex-direction: column; overflow: hidden; }
.user-chip-name { font-weight: 650; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip-mail { font-size: .78rem; color: var(--text-subtle); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; margin-left: var(--nav-width); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: none; align-items: center; gap: 12px; height: var(--header-height); padding: 0 16px;
  border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 30;
  padding-top: env(safe-area-inset-top);
  height: calc(var(--header-height) + env(safe-area-inset-top));
}
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: var(--radius-xs); background: none; border: 0; color: var(--text-muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.content { padding: 34px 40px 64px; max-width: 1080px; margin: 0 auto; width: 100%; }

/* ---------------------------------------------------------------- view --- */
.view { display: none; }
.view.active-view { display: block; animation: viewIn var(--dur-slow) var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.view-head h1 { font-size: 1.55rem; font-weight: 750; margin-bottom: 5px; }
.view-head p { color: var(--text-muted); max-width: 640px; }
.view-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; margin-bottom: 20px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-head h2 { font-size: 1.05rem; font-weight: 700; }

.search-row { position: relative; margin-bottom: 20px; }
.search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); }
.search-row input { padding-left: 40px; }

.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty .icon { width: 40px; height: 40px; color: var(--text-subtle); margin-bottom: 12px; }
.empty h3 { font-size: 1.05rem; margin-bottom: 6px; color: var(--text); }

/* ----------------------------------------------------------- item list --- */
.item-list { display: flex; flex-direction: column; gap: 8px; }
.item-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  flex-wrap: wrap;
}
.item-row-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.item-row-text { display: flex; flex-direction: column; min-width: 0; }
.item-row-title { font-weight: 650; }
.item-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.badge.owner { background: var(--accent-soft); color: var(--accent); }
.badge.member { background: var(--surface-2); color: var(--text-muted); }
.badge.on { background: var(--success-soft); color: var(--success); }
.badge.off { background: var(--danger-soft); color: var(--danger); }
.badge.admin { background: var(--warning-soft); color: var(--warning); }

/* -------------------------------------------------------- project list --- */
.project-list { display: flex; flex-direction: column; gap: 10px; }
.project-card {
  display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; cursor: pointer; transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.project-card:hover { border-color: var(--accent-border); box-shadow: var(--shadow-sm); }
.project-card-title { font-weight: 700; font-size: 1.02rem; margin-bottom: 4px; }
.project-card-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--text-muted); font-size: .86rem; }
.project-card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tag {
  background: var(--surface-2); color: var(--text-muted); border-radius: 999px; padding: 3px 10px; font-size: .78rem; font-weight: 600;
}

/* -------------------------------------------------------------- chat --- */
.chat-log { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; min-height: 120px; }
.chat-bubble { max-width: 78%; padding: 12px 15px; border-radius: var(--radius-lg); line-height: 1.55; white-space: pre-wrap; }
.chat-bubble.assistant { background: var(--surface-2); align-self: flex-start; border: 1px solid var(--border); }
/* Fixed brand colours rather than --text: a bubble that flips with the theme
   would go light-on-light the moment the palette inverts. */
.chat-bubble.user { background: var(--brand-lime); color: var(--brand-ink); align-self: flex-end; }
.chat-bubble.pending { opacity: .6; }
.chat-form { display: flex; gap: 10px; align-items: flex-end; }
.chat-form textarea { flex: 1; }
.interview-done { text-align: center; padding: 32px 24px; }
.interview-done-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* ---------------------------------------------------------- project detail --- */
.project-detail { display: flex; flex-direction: column; gap: 18px; }
.detail-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.detail-group h3 { font-size: .95rem; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.detail-row { display: grid; grid-template-columns: 180px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: 0; }
.detail-row dt { color: var(--text-subtle); font-size: .85rem; font-weight: 600; }
.detail-row dd { margin: 0; white-space: pre-wrap; }
.detail-repeat-row { display: flex; gap: 10px; margin-bottom: 8px; }
.detail-repeat-row input { flex: 1; }
.detail-repeat-remove { flex: none; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 16px; }
.form-grid .field.full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } .detail-row { grid-template-columns: 1fr; } }

/* ----------------------------------------------------------------- kpi --- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.kpi-tile .kpi-value { font-size: 1.7rem; font-weight: 750; }
.kpi-tile .kpi-label { color: var(--text-muted); font-size: .82rem; font-weight: 600; }

/* --------------------------------------------------------------- table --- */
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .87rem; }
.data-table th { text-align: left; color: var(--text-subtle); font-weight: 700; text-transform: uppercase; font-size: .72rem; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
.data-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* -------------------------------------------------------------- activity --- */
.activity-chart { display: flex; align-items: flex-end; gap: 2px; height: 120px; overflow-x: auto; padding-bottom: 4px; }
.activity-bar-wrap { flex: 1 0 6px; min-width: 6px; height: 100%; display: flex; align-items: flex-end; }
.activity-bar { width: 100%; background: var(--accent-bright); border-radius: 2px 2px 0 0; min-height: 2px; }

/* ---------------------------------------------------------------- mfa --- */
.mfa-setup { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); max-width: 340px; }
.mfa-qr { display: flex; justify-content: center; margin: 12px 0; }
.mfa-qr svg { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: var(--radius-sm); }
.mfa-secret { text-align: center; font-family: var(--font-mono); letter-spacing: .05em; color: var(--text-muted); margin-bottom: 14px; }
.admin-mfa-notice { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 40px 24px; }

/* --------------------------------------------------------------- modal --- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(1, 8, 26, .5); display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 200; animation: fadeIn var(--dur-fast) var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-card { background: var(--surface); border-radius: var(--radius-lg); padding: 24px; max-width: 420px; width: 100%; box-shadow: var(--shadow-lg); }
.modal-card h2 { font-size: 1.15rem; margin-bottom: 10px; }
.modal-card p { color: var(--text-muted); margin-bottom: 18px; line-height: 1.55; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* --------------------------------------------------------------- toast --- */
.toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 300; max-width: min(360px, calc(100vw - 40px)); }
.toast {
  background: var(--text); color: var(--bg); padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  font-size: .89rem; display: flex; align-items: center; gap: 10px; animation: toastIn var(--dur) var(--ease);
}
.toast.error { background: var(--danger); color: var(--danger-contrast); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------ handbook --- */
.handbook-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 14px; }
.handbook-section h2 { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; margin-bottom: 12px; }
.handbook-section h2 .icon { color: var(--accent); }
.handbook-section p { margin-bottom: 10px; line-height: 1.6; }
.handbook-section ol, .handbook-section ul { margin: 0 0 10px; padding-left: 22px; line-height: 1.6; }
.handbook-note, .handbook-warn { border-radius: var(--radius-sm); padding: 12px 14px; margin: 10px 0; font-size: .9rem; }
.handbook-note { background: var(--accent-soft); border: 1px solid var(--accent-border); }
.handbook-warn { background: var(--warning-soft); border: 1px solid var(--warning-border); }
.handbook-section table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: .88rem; }
.handbook-section table th, .handbook-section table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }

/* ---------------------------------------------------------- responsive --- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar { display: flex; }
  .content { padding: 24px 18px 48px; }
}

@media (max-width: 640px) {
  .login-aside { display: none; }
  .view-head { flex-direction: column; align-items: stretch; }
  .view-head-actions { flex-direction: column; }
  .view-head-actions .btn { width: 100%; }
  .detail-row { grid-template-columns: 1fr; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input, .inline-form select, .inline-form button { flex: none; width: 100%; }
}

@media (max-width: 480px) {
  .content { padding: 18px 14px 40px; }
  .panel { padding: 16px; }
  .chat-bubble { max-width: 90%; }
}

/* --------------------------------------------------------- safe areas --- */
@supports (padding: max(0px)) {
  .sidebar { padding-top: max(18px, env(safe-area-inset-top)); padding-left: max(14px, env(safe-area-inset-left)); }
  .toast-root { bottom: max(20px, env(safe-area-inset-bottom)); }
}
