/* ============================================================================
   Amparo OS — Shared stylesheet
   Used by every page in /web. Locked palette, components, layout primitives.
   Edit one file, change every dashboard. Don't introduce new colors or
   component types — extend in HANDOFF.md first, then update this file.
   ========================================================================== */

:root {
  /* Core palette */
  --navy:    #1A2E4A;
  --navy-d:  #0F1D33;
  --bronze:  #8B6F47;
  --bronze-l:#A88761;
  --cream:   #F4F1ED;
  --bg:      #FAF9F6;
  --bg-gray: #F1F0EB;
  --surface: #FFFFFF;
  --border:  #D8D4CC;
  --border-l:#E8E5DE;
  --ink:     #1A1A1A;
  --text-2:  #5A5A5A;
  --text-3:  #8A8A8A;

  /* Status pill tones (soft-bg + dark-text pairs) */
  --red-bg:    #FCEBEB; --red-tx:    #791F1F;
  --amber-bg:  #FAEEDA; --amber-tx:  #633806;
  --green-bg:  #EAF3DE; --green-tx:  #27500A;
  --blue-bg:   #E6F1FB; --blue-tx:   #0C447C;
  --purple-bg: #EEEDFE; --purple-tx: #3C3489;
  --teal-bg:   #E1F5EE; --teal-tx:   #085041;
  --gray-bg:   #F1EFE8; --gray-tx:   #444441;

  /* Layout tokens */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-pill: 12px;
  --shadow-none: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  display: flex;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--bronze); }

/* ===== Sidebar (60px navy rail with 7 dashboard icons) ===== */
.sidebar {
  width: 60px;
  background: var(--navy);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
}
.side-logo {
  color: var(--bronze);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1.5px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  margin-bottom: 24px;
  transform: rotate(180deg);
}
.side-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  color: #A5B5C5;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border: 1px solid transparent;
  position: relative;
}
.side-icon:hover { background: var(--navy-d); color: white; }
.side-icon.active { background: var(--bronze); color: white; }
.side-icon[data-label]::after {
  content: attr(data-label);
  position: absolute;
  left: 100%;
  margin-left: 12px;
  white-space: nowrap;
  background: var(--ink);
  color: white;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--r-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 100;
  font-weight: 500;
  letter-spacing: 0;
}
.side-icon:hover[data-label]::after { opacity: 1; }

.side-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
}

/* ===== Main shell ===== */
.shell { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* Topbar (navy, brand left, user right) */
.topbar {
  background: var(--navy);
  border-bottom: 1px solid var(--navy-d);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { font-size: 18px; font-weight: 700; color: white; letter-spacing: 2px; }
.brand-tag {
  font-size: 11px;
  color: #A5B5C5;
  font-style: italic;
  border-left: 1px solid #3a4d6a;
  padding-left: 14px;
}
.user { display: flex; align-items: center; gap: 12px; font-size: 12px; color: #A5B5C5; }
.user .logout {
  background: transparent;
  border: 1px solid #3a4d6a;
  color: #A5B5C5;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-size: 11px;
  margin-left: 10px;
}
.user .logout:hover { color: white; border-color: var(--bronze); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bronze);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

/* Stage = main scroll region under topbar */
.stage { padding: 24px 28px; flex: 1; min-width: 0; }

.view-title { font-size: 22px; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.view-sub { font-size: 12px; color: var(--text-3); margin-bottom: 20px; }

/* ===== KPI tiles ===== */
.kpi-row { display: grid; gap: 12px; margin-bottom: 20px; }
.kpi-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-row.cols-5 { grid-template-columns: repeat(5, 1fr); }
.kpi-tile {
  background: var(--surface);
  border: 1px solid var(--border-l);
  border-radius: var(--r-lg);
  padding: 18px;
  min-height: 90px;
}
.kpi-label {
  font-size: 11px;
  color: var(--text-2);
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.kpi-val {
  font-size: 26px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.1;
}
.kpi-val.red    { color: var(--red-tx); }
.kpi-val.amber  { color: var(--amber-tx); }
.kpi-val.green  { color: var(--green-tx); }
.kpi-val.muted  { color: var(--text-3); }
.kpi-trend { font-size: 11px; color: var(--text-3); margin-top: 8px; }

/* ===== Layout grids ===== */
.grid-2     { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2-eq  { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3     { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }

/* ===== Card chrome ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border-l);
  border-radius: var(--r-lg);
  padding: 16px 18px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-l);
  gap: 10px;
}
.card-head-t { font-size: 13px; font-weight: 600; color: var(--ink); }
.card-head-s { font-size: 11px; color: var(--text-3); }

/* ===== Status pills ===== */
.pill {
  font-size: 10px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-weight: 600;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  display: inline-block;
}
.pill-red    { background: var(--red-bg);    color: var(--red-tx); }
.pill-amber  { background: var(--amber-bg);  color: var(--amber-tx); }
.pill-green  { background: var(--green-bg);  color: var(--green-tx); }
.pill-blue   { background: var(--blue-bg);   color: var(--blue-tx); }
.pill-purple { background: var(--purple-bg); color: var(--purple-tx); }
.pill-teal   { background: var(--teal-bg);   color: var(--teal-tx); }
.pill-gray   { background: var(--gray-bg);   color: var(--gray-tx); }

/* ===== Tables ===== */
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th {
  text-align: left;
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-l);
  background: var(--bg-gray);
  position: sticky;
  top: 0;
}
.tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-l);
  color: var(--ink);
  vertical-align: middle;
}
.tbl tr:hover td { background: var(--cream); cursor: pointer; }
.tbl tr.selected td { background: var(--cream); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .caption { font-weight: 600; color: var(--ink); }
.tbl .meta { font-size: 10px; color: var(--text-3); margin-top: 2px; }
.tbl .empty {
  text-align: center;
  color: var(--text-3);
  font-style: italic;
  padding: 32px;
}

/* Wrapper for scrollable table inside card */
.tbl-wrap { overflow-x: auto; }

/* ===== Buttons ===== */
.btn {
  background: var(--bronze);
  color: white;
  border: 1px solid var(--bronze);
  padding: 9px 16px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2px;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--bronze-l); border-color: var(--bronze-l); }
.btn:disabled, .btn[disabled] { background: var(--gray-bg); border-color: var(--border); color: var(--text-3); cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--navy);
  border: 1px solid var(--bronze);
  padding: 9px 16px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
}
.btn-secondary:hover { background: var(--cream); }

.btn-danger {
  background: transparent;
  color: var(--red-tx);
  border: 1px solid transparent;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 500;
}
.btn-danger:hover { background: var(--red-bg); border-color: var(--red-tx); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--r-sm);
  font-size: 11px;
}
.btn-ghost:hover { background: var(--cream); color: var(--ink); }

/* ===== Action strip (navy bar, primary CTA right) ===== */
.action-strip {
  background: var(--navy);
  color: white;
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-radius: var(--r-lg);
  margin-bottom: 16px;
}
.action-strip-label { font-size: 12px; color: #C5D2E0; font-weight: 500; }
.action-strip-label strong { color: white; margin-right: 4px; }
.action-strip .btn { padding: 8px 18px; }

/* ===== Banner (notice across top of view) ===== */
.banner {
  padding: 10px 18px;
  border-radius: var(--r-lg);
  margin-bottom: 16px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}
.banner-amber { background: var(--amber-bg); color: var(--amber-tx); border: 1px solid var(--amber-tx); border-color: rgba(99,56,6,0.2); }
.banner-blue  { background: var(--blue-bg);  color: var(--blue-tx); }
.banner-red   { background: var(--red-bg);   color: var(--red-tx); }

/* ===== Agent rows ===== */
.agent-list { display: flex; flex-direction: column; gap: 6px; }
.agent-row {
  background: var(--bg-gray);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  transition: background 0.12s;
}
.agent-row:hover { background: var(--border-l); }
.agent-icon {
  width: 32px; height: 32px;
  background: var(--bronze);
  color: white;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  font-weight: 600;
}
.agent-icon.coming { background: var(--gray-bg); color: var(--text-3); }
.agent-text { flex: 1; min-width: 0; }
.agent-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.agent-sub { font-size: 11px; color: var(--text-2); margin-top: 2px; line-height: 1.35; }
.agent-action { margin-left: auto; }

/* ===== Meta strip ===== */
.meta-strip {
  background: var(--surface);
  border: 1px solid var(--border-l);
  border-radius: var(--r-lg);
  padding: 12px 16px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.meta-cell { display: flex; flex-direction: column; gap: 2px; }
.meta-label {
  font-size: 10px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}
.meta-value { font-size: 12px; color: var(--ink); font-weight: 500; }

/* ===== Form inputs ===== */
.input, textarea.input, select.input {
  background: var(--surface);
  border: 1px solid var(--border-l);
  border-radius: var(--r-md);
  padding: 9px 12px;
  font-size: 13px;
  color: var(--ink);
  font-family: inherit;
  width: 100%;
  transition: border-color 0.15s;
}
.input:focus, textarea.input:focus, select.input:focus {
  outline: none;
  border-color: var(--navy);
}
textarea.input { resize: vertical; min-height: 80px; line-height: 1.5; }
.input-label {
  font-size: 11px;
  color: var(--text-2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
  display: block;
}
.input-group { margin-bottom: 12px; }

/* ===== Modal ===== */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(26, 46, 74, 0.4);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  width: 600px;
  max-width: 92vw;
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-l);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border-l);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg);
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-3);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--ink); }

/* ===== Markdown rendering (memo / brief output) ===== */
.md { font-size: 12.5px; line-height: 1.65; color: var(--ink); }
.md h1, .md h2, .md h3 { color: var(--navy); margin: 14px 0 6px; }
.md h1 { font-size: 16px; font-weight: 700; }
.md h2 { font-size: 14px; font-weight: 600; }
.md h3 { font-size: 13px; font-weight: 600; }
.md p, .md ul, .md ol { margin-bottom: 10px; color: var(--text-2); }
.md ul, .md ol { margin-left: 22px; }
.md li { margin-bottom: 4px; }
.md strong { color: var(--ink); }
.md code { background: var(--bg-gray); padding: 1px 5px; border-radius: 3px; font-size: 90%; }
.md blockquote { border-left: 3px solid var(--bronze); padding-left: 12px; color: var(--text-2); margin: 10px 0; font-style: italic; }

/* ===== Toast (top-right notification) ===== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--ink);
  color: white;
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--green-tx); }
.toast.warn    { background: var(--amber-tx); }
.toast.error   { background: var(--red-tx); }

/* ===== Loading state ===== */
.loading {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--bronze);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--bg-gray) 25%, var(--border-l) 50%, var(--bg-gray) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: var(--r-sm);
  display: inline-block;
  min-height: 14px;
  min-width: 40px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ===== Footer ===== */
.footer {
  padding: 24px 32px;
  text-align: center;
  color: var(--text-3);
  font-size: 10px;
  border-top: 1px solid var(--border-l);
  margin-top: 24px;
}

/* ===== Responsive (basic) ===== */
@media (max-width: 1100px) {
  .kpi-row.cols-4, .kpi-row.cols-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-2-eq, .grid-3 { grid-template-columns: 1fr; }
}
