/* ============================================================
   MTR C1604 — Shared Engineering Design System
   Condensed, professional, data-dense
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Roboto+Mono:wght@400;500;600;700&display=swap');

:root {
  --c-primary:    #1a3a52;
  --c-dark:       #0f2537;
  --c-light:      #e8f4f8;
  --c-ai:         #00ff88;
  --c-success:    #10b981;
  --c-warning:    #f59e0b;
  --c-danger:     #e63946;
  --c-info:       #3b82f6;
  --c-purple:     #8b5cf6;
  --c-pink:       #ec4899;
  --c-teal:       #14b8a6;

  --c-bg:         #ffffff;
  --c-surface:    #f7fafc;
  --c-border:     #e2e8f0;
  --c-border-2:   #cbd5e0;
  --c-txt:        #2d3748;
  --c-txt2:       #718096;
  --c-txt3:       #a0aec0;

  --font:         'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:         'Roboto Mono', 'Consolas', monospace;

  --r-sm: 3px;  --r-md: 6px;  --r-lg: 10px;  --r-pill: 999px;

  --sh-sm: 0 1px 3px rgba(0,0,0,0.06);
  --sh-md: 0 4px 12px rgba(0,0,0,0.08);
  --sh-lg: 0 8px 24px rgba(0,0,0,0.12);

  --ease: all 0.18s ease;
  --ease-fast: all 0.12s ease;

  /* layout */
  --header-h: 56px;
  --topbar-h: 44px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
body { font-family: var(--font); font-size: 13px; color: var(--c-txt); background: var(--c-surface); min-height: 100vh; }
a { color: var(--c-info); text-decoration: none; }
a:hover { text-decoration: underline; }
table { border-collapse: collapse; width: 100%; }
button { cursor: pointer; border: none; background: none; font: inherit; }
img, svg { display: block; max-width: 100%; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--c-surface); }
::-webkit-scrollbar-thumb { background: var(--c-border-2); border-radius: 3px; }

/* ── Header ── */
.hdr {
  height: var(--header-h);
  background: var(--c-primary);
  display: flex; align-items: center;
  padding: 0 20px; gap: 12px;
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.hdr-logo { height: 32px; flex-shrink: 0; }
.hdr-sep { width: 1px; height: 28px; background: rgba(255,255,255,0.12); flex-shrink: 0; }
.hdr-title {
  font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.9);
  letter-spacing: -0.1px; line-height: 1.2;
}
.hdr-sub { font-size: 10px; color: rgba(255,255,255,0.4); margin-top: 1px; letter-spacing: 0.2px; }
.hdr-space { flex: 1; }
.hdr-meta { display: flex; align-items: center; gap: 10px; }
.hdr-clock {
  font-family: var(--mono); font-size: 11px; color: rgba(255,255,255,0.45);
  display: flex; flex-direction: column; align-items: flex-end; gap: 1px; line-height: 1.2;
}
.hdr-clock-date { color: rgba(255,255,255,0.6); }

.live-pill {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 9px; background: rgba(0,255,136,0.12);
  border: 1px solid rgba(0,255,136,0.25); border-radius: var(--r-pill);
  font-size: 9px; font-weight: 700; color: var(--c-ai);
  text-transform: uppercase; letter-spacing: 0.8px;
}
.live-dot { width: 5px; height: 5px; background: var(--c-ai); border-radius: 50%; animation: blink 1.4s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.25} }

.hdr-btn {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.6);
  display: flex; align-items: center; justify-content: center;
  transition: var(--ease-fast); position: relative;
}
.hdr-btn:hover { background: rgba(255,255,255,0.14); color: #fff; }
.hdr-btn svg { width: 15px; height: 15px; }
.hdr-notif-dot {
  position: absolute; top: -2px; right: -2px;
  width: 12px; height: 12px; background: var(--c-danger);
  border-radius: 50%; font-size: 8px; font-weight: 700; color: #fff;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--c-primary);
}
.hdr-user {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 8px 3px 4px;
  background: rgba(255,255,255,0.08); border-radius: var(--r-pill);
}
.hdr-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--c-info); color: #fff;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.hdr-uname { font-size: 11px; color: rgba(255,255,255,0.8); font-weight: 500; }

/* ── Top Bar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  display: flex; align-items: center;
  padding: 0 20px; gap: 10px;
}
.breadcrumb {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--c-txt2);
}
.breadcrumb svg { width: 11px; height: 11px; stroke: var(--c-txt3); }
.breadcrumb-link { cursor: pointer; }
.breadcrumb-link:hover { color: var(--c-primary); }
.breadcrumb-cur { color: var(--c-primary); font-weight: 600; }
.tb-space { flex: 1; }
.tb-actions { display: flex; align-items: center; gap: 6px; }

.filter-grp {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--c-txt2); font-weight: 500;
}

/* ── Inputs ── */
.sel {
  padding: 4px 24px 4px 8px;
  border: 1px solid var(--c-border); border-radius: var(--r-sm);
  background: var(--c-bg); color: var(--c-txt);
  font-size: 11px; font-weight: 500; font-family: var(--font);
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23718096' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center;
  transition: var(--ease-fast);
}
.sel:focus { outline: none; border-color: var(--c-info); box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }

.sel-sm { padding: 3px 20px 3px 6px; font-size: 10px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: var(--r-sm);
  font-size: 11px; font-weight: 600; font-family: var(--font);
  border: 1px solid transparent; transition: var(--ease-fast);
  white-space: nowrap; cursor: pointer;
}
.btn svg { width: 12px; height: 12px; }

.btn-primary   { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn-primary:hover { background: var(--c-dark); }
.btn-secondary { background: var(--c-bg); color: var(--c-txt); border-color: var(--c-border); }
.btn-secondary:hover { background: var(--c-surface); border-color: var(--c-border-2); }
.btn-success   { background: var(--c-success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger    { background: var(--c-danger); color: #fff; }
.btn-danger:hover { background: #c0313d; }
.btn-ai { background: linear-gradient(135deg, var(--c-ai), #00d97e); color: #065f46; border-color: var(--c-ai); }
.btn-ai:hover { box-shadow: 0 0 10px rgba(0,255,136,0.35); }

.btn-ghost {
  width: 28px; height: 28px; padding: 0;
  border: 1px solid var(--c-border); background: var(--c-bg);
  border-radius: var(--r-sm); color: var(--c-txt2);
  display: flex; align-items: center; justify-content: center;
  transition: var(--ease-fast);
}
.btn-ghost svg { width: 13px; height: 13px; }
.btn-ghost:hover { background: var(--c-light); color: var(--c-primary); border-color: var(--c-light); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 7px; border-radius: var(--r-pill);
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap;
}
.bdot { width: 4px; height: 4px; border-radius: 50%; flex-shrink: 0; }
.badge-ok  { background: #d1fae5; color: #065f46; } .badge-ok  .bdot { background: #10b981; }
.badge-rev { background: #dbeafe; color: #1e40af; } .badge-rev .bdot { background: #3b82f6; }
.badge-pnd { background: #fef3c7; color: #92400e; } .badge-pnd .bdot { background: #f59e0b; }
.badge-rej { background: #fee2e2; color: #991b1b; } .badge-rej .bdot { background: #e63946; }
.badge-dft { background: #f1f5f9; color: #475569; } .badge-dft .bdot { background: #94a3b8; }
.ai-badge  {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; background: linear-gradient(135deg,#00ff88,#00d97e);
  border-radius: var(--r-pill); font-size: 9px; font-weight: 700; color: #065f46;
  text-transform: uppercase; letter-spacing: 0.4px;
}

/* ── KPI Card ── */
.kpi {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  box-shadow: var(--sh-sm);
  transition: var(--ease);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 4px;
}
.kpi::after {
  content: ''; position: absolute;
  left: 0; top: 0; bottom: 0; width: 3px;
  border-radius: 2px 0 0 2px;
}
.kpi:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
.kpi.c-info::after    { background: var(--c-info); }
.kpi.c-success::after { background: var(--c-success); }
.kpi.c-warning::after { background: var(--c-warning); }
.kpi.c-danger::after  { background: var(--c-danger); }
.kpi.c-ai::after      { background: var(--c-ai); }
.kpi.c-purple::after  { background: var(--c-purple); }

.kpi-hd { display: flex; justify-content: space-between; align-items: flex-start; }
.kpi-lbl { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--c-txt2); }
.kpi-icon svg { width: 16px; height: 16px; stroke: var(--c-txt3); }
.kpi-val { font-size: 26px; font-weight: 700; font-family: var(--mono); color: var(--c-primary); line-height: 1; }
.kpi-val.xl  { font-size: 32px; }
.kpi-val.sm  { font-size: 20px; }
.kpi-chg {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 600;
}
.kpi-chg svg { width: 11px; height: 11px; }
.pos { color: var(--c-success); } .neg { color: var(--c-danger); } .neu { color: var(--c-txt2); }
.kpi-meta { font-size: 10px; color: var(--c-txt2); }
.kpi-foot { margin-top: 4px; }

/* ── Progress ── */
.prog { width: 100%; height: 4px; background: var(--c-border); border-radius: var(--r-pill); overflow: hidden; }
.prog-fill { height: 100%; border-radius: var(--r-pill); transition: width 0.5s ease; }
.prog-fill.grad  { background: linear-gradient(90deg, var(--c-primary), var(--c-info)); }
.prog-fill.ok    { background: var(--c-success); }
.prog-fill.warn  { background: var(--c-warning); }
.prog-fill.err   { background: var(--c-danger); }
.prog-fill.ai    { background: linear-gradient(90deg, var(--c-ai), var(--c-success)); }
.prog-md { height: 6px; }
.prog-lg { height: 8px; }

/* ── Chart Card ── */
.chart-card {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
  display: flex; flex-direction: column; overflow: hidden;
}
.cc-hd {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 12px 16px; border-bottom: 1px solid var(--c-border);
}
.cc-title { font-size: 12px; font-weight: 600; color: var(--c-txt); }
.cc-sub   { font-size: 10px; color: var(--c-txt2); margin-top: 1px; }
.cc-acts  { display: flex; align-items: center; gap: 6px; }
.cc-body  { padding: 14px 16px; flex: 1; position: relative; }
.cc-body.no-pad { padding: 0; }
.cc-foot  { padding: 8px 16px; border-top: 1px solid var(--c-border); background: var(--c-surface); }

/* ── Table Card ── */
.tbl-card {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm); overflow: hidden;
}
.tbl-hd {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--c-border);
  flex-wrap: wrap; gap: 8px;
}
.tbl-title { font-size: 12px; font-weight: 600; color: var(--c-txt); }
.tbl-sub   { font-size: 10px; color: var(--c-txt2); margin-top: 1px; }
.tbl-acts  { display: flex; align-items: center; gap: 6px; }

.srch {
  position: relative; display: flex; align-items: center;
}
.srch svg {
  position: absolute; left: 8px; width: 12px; height: 12px;
  stroke: var(--c-txt3); pointer-events: none;
}
.srch input {
  padding: 4px 8px 4px 26px;
  border: 1px solid var(--c-border); border-radius: var(--r-sm);
  font-size: 11px; color: var(--c-txt); background: var(--c-surface);
  width: 180px; transition: var(--ease-fast); font-family: var(--font);
}
.srch input:focus {
  outline: none; border-color: var(--c-info); background: var(--c-bg);
  width: 220px; box-shadow: 0 0 0 2px rgba(59,130,246,0.12);
}
.srch input::placeholder { color: var(--c-txt3); }

/* Data table */
.dtbl thead { background: var(--c-primary); color: #fff; }
.dtbl th {
  padding: 8px 12px; font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  text-align: left; white-space: nowrap; cursor: pointer; user-select: none;
}
.dtbl th:hover { background: var(--c-dark); }
.dtbl th svg { width: 10px; height: 10px; display: inline; vertical-align: middle; margin-left: 2px; opacity: 0.4; }
.dtbl tbody tr { border-bottom: 1px solid var(--c-border); transition: var(--ease-fast); }
.dtbl tbody tr:nth-child(even) { background: var(--c-surface); }
.dtbl tbody tr:hover { background: var(--c-light); }
.dtbl td { padding: 8px 12px; font-size: 11px; color: var(--c-txt); vertical-align: middle; }
.dtbl td.mono { font-family: var(--mono); font-size: 10px; }

.tbl-ft {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 16px; border-top: 1px solid var(--c-border); background: var(--c-surface);
}
.pg { display: flex; align-items: center; gap: 6px; }
.pg-btn {
  width: 26px; height: 26px;
  border: 1px solid var(--c-border); border-radius: var(--r-sm);
  background: var(--c-bg); display: flex; align-items: center; justify-content: center;
  color: var(--c-txt); transition: var(--ease-fast); cursor: pointer;
}
.pg-btn svg { width: 12px; height: 12px; }
.pg-btn:hover:not(:disabled) { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.pg-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.pg-info { font-size: 10px; color: var(--c-txt2); }

/* ── Discipline tags ── */
.dtag {
  display: inline-block; padding: 1px 6px; border-radius: var(--r-sm);
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
}
.dt-arch  { background: #ede9fe; color: #5b21b6; }
.dt-str   { background: #fef3c7; color: #92400e; }
.dt-mepm  { background: #dbeafe; color: #1e40af; }
.dt-mepe  { background: #fce7f3; color: #9d174d; }
.dt-civil { background: #d1fae5; color: #065f46; }
.dt-fire  { background: #fee2e2; color: #991b1b; }

/* ── SLA chips ── */
.sla-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 7px; border-radius: var(--r-pill);
  font-size: 9px; font-weight: 700; font-family: var(--mono);
}
.sla-ok   { background: #d1fae5; color: #065f46; }
.sla-risk { background: #fef3c7; color: #92400e; }
.sla-over { background: #fee2e2; color: #991b1b; }

/* ── Validation chip ── */
.val-chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 600;
}
.val-chip svg { width: 11px; height: 11px; }
.v-ok   { color: var(--c-success); }
.v-fail { color: var(--c-danger); }
.v-warn { color: var(--c-warning); }

/* ── Modal ── */
.modal {
  display: none; position: fixed; inset: 0;
  z-index: 500; align-items: center; justify-content: center; padding: 20px;
}
.modal.open { display: flex; }
.modal-ov {
  position: absolute; inset: 0;
  background: rgba(15,37,55,0.6); backdrop-filter: blur(4px);
}
.modal-box {
  position: relative; background: var(--c-bg);
  border-radius: var(--r-lg); box-shadow: var(--sh-lg);
  width: 100%; max-width: 600px; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  animation: mIn 0.18s ease;
}
.modal-box.lg { max-width: 720px; }
@keyframes mIn { from { opacity:0; transform: scale(0.97) translateY(6px); } to { opacity:1; transform: none; } }

.modal-hd {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--c-border);
  background: var(--c-primary); color: #fff; flex-shrink: 0;
}
.modal-title { font-size: 13px; font-weight: 700; color: #fff; }
.modal-sub   { font-size: 10px; color: rgba(255,255,255,0.5); margin-top: 1px; }
.modal-close {
  width: 26px; height: 26px; border-radius: var(--r-sm);
  background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.7);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--ease-fast);
}
.modal-close:hover { background: rgba(255,255,255,0.2); }
.modal-close svg { width: 14px; height: 14px; }
.modal-body { padding: 16px; overflow-y: auto; flex: 1; }
.modal-ft {
  display: flex; justify-content: flex-end; align-items: center; gap: 8px;
  padding: 10px 16px; border-top: 1px solid var(--c-border); background: var(--c-surface);
  flex-shrink: 0;
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 900;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--c-txt); color: #fff;
  border-radius: var(--r-md); box-shadow: var(--sh-lg);
  font-size: 12px; font-weight: 500;
  transform: translateY(60px); opacity: 0;
  transition: all 0.25s ease; pointer-events: none; max-width: 320px;
}
.toast svg { width: 14px; height: 14px; flex-shrink: 0; }
.toast.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
.toast.ok svg   { stroke: var(--c-ai); }
.toast.err svg  { stroke: var(--c-danger); }

/* ── Skeleton ── */
.skel {
  background: linear-gradient(90deg,#f7fafc 0%,#e2e8f0 50%,#f7fafc 100%);
  background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: var(--r-sm);
}
@keyframes shimmer { 0%{background-position:-200% 0} 100%{background-position:200% 0} }

/* ── Spin ── */
.spin { animation: spinR 0.7s linear infinite; }
@keyframes spinR { to { transform: rotate(360deg); } }

/* ── Section header ── */
.sec-hd {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.sec-title { font-size: 13px; font-weight: 700; color: var(--c-primary); }
.sec-sub   { font-size: 10px; color: var(--c-txt2); margin-top: 2px; }
.sec-acts  { display: flex; align-items: center; gap: 6px; }

/* ── Divider ── */
.dvd { height: 1px; background: var(--c-border); margin: 12px 0; }

/* ── Layout ── */
.main-wrap { max-width: 1440px; margin: 0 auto; padding: 16px 20px; }
.section-gap { margin-bottom: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; }
.grid-84 { display: grid; grid-template-columns: 8fr 4fr; gap: 12px; }
.grid-63 { display: grid; grid-template-columns: 6fr 3fr; gap: 12px; }

@media (max-width: 1279px) {
  .grid-4 { grid-template-columns: repeat(2,1fr); }
  .grid-84, .grid-63 { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .hdr { padding: 0 12px; }
  .main-wrap { padding: 12px; }
}

/* ── Utility ── */
.flex      { display: flex; }
.flex-col  { flex-direction: column; }
.items-c   { align-items: center; }
.j-between { justify-content: space-between; }
.gap-4  { gap: 4px; }  .gap-6 { gap: 6px; } .gap-8 { gap: 8px; }
.gap-10 { gap: 10px; } .gap-12 { gap: 12px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mono  { font-family: var(--mono); }
.txt2  { color: var(--c-txt2); }
.txt3  { color: var(--c-txt3); }
.fw6   { font-weight: 600; }
.fw7   { font-weight: 700; }
.fs9   { font-size: 9px; }
.fs10  { font-size: 10px; }
.fs11  { font-size: 11px; }
.fs12  { font-size: 12px; }
.w100  { width: 100%; }
