/* =============================================================================
   Catalyst Handling Information System — Modern UI
   Clean industrial-tech aesthetic · refined navy · soft surfaces · clear hierarchy
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Core palette */
  --navy: #1e3a5f;
  --navy-dark: #152a45;
  --navy-mid: #2a4a6e;
  --navy-light: #3d5f8a;
  --accent: #0d9488;          /* teal */
  --accent-soft: #ccfbf1;
  --accent-dark: #0f766e;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --green: #16a34a;
  --green-soft: #dcfce7;

  /* Surfaces */
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  /* Text */
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #f8fafc;

  /* Chart series (accessible categorical) */
  --series-blue: #3b82f6;
  --series-orange: #f97316;
  --series-teal: #14b8a6;
  --series-yellow: #eab308;
  --series-magenta: #ec4899;
  --series-red: #ef4444;
  --chart-grid: #e2e8f0;
  --chart-muted: #94a3b8;

  /* Layout tokens */
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 10px 20px -4px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
  --transition: 160ms cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--navy);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--accent-dark); }

h1 {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 0.25rem;
  letter-spacing: -0.025em;
}
h2 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--navy);
  margin: 0 0 0.75rem;
  letter-spacing: -0.01em;
}
.muted {
  color: var(--text-muted);
  margin-top: 0;
  font-size: 0.875rem;
}

/* ---------------------------------------------------------------- topbar */
.topbar {
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 100%);
  color: var(--text-inverse);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06), var(--shadow);
}
.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  min-height: 58px;
}
.brand {
  color: #fff;
  font-weight: 600;
  font-size: 0.9375rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; color: #fff; opacity: 0.95; }
.brand-logo {
  background: #fff;
  border-radius: 8px;
  padding: 5px 9px;
  display: flex;
  align-items: center;
  line-height: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.brand-logo img { display: block; height: 26px; width: auto; }
.brand-text { white-space: nowrap; }
@media (max-width: 720px) { .brand-text { display: none; } }

.mainnav {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  flex: 1;
}
.mainnav a {
  color: rgba(255,255,255,0.78);
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.mainnav a:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  text-decoration: none;
}
.mainnav a.nav-restricted { color: #fca5a5; }
.mainnav a.nav-restricted:hover {
  background: rgba(220, 38, 38, 0.25);
  color: #fff;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.75);
  white-space: nowrap;
}
.topbar-user a {
  color: rgba(255,255,255,0.75);
  font-weight: 500;
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.15);
  transition: all var(--transition);
}
.topbar-user a:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
  text-decoration: none;
  border-color: rgba(255,255,255,0.25);
}
.role-pill {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: rgba(255,255,255,0.15);
  margin-left: 0.35rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------- layout */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}
.sitefooter {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 1.5rem 1rem 2rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

/* ---------------------------------------------------------------- flash */
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid transparent;
}
.flash-success {
  background: var(--green-soft);
  color: #166534;
  border-color: #bbf7d0;
}
.flash-error {
  background: var(--red-soft);
  color: #991b1b;
  border-color: #fecaca;
}
.flash-info {
  background: #e0f2fe;
  color: #075985;
  border-color: #bae6fd;
}

/* ---------------------------------------------------------------- KPI cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin: 1.25rem 0 1.75rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--navy), var(--accent));
  opacity: 0.85;
}
.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.stat-card-restricted {
  border-left: none;
}
.stat-card-restricted::before {
  background: linear-gradient(90deg, var(--red), #f87171);
}
.stat-num {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.stat-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 0.35rem;
  line-height: 1.35;
}

/* ---------------------------------------------------------------- panels & layout helpers */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.15rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 860px) {
  .two-col { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.panel-warn {
  border-left: 4px solid var(--amber);
  background: linear-gradient(to right, var(--amber-soft), var(--surface) 12%);
}
.panel-warn h2 { color: #92400e; }

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  background: var(--surface-2);
  color: var(--navy);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.95rem;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.3;
}
.btn:hover {
  background: #e2e8f0;
  border-color: var(--border-strong);
  text-decoration: none;
  color: var(--navy);
}
.btn-primary {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
  box-shadow: 0 1px 2px rgba(30, 58, 95, 0.25);
}
.btn-primary:hover {
  background: var(--navy-dark);
  border-color: var(--navy-dark);
  color: #fff;
}
.btn-danger {
  background: var(--red-soft);
  color: #991b1b;
  border-color: #fecaca;
}
.btn-danger:hover {
  background: #fecaca;
  color: #7f1d1d;
}
.btn-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-accent:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #fff;
}
.btn-block { display: flex; width: 100%; text-align: center; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.75rem; }

/* ---------------------------------------------------------------- tables */
table.mini-table,
table.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8125rem;
}
table.mini-table th,
table.mini-table td,
table.data-table th,
table.data-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
  text-align: left;
  vertical-align: top;
}
table.mini-table th:first-child,
table.mini-table td:first-child,
table.data-table th:first-child,
table.data-table td:first-child { padding-left: 0.9rem; }
table.mini-table th:last-child,
table.mini-table td:last-child,
table.data-table th:last-child,
table.data-table td:last-child { padding-right: 0.9rem; }

table.data-table th {
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: none;
}
table.data-table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
table.data-table th:last-child { border-radius: 0 var(--radius-sm) 0 0; }
table.data-table tbody tr {
  background: var(--surface);
  transition: background var(--transition);
}
table.data-table tbody tr:nth-child(even) { background: var(--surface-2); }
table.data-table tbody tr:hover { background: #e0f2fe; }
table.data-table tbody tr:last-child td:first-child { border-radius: 0 0 0 var(--radius-sm); }
table.data-table tbody tr:last-child td:last-child { border-radius: 0 0 var(--radius-sm) 0; }

.cell-auto { background: #f1f5f9; color: var(--text-muted); }
.cell-example { background: var(--green-soft); }
.badge-yes { color: var(--green); font-weight: 600; }
.badge-no { color: var(--text-muted); }
.badge-check { color: var(--red); font-weight: 600; }

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* ---------------------------------------------------------------- forms */
form.stack label {
  display: block;
  margin-bottom: 0.9rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}
form.stack label span.req { color: var(--red); }

input[type=text],
input[type=date],
input[type=number],
input[type=password],
select,
textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  margin-top: 0.3rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}
input[readonly],
select[disabled] {
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: not-allowed;
}
textarea { min-height: 80px; resize: vertical; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.25rem 1.15rem;
}
.form-actions {
  margin-top: 1.35rem;
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 0 1.25rem;
  padding: 1.1rem 1.15rem;
  background: var(--surface);
}
legend {
  color: var(--navy);
  font-weight: 600;
  padding: 0 0.5rem;
  font-size: 0.875rem;
}

/* ---------------------------------------------------------------- misc */
.section-band {
  background: linear-gradient(90deg, var(--navy), var(--navy-mid));
  color: #fff;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
}
.filter-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
  align-items: end;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.filter-bar label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}
.filter-bar select,
.filter-bar input { margin-top: 0.2rem; min-width: 140px; }

.legend-key {
  display: flex;
  gap: 1.15rem;
  margin: 0.75rem 0 1.25rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.legend-key span.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  vertical-align: -1px;
  margin-right: 0.35rem;
}

/* ---------------------------------------------------------------- login */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(13, 148, 136, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(30, 58, 95, 0.15) 0%, transparent 50%),
    linear-gradient(160deg, var(--navy-dark) 0%, var(--navy) 50%, #0f2744 100%);
  padding: 1.5rem;
}
.login-box {
  background: var(--surface);
  padding: 2.25rem 2rem;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.08);
}
.login-logo {
  display: block;
  max-width: 200px;
  height: auto;
  margin: 0 auto 1.35rem;
}
.login-box h1 {
  font-size: 1.2rem;
  text-align: center;
  margin-bottom: 0.25rem;
}
.login-sub {
  color: var(--text-muted);
  font-size: 0.8125rem;
  margin-top: 0;
  margin-bottom: 1.5rem;
  text-align: center;
}
.login-box form label { margin-bottom: 1rem; }
.login-box .btn-primary {
  margin-top: 0.5rem;
  padding: 0.7rem 1rem;
  font-size: 0.875rem;
}

/* ---------------------------------------------------------------- dashboard charts */
.chart-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 1.15rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 960px) {
  .chart-grid { grid-template-columns: 1fr; }
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition);
}
.chart-card:hover { box-shadow: var(--shadow); }
.chart-card-head {
  padding: 1.1rem 1.2rem 0;
}
.chart-card-head h2 { margin-bottom: 0.15rem; }
.chart-card-sub {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
}
.chart-card-body {
  padding: 0.75rem 1.2rem 1.2rem;
  flex: 1;
}
.chart-wrap {
  position: relative;
  width: 100%;
  height: 260px;
}
.chart-empty {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 2.5rem 0;
  text-align: center;
}
.chart-table-toggle { margin-top: 0.65rem; }
.chart-table-toggle summary {
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--navy);
  font-weight: 600;
  user-select: none;
}
.chart-table-toggle summary:hover { color: var(--accent-dark); }
.chart-table-toggle table { margin-top: 0.65rem; }

/* ---------------------------------------------------------------- page header strip */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}
.page-header .muted { margin-bottom: 0; }

/* ---------------------------------------------------------------- attention list */
.attention-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.attention-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.attention-list li:last-child { border-bottom: none; }
.attention-list a { font-weight: 500; }

/* ---------------------------------------------------------------- utility */
.text-sm { font-size: 0.8125rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-0 { margin-bottom: 0; }
.gap-sm { gap: 0.5rem; }

/* Scrollbar polish */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
