/* ═══════════════════════════════════════════════════════════
   IMS v2 — BuildMart93
   Industrial palette: dark navy sidebar, rust-orange accent
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Sidebar */
  --sb-bg:          #131e2b;
  --sb-border:      #1e2d3d;
  --sb-text:        #7d95ac;
  --sb-text-hover:  #dce8f2;
  --sb-section:     #3d5570;
  --sb-active-bg:   rgba(230, 92, 30, 0.1);
  --sb-active-text: #e65c1e;
  --sb-active-bar:  #e65c1e;
  --sb-footer:      #0d1721;
  --sb-width:       240px;

  /* Main */
  --bg:          #f2f4f7;
  --card:        #ffffff;
  --card-border: #e1e7ef;
  --shadow:      0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.1);

  /* Text */
  --text:        #18232f;
  --text-2:      #4a6278;
  --text-3:      #8299af;

  /* Accent */
  --blue:        #2563eb;
  --blue-hover:  #1d4ed8;
  --blue-light:  #eff6ff;
  --green:       #16a34a;
  --green-light: #f0fdf4;
  --red:         #dc2626;
  --red-light:   #fef2f2;
  --orange:      #e65c1e;
  --orange-light:#fff4ee;
  --amber:       #d97706;
  --amber-light: #fffbeb;

  /* Form */
  --border:      #dde3ec;
  --input-bd:    #c8d3e0;
  --radius:      6px;
  --radius-lg:   10px;
}

/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Layout ─────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────── */
.sidebar {
  width: var(--sb-width);
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--sb-border);
}
.sidebar-brand .brand-name {
  font-size: 15px;
  font-weight: 700;
  color: #e2ecf5;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.sidebar-brand .brand-sub {
  font-size: 11px;
  color: var(--sb-text);
  margin-top: 2px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 0;
  list-style: none;
}

.nav-section {
  padding: 14px 20px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sb-section);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sb-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
  border-left: 3px solid transparent;
  text-decoration: none;
}
.sidebar-nav a:hover {
  color: var(--sb-text-hover);
  background: rgba(255,255,255,0.04);
  text-decoration: none;
}
.sidebar-nav a.active {
  color: var(--sb-active-text);
  background: var(--sb-active-bg);
  border-left-color: var(--sb-active-bar);
}
.sidebar-nav a .nav-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--sb-border);
  background: var(--sb-footer);
}
.sidebar-footer .user-name {
  font-size: 13px;
  font-weight: 600;
  color: #c8daea;
}
.sidebar-footer .user-level {
  font-size: 11px;
  color: var(--sb-text);
  margin-top: 2px;
}
.sidebar-footer .logout-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--sb-text);
  text-decoration: none;
}
.sidebar-footer .logout-link:hover { color: var(--red); text-decoration: none; }

/* ── Main content ───────────────────────────────── */
.main {
  margin-left: var(--sb-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}
.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.topbar-right {
  font-size: 13px;
  color: var(--text-2);
}

.content {
  padding: 24px 28px;
  flex: 1;
}

/* ── Cards ──────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.card-body { padding: 20px; }

/* ── Stat cards ─────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.stat-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 6px;
}
.stat-card.blue  .stat-value { color: var(--blue); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.orange .stat-value { color: var(--orange); }
.stat-card.red .stat-value { color: var(--red); }

/* ── Tables ─────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
thead th {
  background: #f7f9fc;
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-2);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f3f7;
  vertical-align: middle;
  color: var(--text);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: 'Courier New', monospace; font-size: 12.5px; }

/* ── Forms ──────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 5px;
}
input[type=text], input[type=number], input[type=date],
input[type=email], input[type=password], select, textarea {
  width: 100%;
  padding: 8px 11px;
  font-size: 14px;
  border: 1px solid var(--input-bd);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
input[readonly] { background: #f7f9fc; color: var(--text-3); cursor: not-allowed; }
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

/* ── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-primary  { background: var(--blue);  color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); text-decoration: none; color:#fff;}
.btn-success  { background: var(--green); color: #fff; border-color: var(--green); }
.btn-success:hover { background: #15803d; text-decoration: none; color:#fff; }
.btn-danger   { background: var(--red);   color: #fff; border-color: var(--red); }
.btn-danger:hover  { background: #b91c1c; text-decoration: none; color:#fff; }
.btn-secondary {
  background: #fff; color: var(--text-2);
  border-color: var(--border);
}
.btn-secondary:hover { background: #f7f9fc; color: var(--text); text-decoration: none; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }

/* ── Badges ─────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-blue   { background: var(--blue-light);   color: var(--blue); }
.badge-green  { background: var(--green-light);  color: var(--green); }
.badge-red    { background: var(--red-light);    color: var(--red); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-amber  { background: var(--amber-light);  color: var(--amber); }
.badge-gray   { background: #f1f5f9; color: var(--text-2); }

/* ── Alerts ─────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: var(--green-light); color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: var(--red-light);   color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--amber-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: var(--blue-light);  color: #1e40af; border: 1px solid #bfdbfe; }

/* ── Misc helpers ───────────────────────────────── */
.page-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.spacer { flex: 1; }

.text-muted { color: var(--text-3); }
.text-sm    { font-size: 12.5px; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* ── Login page ─────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--sb-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box {
  width: 100%;
  max-width: 380px;
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand .name {
  font-size: 22px;
  font-weight: 800;
  color: #e2ecf5;
  letter-spacing: 0.02em;
}
.login-brand .sub {
  font-size: 12px;
  color: var(--sb-text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
}
.login-card {
  background: #1c2d3e;
  border: 1px solid #253647;
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.4);
}
.login-card label { color: #8fa3ba; }
.login-card input {
  background: #0f1c29;
  border-color: #2a3f55;
  color: #e2ecf5;
}
.login-card input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(230, 92, 30, 0.15);
}
.login-card .btn-primary {
  width: 100%;
  justify-content: center;
  padding: 10px;
  background: var(--orange);
  border-color: var(--orange);
  font-size: 15px;
  margin-top: 4px;
}
.login-card .btn-primary:hover {
  background: #cf511a;
  border-color: #cf511a;
}
