/* Harbor — application layout + composed components. */

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; z-index: var(--z-nav);
  height: 100vh; padding: 20px 14px;
  display: flex; flex-direction: column; gap: 3px;
  background: var(--surface-1); border-inline-end: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 10px 20px; }
.brand img { width: 32px; height: 32px; border-radius: 8px; flex: none; }
.brand-name { font: 600 17px/1.15 var(--font-display); letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--ink-3); }

.nav-link {
  display: flex; align-items: center; gap: 11px;
  min-height: 40px; padding: 9px 12px; border-radius: var(--r-sm);
  font: 500 14px/1 var(--font-body); color: var(--ink-2);
  position: relative; cursor: pointer;
  transition: background 180ms, color 180ms;
}
.nav-link svg { width: 17px; height: 17px; flex: none; }
.nav-link:hover { background: var(--surface-2); color: var(--ink); }
.nav-link.active { background: var(--brand-soft); color: var(--brand-hover); font-weight: 600; }
.nav-link.active::before {
  content: ""; position: absolute; inset-inline-start: -14px; top: 9px; bottom: 9px;
  width: 3px; border-radius: 3px; background: var(--brand);
}
.sidebar-foot { margin-top: auto; padding: 10px 12px; font-size: 12px; color: var(--ink-3); }

/* ---------- Topbar ---------- */
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-nav);
  display: flex; align-items: center; gap: 14px;
  min-height: 60px; padding: 0 28px;
  background: rgba(0, 0, 0, 0.82); backdrop-filter: blur(12px);
  border-block-end: 1px solid var(--border);
}
.topbar .menu-btn { display: none; }
.topbar-title { font: 600 15px/1.2 var(--font-display); }
.topbar-status { margin-inline-start: auto; display: flex; align-items: center; gap: 12px; }
main { padding: 26px 28px 72px; max-width: 1240px; width: 100%; min-width: 0; }

/* ---------- KPI tiles ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; margin: 18px 0 8px; }
.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 3px; }
.kpi .kpi-label { display: flex; align-items: center; gap: 7px; font: 600 12px/1 var(--font-body); color: var(--ink-3); letter-spacing: 0.03em; text-transform: uppercase; }
.kpi .kpi-label svg { width: 14px; height: 14px; }
.kpi .kpi-value { font: 600 30px/1.15 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .kpi-sub { font-size: 12.5px; color: var(--ink-3); }
.kpi.kpi-danger .kpi-value { color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: start; padding: 11px 14px;
  font: 600 11.5px/1 var(--font-body); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-3); background: var(--surface-1); border-block-end: 1px solid var(--border-strong);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; border-block-end: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background 150ms; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
tbody tr:last-child td { border-block-end: none; }
th.ta-end, td.ta-end { text-align: end; }
td .row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 6px; }
.page-head .sub { color: var(--ink-3); font-size: 13.5px; margin-top: 3px; overflow-wrap: anywhere; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.section-title { margin: 30px 0 12px; display: flex; align-items: baseline; gap: 8px; }
.section-title .hint { font: 400 12px/1 var(--font-body); color: var(--ink-3); text-transform: none; letter-spacing: 0; }

/* ---------- Grids ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

/* ---------- Slot cards ---------- */
.slot { position: relative; padding: 16px 18px; transition: border-color 200ms; }
.slot.active { border-color: rgba(34, 197, 94, 0.45); }
.slot-head { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.slot-name { font: 700 12px/1 var(--font-display); letter-spacing: 0.1em; text-transform: uppercase; }
.slot-name.blue { color: var(--chart-1); }
.slot-name.green { color: var(--chart-2); }
.slot dl { display: grid; grid-template-columns: 86px 1fr; gap: 6px 10px; }
.slot dt { color: var(--ink-3); font-size: 12.5px; }
.slot dd { font-family: var(--font-mono); font-size: 12.5px; overflow-wrap: anywhere; }
.traffic-flag {
  position: absolute; inset-block-start: 14px; inset-inline-end: 16px;
  display: inline-flex; align-items: center; gap: 6px;
  font: 700 10.5px/1 var(--font-body); letter-spacing: 0.08em; color: var(--ok);
}
.traffic-flag::before { content: ""; width: 7px; height: 7px; border-radius: 999px; background: var(--ok); animation: pulse 1.6s ease-in-out infinite; }

/* ---------- Capacity bars ---------- */
.cap-bar { height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: 8px; }
.cap-bar > i { display: block; height: 100%; border-radius: 4px; background: var(--brand); transition: width 400ms ease; }
.cap-bar.warn > i { background: var(--warn); }
.cap-bar.danger > i { background: var(--danger); }

/* ---------- Console / logs ---------- */
.console {
  height: 320px; padding: 14px 16px; overflow: auto;
  background: #050506; border: 1px solid var(--border); border-radius: var(--r-lg);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.6;
  white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2);
}

/* ---------- Activity feed (timeline) ---------- */
.feed { position: relative; padding: 6px 0; }
.feed-item { position: relative; display: flex; gap: 13px; padding: 10px 18px; }
.feed-item + .feed-item { border-block-start: 1px solid var(--border); }
.feed-dot { flex: none; width: 8px; height: 8px; border-radius: 999px; margin-top: 7px; background: var(--ink-3); }
.feed-item.info .feed-dot { background: var(--brand); }
.feed-item.warn .feed-dot { background: var(--warn); }
.feed-item.error .feed-dot { background: var(--danger); }
.feed-body { min-width: 0; font-size: 13.5px; }
.feed-body time { display: block; color: var(--ink-3); font-size: 11.5px; font-variant-numeric: tabular-nums; margin-top: 1px; }

/* ---------- Run progress timeline ---------- */
.steps { display: flex; flex-direction: column; gap: 0; padding: 4px 0; }
.step { display: flex; align-items: flex-start; gap: 11px; position: relative; padding: 7px 0 7px 2px; }
.step::before {
  content: ""; position: absolute; inset-inline-start: 8px; top: 26px; bottom: -8px;
  width: 2px; background: var(--surface-3);
}
.step:last-child::before { display: none; }
.step-dot {
  flex: none; width: 14px; height: 14px; border-radius: 999px; margin-top: 3px;
  background: var(--ok-soft); border: 2px solid var(--ok); z-index: 1;
}
.step.current .step-dot { border-color: var(--warn); background: var(--warn-soft); animation: pulse 1.2s ease-in-out infinite; }
.step.failed .step-dot { border-color: var(--danger); background: var(--danger-soft); }
.step-body { font-size: 13.5px; }
.step-body time { display: block; color: var(--ink-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* ---------- Charts ---------- */
.chart-card { padding: 16px 18px; }
.chart-card h3 { color: var(--ink-2); font-size: 13px; margin-bottom: 10px; }
.chart-wrap { position: relative; }
.chart-tip {
  position: absolute; top: 0; z-index: 5; display: none; pointer-events: none;
  padding: 7px 10px; white-space: nowrap;
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  font-size: 12.5px; box-shadow: var(--shadow-2);
}
.legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }

/* ---------- Modals ---------- */
dialog {
  width: min(540px, calc(100vw - 32px));
  background: var(--surface-1); color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  padding: 24px 26px; margin: auto; box-shadow: var(--shadow-2);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.72); backdrop-filter: blur(3px); }
dialog h3 { font-size: 16px; margin-bottom: 4px; }
dialog .dlg-sub { color: var(--ink-3); font-size: 13px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------- Toasts ---------- */
.toast-root { position: fixed; inset-block-end: 18px; inset-inline-end: 18px; z-index: var(--z-toast); display: flex; flex-direction: column; gap: 9px; }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  max-width: 380px; padding: 13px 16px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-inline-start: 3px solid var(--brand); border-radius: var(--r-md);
  box-shadow: var(--shadow-2); font-size: 13.5px;
  animation: toast-in 220ms cubic-bezier(0.2, 0.9, 0.3, 1);
}
.toast.error { border-inline-start-color: var(--danger); }
.toast svg { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--brand); }
.toast.error svg { color: var(--danger); }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Login ---------- */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(360px, 100%); padding: 30px 30px 26px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 18px; text-align: center; }
.login-brand img { width: 52px; height: 52px; border-radius: 13px; }
.login-step { margin: 0; }

/* Segmented 6-digit OTP entry */
.otp-heading { text-align: center; font-size: 15px; margin-bottom: 4px; }
.otp-sub { text-align: center; font-size: 12.5px; margin-bottom: 16px; }
.otp-cells { display: flex; gap: 8px; justify-content: center; margin: 4px 0; }
.otp-cell {
  flex: 1 1 0; min-width: 0; max-width: 50px; height: 56px; padding: 0;
  text-align: center; font: 600 24px/1 var(--font-display);
  font-variant-numeric: tabular-nums; color: var(--ink);
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); transition: border-color 180ms;
}
.otp-cell:hover { border-color: rgba(255, 255, 255, 0.26); }
.otp-cell:focus { border-color: var(--brand); outline: 2px solid var(--brand); outline-offset: 1px; }
.otp-back { display: inline-block; font-size: 13px; }

/* On-screen numeric keypad — hidden by default; revealed only on fine-pointer
   (desktop) devices below, so touch devices keep the native numeric keyboard. */
.otp-keypad {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 16px 0 4px;
}
.otp-key {
  display: flex; align-items: center; justify-content: center;
  height: 46px; padding: 0;
  font: 600 18px/1 var(--font-display); font-variant-numeric: tabular-nums;
  color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  cursor: pointer; transition: background 150ms, border-color 150ms;
}
.otp-key:hover { background: var(--surface-3); border-color: rgba(255, 255, 255, 0.24); }
.otp-key:active { background: var(--brand-soft); border-color: var(--brand); }
.otp-key:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.otp-key[data-digit="0"] { grid-column: 2; }
.otp-key-back { color: var(--ink-2); font-size: 20px; }

@media (hover: hover) and (pointer: fine) {
  .otp-keypad { display: grid; }
}

@media (max-width: 400px) {
  .otp-cells { gap: 6px; }
  .otp-cell { height: 50px; font-size: 20px; }
}

/* ---------- View transitions ---------- */
.view-enter { animation: view-in 220ms ease-out; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Drawer backdrop (mobile) ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1);
  background: rgba(0, 0, 0, 0.6); opacity: 0; pointer-events: none; transition: opacity 200ms;
}

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: var(--z-drawer);
    width: 260px; transform: translateX(-102%); transition: transform 220ms ease;
    box-shadow: var(--shadow-2);
  }
  [dir='rtl'] .sidebar { transform: translateX(102%); }
  body.drawer-open .sidebar { transform: translateX(0); }
  body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
  .topbar { padding: 0 16px; }
  .topbar .menu-btn { display: inline-flex; }
  main { padding: 20px 16px 60px; }
  .grid-2 { grid-template-columns: 1fr; }
  table { min-width: 620px; }
  .kpi .kpi-value { font-size: 26px; }
}
