/* Single design-token source for the portal. Tailwind (loaded via CDN in
   base.html) handles layout utilities (flex/grid/spacing-in-context); this
   file owns visual identity — color, type, radius, shadow — so every page
   draws from the same palette instead of ad hoc per-template choices. */

:root {
  /* Brand / primary accent */
  --color-primary: #0f766e;       /* teal-700 */
  --color-primary-hover: #0d5f58;
  --color-primary-soft: #ccfbf1;  /* teal-100, for subtle highlights */

  /* Neutrals */
  --color-bg: #f8fafc;            /* slate-50 */
  --color-surface: #ffffff;
  --color-border: #e2e8f0;        /* slate-200 */
  --color-text: #0f172a;          /* slate-900 */
  --color-text-muted: #64748b;    /* slate-500 */

  /* Semantic states (reconciliation statuses, form feedback) */
  --color-success: #15803d;
  --color-success-bg: #dcfce7;
  --color-warning: #b45309;
  --color-warning-bg: #fef3c7;
  --color-error: #b91c1c;
  --color-error-bg: #fee2e2;
  --color-info: #1d4ed8;
  --color-info-bg: #dbeafe;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  /* Radius & shadow */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.08);

  /* Type scale */
  --text-h1: 24px;
  --text-h2: 20px;
  --text-h3: 16px;
  --text-body: 15px;
  --text-sm: 13px;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-size: var(--text-body);
}

h1, .h1 { font-size: var(--text-h1); font-weight: 500; color: var(--color-text); }
h2, .h2 { font-size: var(--text-h2); font-weight: 500; color: var(--color-text); }
h3, .h3 { font-size: var(--text-h3); font-weight: 500; color: var(--color-text); }
.text-muted { color: var(--color-text-muted); }
.text-small { font-size: var(--text-sm); }

/* Surfaces */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.topbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  min-height: 44px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background: var(--color-primary);
  color: #ffffff;
}
.btn-primary:hover { background: var(--color-primary-hover); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-secondary:hover { background: var(--color-bg); }

.btn-danger {
  background: var(--color-surface);
  color: var(--color-error);
  border-color: var(--color-border);
}
.btn-danger:hover { background: var(--color-error-bg); }

/* Deliberately short of the 44px guideline: these are dense, adjacent
   table-row actions (View/Edit/Remove) where full-size buttons would blow
   up row height across every list view. 40px is the compromise. */
.btn-sm { min-height: 40px; padding: 8px 12px; }

/* Form controls */
.field-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: var(--space-1);
}

.input, select.input, textarea.input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: var(--text-body);
  background: var(--color-surface);
  color: var(--color-text);
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
  border-color: var(--color-primary);
}

.checkbox-row { display: flex; align-items: center; gap: var(--space-2); min-height: 44px; }
.checkbox-row input[type="checkbox"] { width: 18px; height: 18px; }

.form-error { color: var(--color-error); font-size: var(--text-sm); margin-top: var(--space-1); }

/* Badges (reconciliation / status states) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-sm);
  font-weight: 500;
  padding: 2px 10px;
  border-radius: 999px;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-error { background: var(--color-error-bg); color: var(--color-error); }
.badge-info { background: var(--color-info-bg); color: var(--color-info); }
.badge-neutral { background: var(--color-border); color: var(--color-text-muted); }

/* Tables */
.table-modern { width: 100%; font-size: var(--text-body); border-collapse: collapse; }
.table-modern thead th {
  text-align: left;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-bg);
  padding: var(--space-3) var(--space-3);
  white-space: nowrap;
}
.table-modern tbody td {
  padding: var(--space-3) var(--space-3);
  border-top: 1px solid var(--color-border);
  vertical-align: middle;
}
.table-modern tbody tr:hover { background: var(--color-bg); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Empty / loading / error states */
.state-panel {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--color-text-muted);
}
.state-panel .state-icon { margin: 0 auto var(--space-3); opacity: 0.5; }
.state-panel-error { color: var(--color-error); }

/* Nav */
.nav-link { color: var(--color-text-muted); font-size: var(--text-sm); font-weight: 500; }
.nav-link:hover, .nav-link.active { color: var(--color-text); }

/* Icons (inline SVG, single consistent stroke-based set — see icons.html) */
.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }

/* Contextual help (see static/js/help.js) */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  min-height: 0;
  border-radius: 999px;
  background: var(--color-border);
  color: var(--color-text-muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  border: none;
  cursor: pointer;
  vertical-align: middle;
  margin-left: 4px;
  padding: 0;
}
.help-icon:hover { background: var(--color-primary); color: #fff; }
.help-bubble {
  position: absolute;
  z-index: 60;
  max-width: 260px;
  background: var(--color-text);
  color: #fff;
  font-size: var(--text-sm);
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

@media (max-width: 767px) {
  .btn { width: 100%; }
  .btn-inline { width: auto; }
}
