/* ── TQ Design System ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=DM+Sans:wght@400;500;600&display=swap');

:root {
  --brand:        #0052CC;
  --brand-hover:  #0065FF;
  --brand-light:  #DEEBFF;
  --brand-dark:   #003884;

  --success:      #36B37E;
  --success-bg:   #E3FCEF;
  --danger:       #DE350B;
  --danger-bg:    #FFEBE6;
  --warning:      #FF8B00;
  --warning-bg:   #FFFAE6;
  --info:         #0065FF;
  --info-bg:      #E6F0FF;

  --text-primary:   #172B4D;
  --text-secondary: #5E6C84;
  --text-muted:     #97A0AF;
  --text-inverse:   #FFFFFF;

  --bg-page:     #F4F5F7;
  --bg-card:     #FFFFFF;
  --bg-sidebar:  #0747A6;
  --bg-navbar:   #0052CC;

  --border:      #DFE1E6;
  --border-focus:#4C9AFF;
  --radius-sm:   4px;
  --radius:      6px;
  --radius-lg:   10px;

  --shadow-sm: 0 1px 2px rgba(9,30,66,.13);
  --shadow:    0 3px 8px rgba(9,30,66,.16);
  --shadow-lg: 0 6px 20px rgba(9,30,66,.20);

  --sidebar-w: 240px;
  --navbar-h:  52px;

  --font-base: 'Inter', system-ui, sans-serif;
  --font-head: 'DM Sans', system-ui, sans-serif;
}

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

html { font-size: 14px; }
body {
  font-family: var(--font-base);
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
}

/* ── Navbar ── */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--navbar-h);
  background: var(--bg-navbar);
  display: flex; align-items: center; padding: 0 16px;
  gap: 12px; box-shadow: var(--shadow);
}
.navbar-brand {
  font-family: var(--font-head);
  font-weight: 700; font-size: 18px;
  color: #fff; text-decoration: none; letter-spacing: -0.5px;
  display: flex; align-items: center; gap: 8px;
}
.navbar-brand .brand-icon {
  width: 28px; height: 28px; background: rgba(255,255,255,.2);
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.navbar-spacer { flex: 1; }
.navbar-user {
  display: flex; align-items: center; gap: 8px;
  color: rgba(255,255,255,.85); font-size: 13px;
}
.navbar-user .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.2); display: flex; align-items: center;
  justify-content: center; font-weight: 600; font-size: 12px; color: #fff;
}
.navbar-btn {
  background: rgba(255,255,255,.12); border: none; color: #fff;
  padding: 5px 12px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; text-decoration: none; transition: background .15s;
}
.navbar-btn:hover { background: rgba(255,255,255,.22); }

/* ── Layout ── */
.app-layout { display: flex; padding-top: var(--navbar-h); min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-sidebar);
  min-height: calc(100vh - var(--navbar-h));
  position: fixed; top: var(--navbar-h); left: 0; bottom: 0;
  overflow-y: auto; z-index: 90;
  display: flex; flex-direction: column;
}
.sidebar-section { padding: 16px 0 8px; }
.sidebar-section-title {
  font-size: 11px; font-weight: 600; letter-spacing: .8px;
  text-transform: uppercase; color: rgba(255,255,255,.45);
  padding: 0 20px 6px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 20px; color: rgba(255,255,255,.75);
  text-decoration: none; font-size: 13.5px; transition: all .15s;
  border-left: 3px solid transparent;
}
.sidebar-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-link.active {
  background: rgba(255,255,255,.15); color: #fff;
  border-left-color: #fff;
}
.sidebar-link .icon { width: 18px; text-align: center; opacity: .8; font-size: 14px; }
.sidebar-project-name {
  padding: 14px 20px 10px;
  font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,.5); text-transform: uppercase; letter-spacing: .5px;
  border-top: 1px solid rgba(255,255,255,.08);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1; padding: 28px 32px;
  min-width: 0;
}

/* ── Page header ── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px;
}
.page-title { font-family: var(--font-head); font-size: 22px; font-weight: 700; color: var(--text-primary); }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }

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

/* ── Stat cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: .4px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); margin: 6px 0 2px; font-family: var(--font-head); }
.stat-card .stat-sub   { font-size: 12px; color: var(--text-muted); }
.stat-card.green  { border-top: 3px solid var(--success); }
.stat-card.red    { border-top: 3px solid var(--danger); }
.stat-card.blue   { border-top: 3px solid var(--brand); }
.stat-card.orange { border-top: 3px solid var(--warning); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; font-size: 13.5px; font-weight: 500;
  border-radius: var(--radius-sm); border: none; cursor: pointer;
  transition: all .15s; text-decoration: none;
}
.btn-primary   { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); }
.btn-secondary { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn-secondary:hover { background: var(--brand-light); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .88; }
.btn-ghost     { background: transparent; color: var(--text-secondary); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--bg-page); color: var(--text-primary); }
.btn-sm        { padding: 4px 10px; font-size: 12.5px; }
.btn-icon      { padding: 6px 8px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table.tq-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tq-table thead th {
  background: var(--bg-page); padding: 10px 14px;
  text-align: left; font-weight: 600; color: var(--text-secondary);
  border-bottom: 2px solid var(--border); white-space: nowrap;
  font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
}
table.tq-table tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
table.tq-table tbody tr:hover { background: #F8F9FE; }
table.tq-table tbody td { padding: 10px 14px; vertical-align: middle; }
table.tq-table tbody tr:last-child { border-bottom: none; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 500;
}
.badge-green   { background: var(--success-bg); color: #006644; }
.badge-red     { background: var(--danger-bg);  color: #BF2600; }
.badge-orange  { background: var(--warning-bg); color: #974F0C; }
.badge-blue    { background: var(--brand-light); color: var(--brand-dark); }
.badge-gray    { background: #F4F5F7; color: var(--text-secondary); }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-primary); margin-bottom: 5px; }
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%; padding: 8px 12px; font-size: 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; color: var(--text-primary);
  transition: border-color .15s, box-shadow .15s;
  font-family: var(--font-base);
}
.form-control:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(76,154,255,.2); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(9,30,66,.55);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; animation: modalIn .18s ease;
}
.modal-lg { max-width: 780px; }
.modal-xl { max-width: 1000px; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(-8px); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  padding: 18px 24px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 600; font-family: var(--font-head); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 20px; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--bg-page); color: var(--text-primary); }
.modal-body   { padding: 20px 24px; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 18px; border-radius: var(--radius);
  background: #fff; box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--brand); font-size: 13.5px;
  animation: toastIn .2s ease; min-width: 240px; max-width: 360px;
}
.toast.success { border-left-color: var(--success); }
.toast.error   { border-left-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ── Progress bar ── */
.progress-bar-wrap { background: #DFE1E6; border-radius: 20px; height: 8px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 20px; background: var(--brand); transition: width .4s ease; }
.progress-bar-fill.green  { background: var(--success); }
.progress-bar-fill.red    { background: var(--danger); }
.progress-bar-fill.orange { background: var(--warning); }

/* ── Breadcrumb ── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-muted); margin-bottom: 12px; }
.breadcrumb a { color: var(--brand); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { color: var(--text-muted); }

/* ── Tabs ── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 9px 18px; font-size: 13.5px; font-weight: 500;
  color: var(--text-secondary); background: none; border: none;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all .15s;
}
.tab-btn:hover { color: var(--brand); }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Search / filters ── */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.search-box { position: relative; }
.search-box input { padding-left: 34px; width: 240px; }
.search-box .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 14px; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state .icon { font-size: 42px; margin-bottom: 12px; opacity: .4; }
.empty-state p  { font-size: 14px; }

/* ── Charts ── */
.chart-container { position: relative; height: 260px; }

/* ── Report specific ── */
.report-page { background: #fff; }
.report-header {
  background: var(--brand); color: #fff;
  padding: 32px 40px 24px;
}
.report-header h1 { font-size: 24px; font-weight: 700; font-family: var(--font-head); }
.report-header .meta { font-size: 13px; opacity: .75; margin-top: 6px; }
.report-section { padding: 28px 40px; border-bottom: 1px solid var(--border); }
.report-section h2 { font-size: 17px; font-weight: 700; font-family: var(--font-head); margin-bottom: 16px; color: var(--text-primary); }
@media print {
  .sidebar, .navbar, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; padding: 0 !important; }
  .report-section { break-inside: avoid; }
}

/* ── Traceability matrix ── */
.matrix-wrap { overflow: auto; max-height: 70vh; }
table.matrix-table { border-collapse: collapse; font-size: 12px; }
table.matrix-table th, table.matrix-table td { border: 1px solid var(--border); padding: 6px 10px; white-space: nowrap; }
table.matrix-table thead th { background: var(--bg-page); position: sticky; top: 0; z-index: 1; }
table.matrix-table thead th.req-col { position: sticky; top: 0; left: 0; z-index: 2; }
table.matrix-table tbody td.tc-label { position: sticky; left: 0; background: #fff; font-weight: 500; z-index: 1; }
.matrix-cell-yes { background: var(--success-bg); text-align: center; color: #006644; font-weight: 600; }
.matrix-cell-no  { text-align: center; color: var(--border); }

/* ── Dashboard project cards ── */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 18px; }
.project-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  box-shadow: var(--shadow-sm); transition: box-shadow .2s, transform .2s;
  text-decoration: none; color: inherit; display: block;
}
.project-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.project-card-name { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.project-card-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 14px; }
.project-card-footer { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

/* ── Login page ── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0052CC 0%, #003884 60%, #0747A6 100%);
}
.login-box {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 40px 36px; width: 100%; max-width: 400px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-mark {
  width: 52px; height: 52px; background: var(--brand);
  border-radius: 12px; display: inline-flex; align-items: center;
  justify-content: center; font-size: 26px; color: #fff; margin-bottom: 10px;
}
.login-logo h1 { font-family: var(--font-head); font-size: 22px; font-weight: 700; color: var(--text-primary); }
.login-logo p  { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.login-error { background: var(--danger-bg); color: var(--danger); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; margin-bottom: 14px; }

/* ── Misc ── */
.text-muted   { color: var(--text-muted); }
.text-small   { font-size: 12.5px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex  { display: flex; align-items: center; }
.flex-gap { gap: 8px; }
.justify-between { justify-content: space-between; }
.gap-16 { gap: 16px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
