/* Leadwhale shell: the page frame for the hosted app. Written for Leadwhale; shares no code
   with the single-computer host page. leadwhale.css sits on top of this file. */

@font-face { font-family: 'Geist'; font-style: normal; font-weight: 400 700; font-display: swap; src: url('/static/lw/fonts/geist.woff2') format('woff2'); }

:root {
  --sans: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --fs-caption: 0.75rem; --fs-small: 0.75rem; --fs-ui: 0.8125rem; --fs-body: 0.875rem; --fs-lead: 0.9375rem; --fs-h3: 1.0625rem; --fs-h2: 1.375rem;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --lw-blue: #3B82F6; --lw-green: #16B36B; --lw-amber: #F5A524; --lw-red: #E5484D; --lw-purple: #8B5CF6; --lw-on-amber: #3A2500;
  --ok: #16B36B; --warn: #F5A524;
  color-scheme: light;
}
:root[data-theme='dark'] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) { color-scheme: dark; } }

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: var(--fs-body); line-height: 1.5;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
button, input, select, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--text-3); }
.hint { font-weight: 400; color: var(--text-3); font-size: var(--fs-caption); margin-left: 6px; }

/* Frame */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; overflow-y: auto; }
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand-lockup { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -0.03em; line-height: 1; }
.brand .tagline { font-size: var(--fs-caption); line-height: 1.2; }
.sidebar nav { display: flex; flex-direction: column; flex: 1; }
.nav-group { display: flex; flex-direction: column; }
.sidebar nav button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; font: 500 var(--fs-ui)/1 var(--sans); text-align: left; cursor: pointer;
  transition: background .15s ease, color .15s ease; }
.sidebar nav button .label { flex: 1; }
.nav-count { display: none; }
.nav-count:not(:empty) { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 10px; font-size: 11px; font-weight: 600;
  background: rgb(255 255 255 / 0.14); color: #fff; }
.sidebar-foot { display: flex; flex-direction: column; margin-top: auto; }
.foot-actions { display: flex; align-items: center; gap: 8px; }
.theme-switch { display: inline-flex; padding: 3px; border-radius: 9px; gap: 2px; }
.theme-switch button { width: 26px; height: 24px; display: grid; place-items: center; border: 0; border-radius: 7px; background: none; cursor: pointer; }
.theme-switch button .icon { width: 13px; height: 13px; }
.theme-switch button.on { background: rgb(255 255 255 / 0.16); color: #fff; }
.refresh-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 9px; font-size: var(--fs-caption); font-weight: 500; cursor: pointer; }
main.content { min-width: 0; }
.content-inner { max-width: var(--content-w); margin: 0 auto; }
.section { display: none; }
.section.active { display: block; animation: lw-in .18s ease; }
@keyframes lw-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .section.active { animation: none; } }
.section-head { display: flex; justify-content: space-between; flex-wrap: wrap; }
.section-head p { margin-top: 6px; line-height: 1.5; text-wrap: pretty; }

/* Controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border: 0; border-radius: 11px;
  font: 600 var(--fs-ui)/1 var(--sans); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s ease, box-shadow .15s ease, color .15s ease; }
.btn .icon { width: 14px; height: 14px; }
.btn-sm { height: 32px; padding: 0 12px; border-radius: 9px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgb(21 18 59 / 0.18), inset 0 1px 0 rgb(255 255 255 / 0.16); }
.btn-secondary { background: var(--surface); color: var(--text); box-shadow: var(--shadow-border); }
.btn-ghost { background: none; color: var(--text-2); }
.btn-danger { background: var(--lw-red); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
@media (hover: hover) {
  .btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
  .btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
  .btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
  .btn-danger:hover:not(:disabled) { filter: brightness(.94); }
}
.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-label { font-size: var(--fs-ui); font-weight: 600; color: var(--text); }
.form-input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--text);
  font-size: var(--fs-body); transition: border-color .15s ease, box-shadow .15s ease; }
textarea.form-input { height: auto; padding: 10px 12px; line-height: 1.5; }
select.form-input { padding-right: 28px; }
.form-input::placeholder { color: var(--text-3); }
.form-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; }
.search { position: relative; display: flex; align-items: center; flex: 1; min-width: 200px; max-width: 360px; }
.search .icon { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; }
.search .form-input { padding-left: 34px; }
.segmented { display: inline-flex; background: var(--surface-2); }
.segmented button { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border: 0; background: none; color: var(--text-2); font: 600 var(--fs-ui)/1 var(--sans); cursor: pointer; }
.segmented button .n { color: var(--text-3); font-weight: 500; }

/* Surfaces */
.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-border); padding: 20px; margin-bottom: var(--sp-4); }
.subhead { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); font-size: var(--fs-ui); font-weight: 650; color: var(--text); margin: var(--sp-4) 0 var(--sp-3); }
.card > .subhead:first-child { margin-top: 0; }
.table-card { background: var(--surface); box-shadow: var(--shadow-border); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: var(--fs-ui); }
tbody tr:last-child td { border-bottom: 0; }
.table-foot { margin-top: 10px; padding: 0 4px; font-size: var(--fs-caption); color: var(--text-3); }
.cell-stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { font-size: var(--fs-caption); color: var(--text-3); }
.cell-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 56px 24px; }
.empty .glyph { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); margin-bottom: 14px; }
.empty .title { font-size: var(--fs-lead); font-weight: 650; }
.empty .copy { margin-top: 6px; color: var(--text-2); font-size: var(--fs-ui); max-width: 44ch; line-height: 1.5; }
.empty .copy b { color: var(--text); }

/* Dialogs and toasts */
dialog.modal { border: 0; padding: 0; border-radius: 20px; background: var(--surface); color: var(--text); width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  box-shadow: 0 24px 64px rgb(15 12 60 / 0.35); overflow: auto; }
dialog.modal::backdrop { background: rgb(15 12 60 / 0.45); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) var(--sp-3); }
.modal-head h3 { font-size: var(--fs-h3); font-weight: 650; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.modal-head .sub { font-size: var(--fs-ui); color: var(--text-2); margin-top: 4px; }
.modal-body { padding: 0 var(--sp-5) var(--sp-5); }
.modal-foot { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--line); background: var(--surface); }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 10000; max-width: 380px; padding: 12px 16px; border-radius: 12px; background: var(--text); color: var(--bg);
  font-size: var(--fs-ui); font-weight: 500; box-shadow: 0 12px 32px rgb(15 12 60 / 0.3); animation: lw-in .2s ease; }
.toast.error { background: var(--lw-red); color: #fff; }
details summary { cursor: pointer; }

/* Narrow screens: the sidebar becomes a top bar. */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px !important; padding: 12px 16px !important; }
  .brand .tagline, .lw-side-card, .lw-support-hint, .foot-actions { display: none; }
  .sidebar nav { flex-direction: row; flex: 1 1 100%; order: 3; overflow-x: auto; }
  .nav-group { flex-direction: row; }
  .sidebar nav button { width: auto; white-space: nowrap; }
  .sidebar-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; border-top: 0 !important; padding: 0 !important; }
  .lw-support-btn { width: auto; }
  main.content { padding: 20px 16px 72px !important; }
}

/* Sign-in page */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-border); padding: 32px; display: flex; flex-direction: column; gap: 16px; }
.auth-card .brand-lockup { font-size: 22px; color: var(--text); }
.auth-card .lw-whale { color: var(--accent); }
.auth-card h1 { font-size: 24px; letter-spacing: -0.03em; }
.auth-card p { color: var(--text-2); font-size: var(--fs-body); }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .btn { height: 44px; font-size: var(--fs-body); }
.auth-error { display: none; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--lw-red) 12%, var(--surface)); color: color-mix(in srgb, var(--lw-red) 75%, var(--text)); font-size: var(--fs-ui); }
.auth-error.on { display: block; }
.auth-note { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); color: var(--text); font-size: var(--fs-ui); }
.auth-card a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
.auth-switch { text-align: center; font-size: var(--fs-ui); color: var(--text-2); }
.auth-switch button { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }
