/*
 * ADRS Marine — Master Panel
 *
 * Follows files/DESIGN_LANGUAGE.md: light canvas, one indigo accent, hairline
 * borders, radii capped at 8px, General Sans for display and Space Mono for
 * anything technical (IDs, codes, table headers, counts). The dot texture and
 * the LED-ish mono labels are the recurring motifs, so the panel reads as the
 * same product as the platform even though staff are the only audience.
 */

:root {
  --outer: #d8dce7;
  --bg: #ffffff;
  --bg-2: #eff1f7;
  --ink: #0a0c12;
  --ink-2: #565e6b;
  --ink-3: #8f97a4;
  --line: #e1e4ec;
  --line-2: #eaecf2;

  --blue: #4c57f0;
  --blue-ink: #3b45d6;
  --blue-soft: #eceefe;
  --blue-dark: #2b2f8f;

  --success: #16a34a;
  --success-soft: #e3f5eb;
  --warn: #d97706;
  --warn-soft: #fbefda;
  --danger: #dc2626;
  --danger-soft: #fdecec;

  --sans: "General Sans", -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif;
  --mono: "Space Mono", ui-monospace, Menlo, monospace;

  --sidebar: 244px;
  --radius: 8px;
  --shadow: 0 14px 38px rgba(10, 12, 18, 0.1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--outer);
  /* the dotted texture the design language asks for on the outer canvas */
  background-image: radial-gradient(rgba(10, 12, 18, 0.07) 1px, transparent 1px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }

.mono {
  font-family: var(--mono);
  font-size: 0.86em;
  letter-spacing: 0.02em;
}

.hidden { display: none !important; }

/* ------------------------------------------------------------- login -- */

.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.login-card {
  width: 100%;
  max-width: 392px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 32px 28px;
}

.login-card .brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
}

.login-card h1 {
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.login-card .sub {
  color: var(--ink-2);
  font-size: 13.5px;
  margin: 0 0 24px;
}

/* -------------------------------------------------------------- shell -- */

.shell { display: flex; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: var(--bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px 14px;
  position: sticky;
  top: 0;
  height: 100dvh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 8px 18px;
}

.brand-mark {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}

.brand-name { font-weight: 500; letter-spacing: -0.01em; }
.brand-sub {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: block;
  margin-top: -2px;
}

.nav-label {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 14px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: 7px;
  color: var(--ink-2);
  text-align: left;
  transition: background-color .14s ease, color .14s ease;
}

.nav-item:hover { background: var(--bg-2); color: var(--ink); }
.nav-item.active { background: var(--blue-soft); color: var(--blue-ink); font-weight: 500; }
.nav-item svg { flex-shrink: 0; }

.side-foot {
  margin-top: auto;
  border-top: 1px solid var(--line-2);
  padding-top: 12px;
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
}

.who-avatar {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: var(--blue-soft);
  color: var(--blue-ink);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}

.who-name { font-size: 13px; font-weight: 500; line-height: 1.2; }

.main { flex: 1; min-width: 0; padding: 26px clamp(18px, 3vw, 34px) 60px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--blue-ink);
  margin-bottom: 5px;
}

h2.title {
  font-size: 1.6rem;
  font-weight: 500;
  letter-spacing: -0.025em;
  margin: 0;
}

.page-desc { color: var(--ink-2); font-size: 13.5px; margin: 3px 0 0; }

/* --------------------------------------------------------------- bits -- */

.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.card-pad { padding: 18px 20px; }

.card-head {
  padding: 15px 20px;
  border-bottom: 1px solid var(--line-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-head h3 { margin: 0; font-size: 1rem; font-weight: 500; letter-spacing: -0.01em; }
.card-head .hint { color: var(--ink-3); font-size: 12.5px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  transition: border-color .14s ease, background-color .14s ease, color .14s ease;
}

.btn:hover:not(:disabled) { border-color: var(--ink-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-ink); border-color: var(--blue-ink); }
.btn-danger { color: var(--danger); }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 6px;
}

.input, select.input {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  outline: none;
  transition: border-color .14s ease, box-shadow .14s ease;
}

.input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

select.input { appearance: none; background-image: none; padding-right: 30px; }

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.toolbar .input { width: auto; min-width: 150px; }
.toolbar .grow { flex: 1; min-width: 200px; }

/* -------------------------------------------------------------- stats -- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 17px;
}

.stat .k {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.stat .v {
  font-size: 1.85rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-top: 6px;
}

.stat .m { font-size: 12.5px; color: var(--ink-2); }

/* funnel: bars are real proportions, not decoration */
.funnel-row {
  display: grid;
  grid-template-columns: 148px 1fr 46px;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
}

.funnel-row .lbl { font-size: 13px; color: var(--ink-2); }

.funnel-track {
  height: 9px;
  background: var(--bg-2);
  border-radius: 5px;
  overflow: hidden;
}

.funnel-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 5px;
  transition: width .5s cubic-bezier(.22,1,.36,1);
}

.funnel-row .n {
  font-family: var(--mono);
  font-size: 13px;
  text-align: right;
}

.two-col {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 14px;
  align-items: start;
}

@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } }

.attn-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 20px;
  border-bottom: 1px solid var(--line-2);
  font-size: 13.5px;
}

.attn-item:last-child { border-bottom: none; }
.attn-group-label {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 12px 20px 5px;
}

/* ------------------------------------------------------------- tables -- */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--bg-2);
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfe; }

td.right, th.right { text-align: right; }
.cell-strong { font-weight: 500; }
.cell-sub { color: var(--ink-3); font-size: 12px; }

.pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 5px;
  background: var(--bg-2);
  color: var(--ink-2);
  white-space: nowrap;
}

.pill.ok { background: var(--success-soft); color: var(--success); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.accent { background: var(--blue-soft); color: var(--blue-ink); }

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13.5px;
}

.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* ------------------------------------------------------------- dialog -- */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 18, 0.42);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 60;
}

.backdrop.open { display: flex; }

.dialog {
  width: 100%;
  max-width: 440px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.dialog h3 { margin: 0; font-size: 1.05rem; font-weight: 500; letter-spacing: -0.01em; }
.dialog .dlg-head { padding: 18px 20px 0; }
.dialog .dlg-desc { color: var(--ink-2); font-size: 13px; margin: 5px 0 0; }
.dialog .dlg-body { padding: 18px 20px; }
.dialog .dlg-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line-2);
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  background: var(--bg-2);
}

.code-out {
  font-family: var(--mono);
  font-size: 16px;
  letter-spacing: 0.12em;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px 14px;
  text-align: center;
  user-select: all;
}

/* -------------------------------------------------------------- toast -- */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
}

.toast {
  background: var(--ink);
  color: #fff;
  border-radius: 7px;
  padding: 11px 15px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  max-width: 380px;
  animation: toastIn .22s cubic-bezier(.22,1,.36,1);
}

.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }

@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.err-line {
  color: var(--danger);
  font-size: 13px;
  margin: 0 0 12px;
  min-height: 18px;
}

/* ------------------------------------------------------------- mobile -- */

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 10px 12px;
    gap: 6px;
  }
  .brand { padding: 0 10px 0 4px; }
  .nav-label, .side-foot { display: none; }
  .nav-item { width: auto; white-space: nowrap; }
  .main { padding: 18px 16px 50px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
