/* Tito — global tokens, resets, shared primitives (btn, field, modal, empty state, responsive) */

:root {
  --bg: #F5F1EA;
  --bg-card: #FFFFFF;
  --bg-soft: #EFE9DC;
  --bg-warm: #F9F5EE;
  --ink: #1C1B1A;
  --ink-soft: #3D3A36;
  --muted: #6B6864;
  --muted-soft: #9C9893;
  --border: #E5E0D6;
  --border-soft: #EDE8DC;
  --accent: #C45C3D;
  --accent-deep: #A04A30;
  --accent-soft: #F4E2D8;
  --green: #1F4D3F;
  --green-soft: #DFE8E2;
  --amber: #B8862B;
  --amber-soft: #F5EDD5;
  --red: #B0463A;
  --red-soft: #F4DEDA;
  --shadow-sm: 0 1px 2px rgba(28,27,26,0.04);
  --shadow: 0 4px 12px rgba(28,27,26,0.06);
  --shadow-lg: 0 12px 32px rgba(28,27,26,0.08);
  --serif: 'Fraunces', Georgia, serif;
  --sans: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ---- Form fields ---- */
.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(28,27,26,0.06);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--ink);
  color: var(--bg);
  width: 100%;
}

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

.btn-accent {
  background: var(--accent);
  color: white;
}

.btn-accent:hover { background: var(--accent-deep); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--bg-soft); }

.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-icon { padding: 8px; }

/* ---- Tags (used in tables, lists, status indicators) ---- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag-green { background: var(--green-soft); color: var(--green); }
.tag-amber { background: var(--amber-soft); color: var(--amber); }
.tag-accent { background: var(--accent-soft); color: var(--accent-deep); }
.tag-muted { background: var(--bg-soft); color: var(--muted); }

/* ---- Page show/hide ---- */
.page-content { display: none; }
.page-content.active { display: block; }

/* ---- Generic visibility utility ---- */
.hidden { display: none !important; }

/* ---- Modal ---- */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(28,27,26,0.4);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal-bg.active { display: flex; }

.modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-head {
  padding: 24px 28px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-head h3 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.modal-head p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.modal-body { padding: 24px 28px; }

.modal-foot {
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--bg-warm);
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--muted);
}

.empty-state i {
  font-size: 48px;
  color: var(--muted-soft);
  margin-bottom: 16px;
  display: block;
}

.empty-state h4 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 8px;
}

.empty-state p { font-size: 14px; max-width: 340px; margin: 0 auto 20px; }

/* ---- Responsive ---- */
@media (max-width: 1200px) {
  .auth-screen { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .sim-grid { grid-template-columns: 1fr; height: auto; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid, .detail-grid { grid-template-columns: 1fr; }
}
