/* Stitch / Structure Enterprise — design tokens & base (identity: DESIGN.md)
   Rules: No-Line (tonal surfaces, no borders/shadows on cards), one accent
   (#0056D2, ≤15% of any screen), Manrope headings + Inter body. */

:root {
  --brand-primary: #0056D2;
  --brand-primary-hover: #0047AE;
  --brand-tint: #E8F0FE;
  --brand-navy: #16294B;   /* from the ARMS product art — used as a deep neutral, not a second accent */
  --brand-gold: #C9A54A;   /* the art's brass — sparing brand echoes only (data-amber stays for charts) */
  --ink: #111827;
  --ink-muted: #6B7280;
  --surface-base: #FFFFFF;
  --surface-raised: #F8F9FA;
  --surface-sunken: #F1F3F5;
  --amber: #F59E0B;          /* data-encoding exception (manual series), not a UI accent */
  --danger: #B42318;
  --radius: 10px;
  --font-display: 'Manrope', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--surface-raised);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; color: var(--brand-navy); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 0.75rem; }

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

/* ---- Sidebar: light, per the Sextant reference ---- */

.sidebar {
  width: 230px;
  background: var(--surface-base);
  display: flex;
  flex-direction: column;
  padding: 1.1rem 0.9rem;
}

.sidebar-brand { display: flex; align-items: center; gap: 0.6rem; margin: 0.2rem 0 1.8rem 0.3rem; }

.brand-icon {
  display: inline-flex;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--brand-primary);
  color: #FFFFFF;
  align-items: center;
  justify-content: center;
}

.brand-icon img { width: 24px; height: 24px; object-fit: contain; }

.brand-word {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.14em;
  font-size: 0.95rem;
  color: var(--brand-navy);
}

.sidebar-section {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--ink-muted);
  margin: 0 0 0.4rem 0.75rem;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }

.sidebar-nav a {
  color: var(--ink);
  text-decoration: none;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-weight: 500;
}

.sidebar-nav a:hover { background: var(--surface-raised); }

.sidebar-nav a.active { background: var(--brand-tint); color: var(--brand-primary); }

/* Multi-level nav groups (native <details> — no JS dependency) */
.nav-group summary {
  list-style: none;
  cursor: pointer;
  color: var(--ink);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-group summary::-webkit-details-marker { display: none; }

.nav-group summary::after {
  content: "›";
  color: var(--ink-muted);
  transition: transform 0.15s;
}

.nav-group[open] summary::after { transform: rotate(90deg); }

.nav-group summary:hover { background: var(--surface-raised); }

.nav-group .nav-child {
  display: block;
  padding: 0.4rem 0.75rem 0.4rem 1.6rem;
  font-size: 0.92em;
}

.sidebar-logout { margin-top: auto; }

/* ---- Topbar ---- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-base);
  padding: 0.65rem 2rem;
}

.topbar-title { font-family: var(--font-display); font-weight: 700; }

.topbar-right { display: flex; align-items: center; gap: 1.25rem; font-size: 0.85rem; }

.topbar-lang { display: flex; align-items: center; gap: 0.4rem; color: var(--ink-muted); }

.topbar-lang select {
  border: none;
  background: var(--surface-sunken);
  border-radius: 7px;
  padding: 0.25rem 0.5rem;
  font: inherit;
  color: var(--ink);
}

.lang-apply {
  border: none;
  background: var(--surface-sunken);
  border-radius: 7px;
  padding: 0.25rem 0.5rem;
  font: inherit;
  cursor: pointer;
}

.topbar-user { color: var(--ink-muted); }

/* Topbar dropdown (model catalog) — floating element, shadow allowed */
.topbar-menu { position: relative; }

.topbar-menu summary {
  list-style: none;
  cursor: pointer;
  color: var(--ink-muted);
  padding: 0.25rem 0.6rem;
  border-radius: 7px;
  background: var(--surface-sunken);
  font-size: 0.85rem;
}

.topbar-menu summary::-webkit-details-marker { display: none; }

.topbar-dropdown {
  position: absolute;
  right: 0;
  top: 2.2rem;
  width: 340px;
  background: var(--surface-base);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(17, 24, 39, 0.12);
  padding: 1rem 1.1rem;
  z-index: 50;
}

.model-item { padding: 0.45rem 0; font-size: 0.85rem; }
.model-item + .model-item { border-top: 1px solid var(--surface-sunken); }
.topbar-user strong { color: var(--ink); font-weight: 600; }

.topbar-context { color: var(--ink-muted); font-family: var(--font-body); font-weight: 500; font-size: 0.85rem; margin-left: 0.35rem; }

/* ---- Tela Padrão zones (DESIGN.md) ---- */
/* Zones 9/10: Explorer-like light command bar under the topbar (white chrome
   band over the raised content — tonal containment, No-Line). */

.actionbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 2rem;
  background: var(--surface-base);
}

.actionbar-left, .actionbar-right { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
.actionbar .inline-form { margin: 0; }

/* Zone 11: bar between input and results */
.midbar { display: flex; align-items: center; gap: 0.9rem; margin: 0 0 1rem; }

/* Zones 15/16: sys_comm right panel + quick input */
.syscomm {
  width: 290px;
  flex-shrink: 0;
  background: var(--surface-base);
  padding: 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.syscomm-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.syscomm .flash { margin: 0; }
.sysinput { margin-top: auto; }

/* ---- Main / content ---- */

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.content-row { flex: 1; display: flex; align-items: stretch; min-width: 0; }

.content { flex: 1; padding: 1.75rem 2rem; max-width: 1160px; width: 100%; margin: 0 auto; min-width: 0; }

.footer-status { text-align: center; }

.footer {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 2rem;
  color: var(--ink-muted);
  font-size: 0.8rem;
}

/* No-Line rule: containment by tonal shift, never borders or box-shadows. */
.card {
  background: var(--surface-base);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

.stat { flex: 1; min-width: 160px; margin-bottom: 0; }

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
}

.stat-value { font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; color: var(--brand-navy); }

/* ---- Forms ---- */

.field-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin: 0.75rem 0 0.25rem;
}

.input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: none;
  border-radius: var(--radius);
  background: var(--surface-sunken);
  font: inherit;
  color: var(--ink);
}

.input:focus { outline: 2px solid var(--brand-primary); }

.btn-primary {
  margin-top: 1rem;
  padding: 0.55rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  background: var(--brand-primary);
  color: #FFFFFF;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover { background: var(--brand-primary-hover); }

.btn-block { display: block; width: 100%; }

.btn-danger {
  margin-top: 0.75rem;
  padding: 0.55rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  background: var(--danger);
  color: #FFFFFF;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-quiet-dark {
  background: none;
  border: none;
  color: var(--ink-muted);
  font: inherit;
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.btn-quiet-dark:hover { color: var(--ink); }

.flash { border-radius: var(--radius); padding: 0.6rem 1rem; margin-bottom: 1rem; }
.flash-info { background: var(--brand-tint); color: var(--brand-primary); }
.flash-error { background: #FEE4E2; color: var(--danger); }

.muted { color: var(--ink-muted); }

/* Small info chips (field origins, counters) */
.chip {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  vertical-align: middle;
}

.chip-core { background: var(--brand-tint); color: var(--brand-primary); }
.chip-upload { background: #FEF3E2; color: #B45309; }
.chip-ui { background: #E7F6EC; color: #067647; }
.chip-muted { background: var(--surface-sunken); color: var(--ink-muted); }

.btn-cart {
  border: none;
  background: var(--brand-tint);
  color: var(--brand-primary);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 7px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}

.btn-cart:hover { background: #D8E6FC; }

.delta-up { color: #067647; font-weight: 600; }
.delta-down { color: var(--danger); font-weight: 600; }

.req { color: var(--brand-primary); }

/* ---- Tables ---- */

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

.table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  padding: 0.5rem 0.75rem;
}

.table td { padding: 0.6rem 0.75rem; background: var(--surface-base); }

.table tbody tr:nth-child(even) td { background: var(--surface-raised); }

.inline-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form > div { flex: 1; min-width: 180px; }

/* ---- Login: right-aligned panel, no card (reference identity) ---- */

.login-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 88vh;
  background: var(--brand-navy);
  border-radius: var(--radius);
  padding: 3rem 6vw;
  gap: 3rem;
}

.login-art { flex: 1; display: flex; justify-content: center; }

.login-art img {
  max-height: 72vh;
  max-width: 100%;
  border-radius: var(--radius);
  /* Soft gold halo ties the panel to the artwork (subliminal, not decorative noise) */
  box-shadow: 0 0 80px rgba(201, 165, 74, 0.18);
}

.login-panel {
  width: 400px;
  flex-shrink: 0;
  background: var(--surface-base);
  border-radius: var(--radius);
  padding: 2.5rem 2.25rem;
}

@media (max-width: 900px) { .login-art { display: none; } }

.login-wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2rem;
  color: var(--brand-primary);
  text-align: center;
}

.login-tagline {
  text-align: center;
  color: var(--ink-muted);
  margin-bottom: 2.2rem;
  padding-bottom: 0.9rem;
  /* the art's brass, one quiet line */
  background: linear-gradient(var(--brand-gold), var(--brand-gold)) bottom center / 56px 2px no-repeat;
}

.login-label { display: block; font-weight: 600; margin: 1rem 0 0.3rem; }
