/* TQMS CRM – custom admin theme (on top of Bootstrap 5.3) */
:root {
  --brand: #1d3f94;
  --brand-600: #18357d;
  --brand-50: #eef2fb;
  --accent: #d92d2d;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e5e8ef;
  --bg: #f4f6fb;
  --card: #ffffff;
  --sidebar: #0f1d3d;
  --sidebar-ink: #c4cde3;
  --sidebar-active: #ffffff;
  --radius: 12px;
  --bs-primary: #1d3f94;
  --bs-primary-rgb: 29, 63, 148;
  --bs-link-color: #1d3f94;
  --bs-link-color-rgb: 29, 63, 148;
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-color: #0f172a;
  --bs-border-color: #e5e8ef;
}
html, body { background: var(--bg); }
body { font-size: 14px; color: var(--ink); -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand-600); --bs-btn-hover-border-color: var(--brand-600); --bs-btn-active-bg: var(--brand-600); --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand); }
.text-primary { color: var(--brand) !important; }
.bg-primary { background-color: var(--brand) !important; }
.text-bg-primary { background-color: var(--brand) !important; }
.btn { border-radius: 8px; font-weight: 500; font-size: 14px; }
.btn-sm { border-radius: 7px; }
.form-control, .form-select { border-radius: 8px; border-color: #d8dde8; font-size: 14px; }
.form-control:focus, .form-select:focus { border-color: #6d86c9; box-shadow: 0 0 0 .2rem rgba(29,63,148,.12); }
.form-label { font-weight: 500; color: #334155; margin-bottom: .3rem; font-size: 13px; }
.form-text { font-size: 12px; }
.form-label.required::after { content: " *"; color: var(--accent); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 252px; background: var(--sidebar); color: var(--sidebar-ink); position: fixed; inset: 0 auto 0 0; z-index: 1040; display: flex; flex-direction: column; transition: transform .2s; }
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar .brand img { height: 34px; background: #fff; border-radius: 8px; padding: 3px 6px; }
.sidebar .brand .name { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.1; }
.sidebar .brand .name small { display: block; font-weight: 400; color: var(--sidebar-ink); font-size: 11px; }
.sidebar nav { overflow-y: auto; flex: 1; padding: 10px 10px 20px; }
.sidebar .nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #7d8bb0; padding: 14px 10px 6px; }
.sidebar .nav-link { color: var(--sidebar-ink); display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; }
.sidebar .nav-link i { font-size: 16px; width: 18px; text-align: center; opacity: .9; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-link.active { background: var(--brand); color: var(--sidebar-active); box-shadow: 0 4px 12px rgba(29,63,148,.35); }
.sidebar .nav-link .count { margin-left: auto; background: var(--accent); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
.main { margin-left: 252px; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 22px; position: sticky; top: 0; z-index: 1030; }
.topbar .search { flex: 1; max-width: 460px; position: relative; }
.topbar .search input { padding-left: 36px; background: var(--bg); border-color: transparent; }
.topbar .search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-50); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.content { padding: 22px; flex: 1; }
.footer { padding: 14px 22px; color: var(--muted); font-size: 12px; }
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 1035; }
  .main { margin-left: 0; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 21px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-head .sub { color: var(--muted); margin-top: 3px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--brand); }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); padding: 13px 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-radius: var(--radius) var(--radius) 0 0 !important; }
.card-header h2, .card-header .card-title { font-size: 15px; font-weight: 600; margin: 0; }
.card-body { padding: 18px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin: 6px 0 12px; }

.stat { display: flex; gap: 14px; align-items: center; padding: 16px 18px; }
.stat .icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat .hint { font-size: 12px; color: var(--muted); }
.tint-blue { background: #e8eefc; color: #1d3f94; }
.tint-green { background: #e5f6ee; color: #11845b; }
.tint-amber { background: #fdf3df; color: #b26b00; }
.tint-red { background: #fde8e8; color: #c02626; }
.tint-violet { background: #efe9fd; color: #6b3fd4; }
.tint-cyan { background: #e2f5f9; color: #0b7b93; }
a.card-link-hover:hover .card { border-color: #b9c6e6; }

/* ---------- Tables ---------- */
.table { --bs-table-hover-bg: #f7f9fd; margin: 0; }
.table > :not(caption) > * > * { padding: 10px 14px; vertical-align: middle; }
.table thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; background: #fafbfd; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td .title { font-weight: 600; color: var(--ink); }
.table td .meta { color: var(--muted); font-size: 12px; }
.table-responsive { border-radius: 0 0 var(--radius) var(--radius); }
.badge-status { font-weight: 500; font-size: 11.5px; padding: .38em .75em; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters .form-control, .filters .form-select { width: auto; min-width: 150px; }
.empty { text-align: center; padding: 42px 16px; color: var(--muted); }
.empty i { font-size: 34px; display: block; margin-bottom: 8px; color: #b6bfd3; }
.pagination { margin: 0; }
.card-footer { background: #fff; border-top: 1px solid var(--line); }

/* ---------- Detail lists ---------- */
.dl { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; margin: 0; }
.dl dt { color: var(--muted); font-weight: 500; font-size: 13px; }
.dl dd { margin: 0; word-break: break-word; }
@media (max-width: 575px) { .dl { grid-template-columns: 1fr; gap: 2px; } .dl dd { margin-bottom: 8px; } }

/* ---------- Pipeline stepper ---------- */
.pipeline { display: flex; gap: 0; overflow-x: auto; padding: 4px 2px 6px; }
.pipeline .step { flex: 1; min-width: 104px; text-align: center; position: relative; font-size: 11.5px; color: var(--muted); }
.pipeline .step .dot { width: 28px; height: 28px; border-radius: 50%; margin: 0 auto 6px; display: flex; align-items: center; justify-content: center; background: #eef1f6; color: #94a0b8; font-weight: 700; position: relative; z-index: 1; border: 2px solid #fff; }
.pipeline .step::before { content: ""; position: absolute; top: 14px; left: -50%; width: 100%; height: 2px; background: #e3e7ef; }
.pipeline .step:first-child::before { display: none; }
.pipeline .step.done .dot { background: #11845b; color: #fff; }
.pipeline .step.done::before, .pipeline .step.current::before { background: #11845b; }
.pipeline .step.current .dot { background: var(--brand); color: #fff; box-shadow: 0 0 0 4px rgba(29,63,148,.15); }
.pipeline .step.current { color: var(--ink); font-weight: 600; }

/* ---------- Tabs ---------- */
.nav-tabs.crm-tabs { border-bottom: 1px solid var(--line); gap: 2px; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.nav-tabs.crm-tabs .nav-link { border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; padding: 10px 14px; white-space: nowrap; }
.nav-tabs.crm-tabs .nav-link.active { color: var(--brand); border-bottom-color: var(--brand); background: transparent; }
.nav-tabs.crm-tabs .nav-link .badge { font-size: 10px; }

/* ---------- Wizard ---------- */
.wizard-steps { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.wizard-steps a { flex: 1; min-width: 130px; padding: 10px 12px; border-radius: 10px; background: #fff; border: 1px solid var(--line); color: var(--muted); font-size: 12.5px; display: flex; gap: 8px; align-items: center; }
.wizard-steps a .n { width: 22px; height: 22px; border-radius: 50%; background: #eef1f6; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 11px; flex-shrink: 0; }
.wizard-steps a.active { border-color: var(--brand); color: var(--brand); background: var(--brand-50); font-weight: 600; }
.wizard-steps a.active .n { background: var(--brand); color: #fff; }
.wizard-steps a.done .n { background: #11845b; color: #fff; }
.yn-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.yn-row:last-child { border-bottom: 0; }
.dyn-table .form-control, .dyn-table .form-select { min-width: 120px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 16px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .when { color: var(--muted); font-size: 12px; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfd; font-size: 12.5px; color: var(--ink); }
.file-chip:hover { border-color: var(--brand); color: var(--brand); }
.alert { border-radius: 10px; }
.toast-wrap { position: fixed; top: 72px; right: 18px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast-wrap .alert { box-shadow: 0 8px 24px rgba(15,23,42,.15); margin: 0; }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side { background: linear-gradient(140deg, #0f1d3d 0%, #1d3f94 70%, #2c56c4 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h2 { font-size: 30px; font-weight: 700; line-height: 1.25; }
.auth-side ul { list-style: none; padding: 0; margin: 28px 0 0; }
.auth-side li { display: flex; gap: 10px; margin-bottom: 12px; color: #d5def5; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 32px; background: #fff; }
.auth-form .box { width: 100%; max-width: 390px; }
.auth-form img.logo { height: 54px; margin-bottom: 22px; }
@media (max-width: 860px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { display: none; } }

/* Portal tweaks */
.portal .sidebar { background: #ffffff; border-right: 1px solid var(--line); }
.portal .sidebar .brand { border-bottom-color: var(--line); }
.portal .sidebar .brand .name { color: var(--ink); }
.portal .sidebar .brand .name small, .portal .sidebar .nav-link { color: #475569; }
.portal .sidebar .nav-section { color: #94a3b8; }
.portal .sidebar .nav-link:hover { background: var(--brand-50); color: var(--brand); }
.portal .sidebar .nav-link.active { color: #fff; }
.action-item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.action-item:last-child { border-bottom: 0; }
.action-item .icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.calendar { display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.calendar .cell { min-height: 108px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px; font-size: 12px; background: #fff; }
.calendar .cell.muted { background: #fafbfd; color: #b0b8c9; }
.calendar .cell.today .d { background: var(--brand); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.calendar .head { padding: 8px; font-weight: 600; font-size: 11.5px; text-transform: uppercase; color: var(--muted); background: #fafbfd; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.calendar .ev { display: block; margin-top: 4px; padding: 3px 6px; border-radius: 6px; background: var(--brand-50); color: var(--brand); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calendar .ev.s2 { background: #e5f6ee; color: #11845b; }
.calendar .ev.sv { background: #fdf3df; color: #b26b00; }
@media (max-width: 767px) { .calendar .cell { min-height: 70px; } }
@media print { .sidebar, .topbar, .no-print, .footer { display: none !important; } .main { margin: 0; } }
