/* AcmeOps Operations OS — design tokens + components */

:root {
  /* Brand */
  --brand: #1F3A8A;
  --brand-soft: #EEF2FB;
  --brand-strong: #0E1F5C;

  /* Neutrals */
  --ink-1: #0E1116;
  --ink-2: #1F2937;
  --ink-3: #4B5563;
  --ink-4: #6B7280;
  --ink-5: #9CA3AF;

  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --surface-3: #F1F3F6;

  --line: #E5E7EB;
  --line-strong: #D1D5DB;

  /* Status */
  --ok: #117A4B;
  --ok-soft: #E6F3EC;
  --warn: #B45309;
  --warn-soft: #FEF3C7;
  --danger: #B91C1C;
  --danger-soft: #FCE7E7;
  --info: #1E40AF;
  --info-soft: #E0E7FF;

  /* Shape */
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(14,17,22,.04), 0 1px 1px rgba(14,17,22,.03);
  --shadow: 0 1px 3px rgba(14,17,22,.06), 0 1px 2px rgba(14,17,22,.04);
  --shadow-lg: 0 12px 32px rgba(14,17,22,.12), 0 4px 8px rgba(14,17,22,.06);

  /* Type */
  --font: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;

  /* Density */
  --row-h: 38px;
  --pad-y: 10px;
  --pad-x: 14px;
}

[data-density="compact"] {
  --row-h: 32px;
  --pad-y: 7px;
  --pad-x: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); }
body {
  font-family: var(--font);
  font-size: 13px;
  color: var(--ink-2);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }
table { border-collapse: collapse; width: 100%; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: auto 1fr;
  height: 100vh;
  background: var(--bg);
}

/* Sidebar */
.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  transition: width .15s ease;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -.02em;
  flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 14px; color: var(--ink-1); letter-spacing: -.01em; line-height: 1.1; }
.brand-tag { font-size: 10.5px; color: var(--ink-4); text-transform: uppercase; letter-spacing: .05em; margin-top: 1px; }

.nav-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-5);
  padding: 4px 8px;
  margin-bottom: 2px;
  font-weight: 500;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--ink-3);
  cursor: pointer;
  margin-bottom: 1px;
  transition: background .08s, color .08s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink-2); }
.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 500;
}
.nav-item.active svg { color: var(--brand); }
.nav-count {
  font-size: 10.5px;
  background: var(--surface-3);
  color: var(--ink-3);
  padding: 1px 6px;
  border-radius: 9px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}
.nav-item.active .nav-count { background: var(--brand); color: #fff; }

/* Main area */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 52px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 14px;
  flex-shrink: 0;
}
.search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink-4);
  font-size: 12.5px;
  cursor: pointer;
  width: 320px;
}
.search-btn:hover { border-color: var(--line-strong); }
.search-btn span:first-of-type { flex: 1; text-align: left; }

.kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 5px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-4);
  box-shadow: 0 1px 0 var(--line);
}

.content {
  flex: 1;
  overflow: auto;
  padding: 18px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 5px;
  height: 30px;
  padding: 0 11px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  white-space: nowrap;
  transition: background .08s, border-color .08s;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.icon { padding: 0; width: 30px; }
.btn.icon.sm { width: 26px; }
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-3);
}
.btn.ghost:hover { background: var(--surface-2); color: var(--ink-2); }

/* Segmented */
.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 2px;
  gap: 0;
}
.seg button {
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--ink-3);
  border-radius: 5px;
  font-weight: 500;
  height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.seg button:hover { color: var(--ink-2); }
.seg button.on {
  background: #fff;
  color: var(--ink-1);
  box-shadow: var(--shadow-sm);
}

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  gap: 10px;
}
.card-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -.005em;
}
.card-head h3 .sub { font-weight: 400; color: var(--ink-4); font-size: 12px; margin-left: 4px; }
.card-body { padding: 14px; }
.card-body.tight { padding: 0; }

/* ---------- Layout helpers ---------- */
.vstack { display: flex; flex-direction: column; }
.hstack { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; }
.muted { color: var(--ink-4); }
.divider { height: 1px; background: var(--line); margin: 4px 0; }

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.kpi { padding: 14px 16px; background: #fff; }
.kpi .lab {
  font-size: 11px;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
}
.kpi .val {
  font-size: 26px;
  font-weight: 600;
  color: var(--ink-1);
  margin: 6px 0 4px;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.kpi .delta {
  font-size: 11.5px;
  color: var(--ok);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}
.kpi .delta.neg { color: var(--danger); }
.kpi .delta .arr { font-size: 9px; }

/* ---------- Pills, tags, dots ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 19px;
  padding: 0 8px;
  font-size: 10.5px;
  font-weight: 500;
  border-radius: 9px;
  white-space: nowrap;
  letter-spacing: .01em;
}
.pill.outline { background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--line); }
.pill.brand   { background: var(--brand-soft); color: var(--brand); }
.pill.ok      { background: var(--ok-soft); color: var(--ok); }
.pill.warn    { background: var(--warn-soft); color: var(--warn); }
.pill.danger  { background: var(--danger-soft); color: var(--danger); }
.pill .pip { width: 5px; height: 5px; border-radius: 3px; background: currentColor; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink-3);
  font-weight: 500;
}

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 5px; background: var(--ink-5); }
.dot.ok   { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.info { background: var(--brand); }

/* ---------- Tables ---------- */
.tbl { width: 100%; }
.tbl thead th {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink-4);
  font-weight: 500;
  text-align: left;
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.tbl thead th.num { text-align: right; }
.tbl tbody td {
  padding: var(--pad-y) 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-2);
  vertical-align: middle;
}
.tbl tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr.row-clickable { cursor: pointer; transition: background .06s; }
.tbl tbody tr.row-clickable:hover { background: var(--surface-2); }

/* Progress */
.progress {
  width: 100%;
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: 3px;
  transition: width .25s;
}
.progress.ok > span    { background: var(--ok); }
.progress.warn > span  { background: var(--warn); }
.progress.brand > span { background: var(--brand); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  padding: 0 18px;
  background: #fff;
  gap: 2px;
  flex-shrink: 0;
}
.tab {
  padding: 11px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-4);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color .08s, border-color .08s;
  margin-bottom: -1px;
}
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-count {
  font-size: 10px;
  background: var(--surface-3);
  color: var(--ink-3);
  padding: 0 6px;
  border-radius: 9px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.tab.active .tab-count { background: var(--brand-soft); color: var(--brand); }

/* ---------- Drawer ---------- */
.drawer-back {
  position: fixed; inset: 0;
  background: rgba(14,17,22,.32);
  z-index: 50;
  display: flex;
  justify-content: flex-end;
  animation: fade .15s ease;
}
.drawer {
  width: min(86vw, 1180px);
  height: 100%;
  background: #fff;
  display: flex;
  flex-direction: column;
  box-shadow: -16px 0 32px rgba(14,17,22,.18);
  animation: slide .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0;
  background: rgba(14,17,22,.42);
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade .12s ease;
}
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: pop .2s cubic-bezier(.2,.8,.2,1);
}
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--ink-1); letter-spacing: -.01em; }
.modal-body { padding: 18px; overflow: auto; flex: 1; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
  font-size: 11px;
  color: var(--ink-4);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 500;
}
.input, .select {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 12.5px;
  color: var(--ink-2);
  outline: none;
  transition: border-color .08s, box-shadow .08s;
}
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input-readonly { background: var(--surface-2); color: var(--ink-3); }
.textarea {
  min-height: 80px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 12.5px;
  color: var(--ink-2);
  outline: none;
  resize: vertical;
  font-family: var(--font);
}
.textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- Avatars ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #5C7BC2 0%, #2E4A99 100%);
  color: #fff;
  font-weight: 600;
  letter-spacing: .01em;
  flex-shrink: 0;
}

/* ---------- Country flag chip ---------- */
.flag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 500;
}
.flag-chip .flag {
  display: inline-block;
  width: 16px; height: 11px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,.06);
  background-size: cover;
  background-position: center;
}

/* ---------- Activity feed ---------- */
.feed { padding: 4px 0; }
.feed-row {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  font-size: 12.5px;
  color: var(--ink-3);
  position: relative;
}
.feed-row strong { color: var(--ink-2); font-weight: 500; }
.feed-icon {
  width: 24px; height: 24px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  flex-shrink: 0;
}
.feed-row .when { font-size: 11px; color: var(--ink-5); white-space: nowrap; }

/* ---------- Stepper ---------- */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
}
.step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--ink-4);
  white-space: nowrap;
}
.step .dot {
  width: 22px; height: 22px;
  border-radius: 12px;
  background: #fff;
  border: 1.5px solid var(--line-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-4);
}
.step.active { color: var(--ink-1); font-weight: 600; }
.step.active .dot { border-color: var(--brand); background: var(--brand); color: #fff; }
.step.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.done { color: var(--ink-3); }
.bar {
  flex: 1;
  height: 1.5px;
  background: var(--line-strong);
  margin: 0 6px;
}

/* ---------- Dropzone ---------- */
.dropzone {
  border: 2px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
  text-align: center;
  color: var(--ink-3);
  font-size: 12.5px;
  transition: all .12s;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.dropzone.is-active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.dropzone .big {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 4px;
}
.dropzone:hover .big, .dropzone.is-active .big { color: var(--brand); }

/* ---------- Product thumb (placeholder) ---------- */
.thumb {
  background: linear-gradient(135deg, #DDE3EE 0%, #BFC9D9 100%);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(14,17,22,.35);
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,.04);
  position: relative;
  overflow: hidden;
}
