/* Gaelta Cockpit panel. Layout after the LWI 2.0 admin (GaeltaAgency/lwi-upgrade), see SPEC.md 0b. */
@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&display=swap');

:root {
  --bg: #f3f5f6;
  --surface: #ffffff;
  --sunken: #eef1f3;
  --ink: #16212b;
  --ink-2: #3e4a55;
  --muted: #5f6b76;
  --line: #e1e6ea;
  --line-strong: #cfd6dc;
  --primary: #16212b;
  --on-primary: #ffffff;
  --link: #2459e0;
  --focus: #2f6bff;
  --ok: #1e9e6a;
  --ok-soft: #e4f5ed;
  --warn: #b97800;
  --warn-soft: #fdf2dc;
  --bad: #d23f37;
  --bad-soft: #fde8e6;
  --off: #9aa6b0;
  --shadow: 0 1px 2px rgba(22, 33, 43, .05), 0 6px 16px rgba(22, 33, 43, .05);
  --r-sm: 6px;
  --r: 8px;
  --r-lg: 12px;
  --side: 240px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1519; --surface: #161e24; --sunken: #121a1f; --ink: #e8edf0; --ink-2: #c2cbd1; --muted: #93a0aa;
    --line: #26323a; --line-strong: #33424c; --primary: #e8edf0; --on-primary: #0f1519; --link: #7ea2ff; --focus: #6f97ff;
    --ok: #3cc48c; --ok-soft: #12322a; --warn: #f0b23a; --warn-soft: #362a12; --bad: #ff6b62; --bad-soft: #3a1a18; --off: #5d6a74;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1519; --surface: #161e24; --sunken: #121a1f; --ink: #e8edf0; --ink-2: #c2cbd1; --muted: #93a0aa;
  --line: #26323a; --line-strong: #33424c; --primary: #e8edf0; --on-primary: #0f1519; --link: #7ea2ff; --focus: #6f97ff;
  --ok: #3cc48c; --ok-soft: #12322a; --warn: #f0b23a; --warn-soft: #362a12; --bad: #ff6b62; --bad-soft: #3a1a18; --off: #5d6a74;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); color-scheme: dark;
}

* { box-sizing: border-box; }
html { font-size: 14px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 1rem/1.5 Geist, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-feature-settings: 'tnum' 1; -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.08rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- buttons, inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--ink);
  font: 500 0.95rem/1 inherit; font-family: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--sunken); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { filter: brightness(1.15); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--sunken); }
.btn.sm { height: 30px; padding: 0 10px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.icon-btn { width: 36px; padding: 0; }

label { display: block; font-weight: 500; margin: 14px 0 6px; }
input, select {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.hint { font-size: .9rem; color: var(--muted); margin-top: 6px; }
.error { color: var(--bad); font-size: .95rem; min-height: 1.4em; margin-top: 10px; }

/* ---------------------------------------------------------------- shell */
.shell { display: flex; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; width: var(--side); flex: none; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--line); transition: width .18s ease;
}
.shell.collapsed { --side: 64px; }
.brand { display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--line); color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand img { width: 28px; height: 28px; border-radius: 7px; flex: none; }
.brand b { font-weight: 650; font-size: 1.02rem; white-space: nowrap; }
.nav { flex: 1; overflow-y: auto; padding: 10px 10px; }
.nav-group { margin-top: 14px; padding: 0 10px 4px; font-size: .85rem; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 10px; border-radius: var(--r);
  color: var(--ink-2); font-weight: 500; white-space: nowrap;
}
.nav a:hover { background: var(--sunken); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--sunken); color: var(--ink); box-shadow: inset 3px 0 0 var(--ink); }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { padding: 10px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.side-foot small { color: var(--muted); white-space: nowrap; overflow: hidden; }
.collapsed .brand b, .collapsed .nav span, .collapsed .nav-group, .collapsed .side-foot small { display: none; }
.collapsed .nav a { justify-content: center; padding: 0; }
.collapsed .side-foot { justify-content: center; }
.collapsed .collapse-btn svg { transform: rotate(180deg); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 5; height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; }
.org-switch { max-width: 280px; justify-content: flex-start; }
.org-switch span { overflow: hidden; text-overflow: ellipsis; }
.org-switch .role { color: var(--muted); font-weight: 400; }
.search { flex: 1; max-width: 360px; justify-content: space-between; color: var(--muted); margin-left: auto; }
kbd { font: 500 .8rem inherit; font-family: inherit; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 5px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--sunken); border: 1px solid var(--line-strong); display: grid; place-items: center; font-weight: 600; font-size: .85rem; cursor: pointer; color: var(--ink); }

.content { width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head p { margin-top: 6px; color: var(--ink-2); max-width: 64ch; }
.section { margin-top: 32px; }
.section > header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section > header p { color: var(--muted); }

/* Exception strip: inside the content, never above the topbar, so nothing jumps. */
.strip { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--r); margin-bottom: 18px; font-weight: 500; }
.strip.warn { background: var(--warn-soft); color: var(--ink); }
.strip.bad { background: var(--bad-soft); color: var(--ink); }
.strip .btn { margin-left: auto; }

/* ---------------------------------------------------------------- the panel: tools with status lamps */
.lamp { width: 9px; height: 9px; border-radius: 50%; background: var(--off); flex: none; }
.lamp.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.lamp.warn { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 22%, transparent); }
.lamp.bad { background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 22%, transparent); }

.mark { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 1.05rem; flex: none; }
.mark.sm { width: 24px; height: 24px; border-radius: 6px; font-size: .75rem; }

.instruments { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.instrument {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; padding: 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.instrument .mark { grid-row: span 2; }
.instrument .name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 1.05rem; }
.instrument .state { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.instrument .actions { display: flex; align-items: center; gap: 6px; }
.instrument .meta { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); }

.offers { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.offer {
  display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px dashed var(--line-strong); border-radius: var(--r-lg); background: transparent;
}
.offer .head { display: flex; align-items: center; gap: 12px; }
.offer .mark { filter: saturate(.55); opacity: .9; }
.offer p { color: var(--ink-2); }
.offer .foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 4px; }
.price { color: var(--muted); }
.price b { color: var(--ink); font-weight: 600; }

.soon-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.soon-list li { display: grid; grid-template-columns: 24px auto 1fr; align-items: center; gap: 10px; }
.soon-list li > span:last-child { color: var(--muted); }
.soon-list .mark { filter: saturate(.4); opacity: .8; }

/* ---------------------------------------------------------------- tables, panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); overflow: hidden; }
.panel + .panel { margin-top: 12px; }
.panel-body { padding: 18px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 500; color: var(--muted); background: var(--sunken); font-size: .92rem; }
tr:last-child td { border-bottom: 0; }
td .state { display: inline-flex; align-items: center; gap: 8px; }
.empty { padding: 36px 18px; text-align: center; color: var(--ink-2); }
.empty p { margin: 6px auto 16px; color: var(--muted); max-width: 46ch; }
.row-form { display: flex; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--line); background: var(--sunken); }
.row-form input { max-width: 320px; }
.row-form select { max-width: 160px; }
.summary { font-size: 1.05rem; color: var(--ink-2); max-width: 70ch; }
.summary b { color: var(--ink); font-weight: 600; }
.pill { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; background: var(--sunken); color: var(--ink-2); font-size: .85rem; font-weight: 500; }

/* ---------------------------------------------------------------- sheet (unlock flow), menus, palette */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgba(15, 21, 25, .38); }
.sheet {
  position: fixed; z-index: 21; top: 0; right: 0; bottom: 0; width: min(460px, 100%); background: var(--surface);
  border-left: 1px solid var(--line); display: flex; flex-direction: column; animation: sheet-in .2s ease;
}
@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } }
.sheet header { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.sheet header .btn { margin-left: auto; }
.sheet .body { flex: 1; overflow-y: auto; padding: 20px; }
.sheet .body > p { color: var(--ink-2); }
.sheet footer { padding: 16px 20px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.plans { list-style: none; margin: 18px 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--r); }
.plan-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); }
.plan-row:first-child { border-top: 0; }
.plan-row .price { margin-left: auto; }
.plan-row.hl { background: var(--sunken); }
.note { margin-top: 16px; padding: 12px 14px; border-radius: var(--r); background: var(--sunken); color: var(--ink-2); font-size: .95rem; }

.menu { position: fixed; z-index: 30; min-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 10px 30px rgba(15, 21, 25, .16); padding: 6px; }
.menu button, .menu a { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 6px; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.menu button:hover, .menu a:hover, .menu [aria-selected="true"] { background: var(--sunken); text-decoration: none; }
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu .who small { display: block; color: var(--muted); }
.menu .check { margin-left: auto; color: var(--ink); }
.menu input { margin-bottom: 6px; }

.toast { position: fixed; z-index: 40; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--primary); color: var(--on-primary); padding: 10px 16px; border-radius: var(--r); font-weight: 500; box-shadow: var(--shadow); }

/* ---------------------------------------------------------------- login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { border: 0; padding: 0; height: auto; margin-bottom: 28px; }
.auth-card h1 { font-size: 1.5rem; }
.auth-card > p { margin-top: 6px; color: var(--ink-2); }
.auth-card form { margin-top: 18px; }
.auth-card .btn.primary { margin-top: 20px; height: 40px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); margin: 18px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.tools-line { margin-top: 28px; display: flex; gap: 6px; }

.center { min-height: 100vh; display: grid; place-items: center; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 860px) {
  .side { position: fixed; z-index: 25; left: 0; transform: translateX(-100%); transition: transform .2s ease; width: 260px; }
  .shell.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(15, 21, 25, .38); }
  .collapsed .brand b, .collapsed .nav span, .collapsed .nav-group { display: initial; }
  .collapse-btn { display: none; }
  .menu-btn { display: inline-flex; }
  .top { padding: 0 12px; }
  .search .label, .search kbd { display: none; }
  .search { flex: none; width: 36px; padding: 0; justify-content: center; margin-left: auto; }
  .org-switch { max-width: 52vw; }
  .content { padding: 20px 16px 48px; }
  .page-head { flex-direction: column; align-items: stretch; }
  .instruments, .offers { grid-template-columns: 1fr; }
  .section > header { flex-direction: column; align-items: flex-start; gap: 4px; }
  .soon-list li { grid-template-columns: 24px 1fr; }
  .soon-list li > span:last-child { grid-column: 2; }
  th:nth-child(n+3), td:nth-child(n+3) { display: none; }
  .row-form { flex-wrap: wrap; }
  .row-form input, .row-form select { max-width: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
