/* Strawhats dashboard — chart-paper palette, straw-yellow timers, one memorable element: the draining fleet strip */

:root {
  --bg: #E8EEEB;
  --surface: #F7F9F7;
  --surface-2: #EDF2EF;
  --ink: #12272C;
  --muted: #566B6F;
  --line: #C8D4CF;
  --brand: #0E5A63;
  --on-brand: #F4FAF9;
  --straw: #E2A729;
  --straw-soft: #F5E3B4;
  --run: #1E8A57;
  --run-soft: #CDE6D9;
  --finished: #3A74A8;
  --finished-soft: #D2E2F0;
  --idle: #8A9A9D;
  --idle-soft: #DDE5E2;
  --warn: #A8650A;
  --warn-soft: #F5E2BF;
  --danger: #B3302A;
  --danger-soft: #F4D9D5;
  --radius: 10px;
  --mono: "Spline Sans Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D191C;
    --surface: #13252A;
    --surface-2: #183036;
    --ink: #E3EEEA;
    --muted: #8FA7A9;
    --line: #264248;
    --brand: #5CC8D3;
    --on-brand: #06242A;
    --straw: #F0B83A;
    --straw-soft: #4A3912;
    --run: #4CCB8C;
    --run-soft: #17402F;
    --finished: #6FA8DC;
    --finished-soft: #1B3550;
    --idle: #7E9498;
    --idle-soft: #1F3338;
    --warn: #E3A04A;
    --warn-soft: #473213;
    --danger: #F2736A;
    --danger-soft: #431E1B;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h3 { font-size: 18px; }
p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13.5px; max-width: 62ch; }
.hint.small { font-size: 12.5px; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* ───────── buttons & fields ───────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink);
  font-weight: 500; cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.small { min-height: 30px; padding: 0 11px; font-size: 13.5px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { filter: brightness(1.08); background: var(--brand); }
.btn.danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); border-color: transparent; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; color: var(--muted); }
.field input, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font-size: 15px;
}
.field textarea { font-family: var(--mono); font-size: 13px; resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.field.compact input { width: 150px; }
.form-error { color: var(--danger); font-size: 13.5px; min-height: 1.3em; }

/* ───────── login ───────── */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(360px, 100%); display: flex; flex-direction: column; gap: 16px;
  padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.brand-mark {
  width: 28px; height: 28px; flex: none; border-radius: 50% 50% 46% 46%;
  background:
    linear-gradient(to bottom, transparent 58%, #B3302A 58%, #B3302A 72%, transparent 72%),
    var(--straw);
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.12);
}

/* ───────── top bar ───────── */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
  padding: 12px clamp(16px, 3vw, 32px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-weight: 700; font-size: 19px; letter-spacing: -0.02em; }
.summary { display: flex; gap: 28px; flex-wrap: wrap; flex: 1; }
.stat { display: flex; flex-direction: column; line-height: 1.15; }
.stat-value { font-size: 20px; font-weight: 600; }
.stat-label { font-size: 12.5px; color: var(--muted); }
.topbar-end { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.conn { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); }
.conn[data-state="on"] i { background: var(--run); }
.conn[data-state="off"] i { background: var(--danger); }

.banner {
  margin: 0; padding: 10px clamp(16px, 3vw, 32px);
  background: var(--warn-soft); color: var(--warn); font-size: 14px; border-bottom: 1px solid var(--line);
}

main { max-width: 1280px; margin: 0 auto; padding: 24px clamp(16px, 3vw, 32px) 80px; display: flex; flex-direction: column; gap: 28px; }

/* ───────── console ───────── */

.console {
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 20px;
  padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.window { display: flex; flex-direction: column; gap: 10px; }
.window-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.window-effective { font-weight: 600; color: var(--brand); }
.window-effective[data-custom="true"] { color: var(--warn); }
.window-inputs { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.actions { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; border-left: 1px solid var(--line); padding-left: 20px; }
.actions-main { display: flex; gap: 10px; flex-wrap: wrap; }
.actions .btn.danger { align-self: stretch; }

/* ───────── fleet strip ───────── */

.fleet { display: flex; flex-direction: column; gap: 12px; }
.fleet-strip { display: flex; flex-wrap: wrap; gap: 14px 22px; }
.fleet-group { display: flex; flex-direction: column; gap: 6px; }
.fleet-group-name { font-size: 12.5px; color: var(--muted); }
.fleet-cells { display: flex; flex-wrap: wrap; gap: 4px; max-width: 360px; }
.cell {
  --fill: 0%; --c: var(--idle); --c-soft: var(--idle-soft);
  position: relative; width: 16px; height: 34px; padding: 0; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); border-radius: 4px;
  background: linear-gradient(to top, var(--c) var(--fill), var(--c-soft) var(--fill));
  transition: background .6s linear;
}
.cell:hover { border-color: var(--ink); }
.cell.s-running { --c: var(--straw); --c-soft: var(--run-soft); border-color: var(--run); }
.cell.s-starting, .cell.s-queued, .cell.s-stopping { --c: var(--warn); --c-soft: var(--warn-soft); --fill: 100%; }
.cell.s-finished { --c: var(--finished); --c-soft: var(--finished-soft); --fill: 100%; }
.cell.s-error { --c: var(--danger); --c-soft: var(--danger-soft); --fill: 100%; }
.cell.s-idle, .cell.s-stopped { --c: var(--idle); --c-soft: var(--idle-soft); --fill: 0%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend-note { margin-left: auto; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--idle); display: inline-block; flex: none; }
.dot.s-running { background: var(--run); }
.dot.s-starting, .dot.s-queued, .dot.s-stopping { background: var(--warn); }
.dot.s-finished { background: var(--finished); }
.dot.s-error { background: var(--danger); }

/* ───────── servers ───────── */

.servers-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: -12px; }
.servers-head-end { display: flex; gap: 8px; }
.servers { display: flex; flex-direction: column; gap: 18px; }
.empty { color: var(--muted); padding: 28px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

.server { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.server-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.server-title { display: flex; flex-direction: column; min-width: 0; flex: 1 1 220px; }
.server-name { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.server-meta { font-size: 13px; color: var(--muted); }
.server-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 170px;
  display: flex; flex-direction: column; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(10, 30, 35, .18);
}
.menu-list button {
  text-align: left; padding: 8px 10px; background: none; border: 0; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.menu-list button:hover { background: var(--surface-2); }
.menu-list button.danger-text { color: var(--danger); }

.worker {
  display: grid; align-items: center; gap: 12px 18px;
  grid-template-columns: 118px minmax(150px, 1.2fr) minmax(190px, 1.3fr) minmax(110px, .8fr) auto;
  padding: 11px 18px; border-bottom: 1px solid var(--line);
}
.worker:last-child { border-bottom: 0; }
.worker.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--straw-soft); } to { background: transparent; } }

.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px 3px 8px;
  border-radius: 999px; font-size: 13px; font-weight: 500;
  background: var(--idle-soft); color: var(--muted); width: max-content;
}
.pill.s-running { background: var(--run-soft); color: var(--run); }
.pill.s-starting, .pill.s-queued, .pill.s-stopping { background: var(--warn-soft); color: var(--warn); }
.pill.s-finished { background: var(--finished-soft); color: var(--finished); }
.pill.s-error { background: var(--danger-soft); color: var(--danger); }
.pill.s-running .dot { animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.w-name { display: flex; flex-direction: column; min-width: 0; }
.w-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-sub.error { color: var(--danger); white-space: normal; }

.w-time { display: flex; flex-direction: column; gap: 5px; }
.w-time-text { font-size: 14px; }
.w-time-text b { font-weight: 600; font-size: 15px; }
.bar { height: 5px; border-radius: 3px; background: var(--idle-soft); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--straw); transition: width .9s linear; }
.w-stats { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; }
.w-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.server-empty { padding: 18px; color: var(--muted); font-size: 14px; }

/* ───────── log panel ───────── */

.logpanel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(620px, 100vw);
  display: flex; flex-direction: column; background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(10, 30, 35, .16);
}
.logpanel > header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.logpanel > header > div:first-child { display: flex; flex-direction: column; min-width: 0; }
.log-actions { display: flex; gap: 6px; }
.log-body {
  flex: 1; margin: 0; padding: 14px 16px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.55; background: var(--bg);
}
.log-line .ts { color: var(--muted); margin-right: 8px; }
.log-line.warn { color: var(--warn); }
.log-line.bad { color: var(--danger); }
.log-line.sys { color: var(--brand); }

/* ───────── dialogs, toasts ───────── */

.dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--ink); width: min(440px, calc(100vw - 32px)); }
.dialog.wide { width: min(640px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(8, 22, 26, .5); }
.dialog-body { display: flex; flex-direction: column; gap: 14px; padding: 22px; }
.dialog-body p { color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100vw - 32px); }
.toast { padding: 10px 16px; border-radius: 10px; background: var(--ink); color: var(--bg); font-size: 14px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.bad { background: var(--danger); color: #fff; }

/* ───────── responsive ───────── */

@media (max-width: 1020px) {
  .console { grid-template-columns: 1fr; }
  .actions { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 16px; }
  .worker { grid-template-columns: 112px minmax(0, 1fr) minmax(0, 1fr); }
  .w-actions { grid-column: 1 / -1; justify-content: flex-start; }
}
@media (max-width: 620px) {
  .worker { grid-template-columns: 1fr; }
  .topbar { gap: 14px; }
  .summary { gap: 18px; }
  .field.compact input { width: 130px; }
  .legend-note { margin-left: 0; width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ───────── payout page ───────── */

.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); }

.panel { display: flex; flex-direction: column; gap: 10px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.hint.warn { color: var(--warn); }
.po-form { display: flex; flex-direction: column; gap: 18px; margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.field select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); font-size: 15px;
}
.pick { display: flex; flex-direction: column; gap: 10px; }
.pick-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pick-actions { margin-left: auto; display: flex; gap: 4px; }
.checklist { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2);
}
.check input { accent-color: var(--brand); width: 16px; height: 16px; }
.check small { color: var(--muted); }
.check.disabled { opacity: .6; cursor: not-allowed; }

.section-title { margin-bottom: 12px; }
.jobs { display: flex; flex-direction: column; gap: 16px; }
.job { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.job-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.acct {
  display: grid; align-items: center; gap: 8px 18px; padding: 10px 18px; border-bottom: 1px solid var(--line);
  grid-template-columns: 140px minmax(130px, 1fr) minmax(150px, 1fr) minmax(160px, 1.4fr);
}
.acct:last-child { border-bottom: 0; }
.pad { padding: 10px 18px; }
@media (max-width: 800px) { .acct { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .acct { grid-template-columns: 1fr; } .nav a { padding: 6px 8px; } }
