/* Components */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface-solid); color: var(--text);
  font-size: 13.5px; font-weight: var(--fw-medium); white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
  text-decoration: none !important;
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; stroke-width: 2; flex: none; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; box-shadow: 0 4px 12px -4px rgba(72, 157, 164, 0.6); }
.btn-primary:hover { background: var(--teal-600); border-color: var(--teal-600); }
.btn-dark { background: #162E5B; border-color: #162E5B; color: #fff; }
.btn-dark:hover { background: #1F3D72; border-color: #1F3D72; }
.btn-coral { background: var(--coral); border-color: var(--coral); color: #fff; }
.btn-coral:hover { background: var(--coral-600); border-color: var(--coral-600); }
.btn-danger { background: var(--surface-solid); border-color: color-mix(in srgb, var(--red) 40%, var(--border)); color: var(--red); }
.btn-danger:hover { background: var(--red-50); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { height: var(--touch); padding: 0 20px; font-size: 15px; }
.btn-icon { width: 38px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; }
.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-solid); color: var(--text-2);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.8; }
.icon-btn.on { background: var(--coral); border-color: var(--coral); color: #fff; }
.icon-btn .dot { position: absolute; top: 6px; right: 7px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--coral); color: #fff; font-size: 10px; font-weight: 600; line-height: 16px; text-align: center; border: 2px solid var(--surface-solid); box-sizing: content-box; transform: translate(40%, -40%); }

/* Guarded action: button + visible reason */
.guard { display: inline-flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.guard-reason { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); color: var(--text-3); max-width: 280px; line-height: 1.35; }
.guard-reason svg { width: 12px; height: 12px; flex: none; }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); }
.field .req { color: var(--coral); }
.field .hint { font-size: var(--fs-xs); color: var(--text-3); }
.field .err { font-size: var(--fs-xs); color: var(--red); display: none; }
.field.invalid .err { display: block; }
.field.invalid .input { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-50); }
.input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-solid); color: var(--text); font-size: var(--fs-base);
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--focus); }
.input[readonly] { background: var(--surface-sunk); color: var(--text-2); }
select.input { appearance: none; -webkit-appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237C8698' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
.input-group { position: relative; }
.input-group svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.input-group .input { padding-left: 36px; }
.file-drop { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px dashed var(--border-strong); border-radius: var(--r-sm); color: var(--text-3); font-size: var(--fs-sm); background: var(--surface-sunk); cursor: pointer; }
.file-drop svg { width: 18px; height: 18px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--border); border-radius: var(--r-pill); font-size: var(--fs-sm); cursor: pointer; background: var(--surface-solid); user-select: none; }
.check input { accent-color: var(--teal); margin: 0; }
.check:has(input:checked) { border-color: var(--teal); background: var(--teal-50); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--fs-sm); }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 11px; background: var(--n-300); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s var(--ease); }
.switch input:checked + .track { background: var(--teal); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--focus); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.form-grid .full { grid-column: 1 / -1; }
.form-section { grid-column: 1 / -1; font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding-top: var(--sp-2); border-top: 1px solid var(--divider); margin-top: var(--sp-1); }
.form-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Pills, tabs, chips ---------- */
.pills { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--border); flex-wrap: wrap; max-width: 100%; }
.pills.tbl-tabs { flex-wrap: nowrap; }
.pills.pills-wrap { display: flex; gap: 6px; padding: 0; background: none; border: 0; border-radius: 0; }
.pills.pills-wrap .pill { border: 1px solid var(--border); background: var(--surface-solid); }
.pills.pills-wrap .pill.active { border-color: transparent; background: #162E5B; color: #fff; }
:root[data-theme="dark"] .pills.pills-wrap .pill.active { background: var(--teal); }
.pill { height: 30px; padding: 0 14px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--text-2); font-size: 13px; font-weight: var(--fw-medium); white-space: nowrap; }
.pill:hover { color: var(--text); }
.pill.active { background: #162E5B; color: #fff; box-shadow: var(--shadow-sm); }
:root[data-theme="dark"] .pill.active { background: var(--teal); }
.pill .count { margin-left: 6px; font-size: 11px; opacity: .7; }
.filter-pill { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface-solid); font-size: 13px; color: var(--text-2); }
.filter-pill select { border: 0; background: transparent; font-size: 13px; color: var(--text); font-weight: var(--fw-medium); padding-right: 4px; max-width: 160px; cursor: pointer; }
.filter-pill select:focus { outline: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-pill); background: var(--surface-sunk); border: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-2); white-space: nowrap; }
.kbd { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-sunk); font-size: 11px; color: var(--text-3); font-family: var(--font); }

/* ---------- Status badge ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: var(--fw-medium); white-space: nowrap; background: var(--surface-sunk); color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.g { background: var(--green-50); color: var(--green); }
.badge.a { background: var(--amber-50); color: var(--amber); }
.badge.r { background: var(--red-50); color: var(--red); }
.badge.b { background: var(--blue-50); color: var(--blue); }
.badge.t { background: var(--teal-50); color: var(--teal-600); }
.badge.n { background: var(--surface-sunk); color: var(--text-2); }
:root[data-theme="dark"] .badge.t { color: var(--teal); }
.status-dot { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 13px; }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; }
.status-dot.g::before { background: var(--green); } .status-dot.a::before { background: var(--amber); }
.status-dot.r::before { background: var(--red); } .status-dot.b::before { background: var(--blue); } .status-dot.t::before { background: var(--teal); }

/* ---------- Cards ---------- */
.card {
  position: relative; min-width: 0;
  background: var(--surface);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow);
  outline: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  outline-offset: -1px;
}
.card-head { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) 0; flex-wrap: wrap; }
.card-head h3 { flex: 1; min-width: 160px; }
.card-head .sub { display: block; font-size: var(--fs-sm); color: var(--text-3); font-weight: var(--fw-regular); margin-top: 4px; letter-spacing: 0; }
.card-body { padding: var(--sp-5); }
.card-body.flush { padding: var(--sp-3) 0 0; }
.card.flash { animation: flash 1.6s var(--ease); }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--coral), var(--shadow); } 100% { box-shadow: var(--shadow); } }
.card-link { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--teal-600); }

/* ---------- KPI tile ---------- */
.kpi {
  display: flex; flex-direction: column; gap: 6px;
  padding: var(--sp-5); min-width: 0;
  background: var(--surface); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border); outline: 1px solid color-mix(in srgb, var(--border) 60%, transparent); outline-offset: -1px;
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none !important; transition: transform .15s var(--ease), box-shadow .15s;
}
a.kpi:hover, button.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-top { display: flex; align-items: center; gap: 10px; }
.kpi-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--teal); flex: none; }
.kpi-icon svg { width: 17px; height: 17px; stroke-width: 2; }
.kpi-icon.navy { background: #162E5B; } .kpi-icon.coral { background: var(--coral); } .kpi-icon.blue { background: var(--blue); }
.kpi-icon.green { background: var(--green); } .kpi-icon.amber { background: var(--amber); } .kpi-icon.red { background: var(--red); }
.kpi-label { font-size: 13px; color: var(--text-2); font-weight: var(--fw-medium); line-height: 1.3; }
.kpi-value { font-size: var(--fs-2xl); font-weight: var(--fw-semibold); letter-spacing: -0.03em; line-height: 1.1; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value.sm { font-size: 24px; } .kpi-value.xs { font-size: 20px; }
.kpi-value small.pre { margin: 0 4px 0 0; font-size: 13px; vertical-align: 0.5em; }
.kpi-value small { font-size: 15px; font-weight: var(--fw-medium); color: var(--text-3); margin-left: 3px; letter-spacing: 0; }
.kpi-trend { display: flex; align-items: flex-start; gap: 6px; line-height: 1.35; font-size: var(--fs-sm); color: var(--text-3); min-height: 18px; }
.kpi-note { min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kpi-trend .delta { white-space: nowrap; flex: none; display: inline-flex; align-items: center; gap: 2px; font-weight: var(--fw-semibold); }
.kpi-trend .delta svg { width: 14px; height: 14px; stroke-width: 2.4; }
.kpi-trend .up { color: var(--green); } .kpi-trend .down { color: var(--red); } .kpi-trend .warn { color: var(--amber); }
.kpi.accent { background: linear-gradient(150deg, #E96653, #D2533F); color: #fff; border-color: transparent; outline: 0; }
.kpi.accent .kpi-label, .kpi.accent .kpi-trend, .kpi.accent .kpi-value small { color: rgba(255, 255, 255, .85); }
.kpi.accent .kpi-icon { background: rgba(255, 255, 255, .22); }
.kpi.accent .kpi-trend .delta { color: #fff; }
@media (max-width: 640px) { .kpi { padding: var(--sp-4); } .kpi-value { font-size: 22px; } }

/* ---------- Tables ---------- */
.table-tools { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; padding: 0 var(--sp-5) var(--sp-3); }
.table-tools .input-group { flex: 1 1 220px; max-width: 320px; }
.table-tools .input { height: 36px; border-radius: var(--r-pill); }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--divider); scrollbar-width: thin; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { position: sticky; top: 0; text-align: left; font-weight: var(--fw-medium); font-size: 12.5px; color: var(--text-3); padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--divider); white-space: nowrap; user-select: none; }
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th .sort { display: inline-block; width: 12px; height: 12px; vertical-align: -2px; margin-left: 2px; opacity: .35; }
.tbl th.sorted .sort { opacity: 1; color: var(--teal); }
.tbl th:first-child, .tbl td:first-child { padding-left: var(--sp-5); }
.tbl th:last-child, .tbl td:last-child { padding-right: var(--sp-5); }
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--divider); vertical-align: middle; white-space: nowrap; max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.tbl td.wrap { white-space: normal; min-width: 200px; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover { background: color-mix(in srgb, var(--teal-50) 70%, transparent); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num, .tbl th.num { text-align: right; }
.tbl .ref { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }
.tbl .primary { font-weight: var(--fw-medium); color: var(--text); }
.tbl .sub { display: block; font-size: var(--fs-xs); color: var(--text-3); }
.tbl tr.row-hi td { background: var(--coral-50); }
.table-foot { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--divider); font-size: var(--fs-sm); color: var(--text-3); flex-wrap: wrap; }
.pager { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.pager button { min-width: 30px; height: 30px; border-radius: 8px; border: 1px solid transparent; background: transparent; font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pager button:hover:not([disabled]) { background: var(--surface-2); }
.pager button.active { background: #162E5B; color: #fff; }
:root[data-theme="dark"] .pager button.active { background: var(--teal); }
.pager button[disabled] { opacity: .35; cursor: default; }
.pager svg { width: 14px; height: 14px; margin: auto; }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--teal-50); color: var(--teal-700); font-size: 11px; font-weight: var(--fw-semibold); flex: none; }
:root[data-theme="dark"] .avatar { color: var(--teal); }
.cell-person { display: inline-flex; align-items: center; gap: 10px; }
.bar-cell { display: inline-flex; align-items: center; gap: 8px; }
.bar-cell .bar { width: 72px; height: 6px; border-radius: 3px; background: var(--surface-sunk); overflow: hidden; }
.bar-cell .bar i { display: block; height: 100%; background: var(--teal); border-radius: 3px; }

/* Mini list (card rows) */
.mini-list > li { display: flex; align-items: center; gap: var(--sp-3); padding: 11px 0; border-bottom: 1px solid var(--divider); min-width: 0; }
.mini-list > li:last-child { border-bottom: 0; }
.mini-list .ml-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-sunk); color: var(--text-2); flex: none; }
.mini-list .ml-icon svg { width: 16px; height: 16px; }
.mini-list .ml-icon.r { background: var(--red-50); color: var(--red); } .mini-list .ml-icon.a { background: var(--amber-50); color: var(--amber); }
.mini-list .ml-icon.g { background: var(--green-50); color: var(--green); } .mini-list .ml-icon.b { background: var(--blue-50); color: var(--blue); } .mini-list .ml-icon.t { background: var(--teal-50); color: var(--teal); }
.mini-list .ml-main { flex: 1; min-width: 0; }
.mini-list .ml-title { font-size: 13.5px; font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .ml-sub { font-size: var(--fs-sm); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .ml-end { text-align: right; font-size: 13px; flex: none; }
.mini-list a.ml-row { display: contents; color: inherit; }

/* Progress */
.progress { height: 8px; border-radius: 4px; background: var(--surface-sunk); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 4px; background: var(--teal); transition: width .4s var(--ease); }
.progress.striped > i { background-image: repeating-linear-gradient(-45deg, rgba(255,255,255,.25) 0 6px, transparent 6px 12px); }

/* ---------- Stepper ---------- */
.stepper { display: flex; align-items: flex-start; gap: 0; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.step { flex: 1 1 0; min-width: 104px; display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; gap: 8px; padding: 0 4px; }
.step::before { content: ""; position: absolute; top: 16px; left: calc(-50% + 20px); right: calc(50% + 20px); height: 2px; background: var(--border); }
.step:first-child::before { display: none; }
.step.done::before, .step.current::before { background: var(--teal); }
.step-dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border); background: var(--surface-solid); color: var(--text-3); font-size: 13px; font-weight: var(--fw-semibold); z-index: 1; }
.step-dot svg { width: 16px; height: 16px; stroke-width: 2.6; }
.step.done .step-dot { background: var(--teal); border-color: var(--teal); color: #fff; }
.step.current .step-dot { border-color: var(--coral); color: var(--coral); box-shadow: 0 0 0 5px var(--coral-50); }
.step.blocked .step-dot { border-color: var(--red); color: var(--red); background: var(--red-50); }
.step-label { font-size: 12.5px; font-weight: var(--fw-medium); color: var(--text-2); line-height: 1.3; }
.step.current .step-label { color: var(--text); }
.step-meta { font-size: 11px; color: var(--text-3); line-height: 1.3; }
.chevrons { display: flex; gap: 4px; overflow-x: auto; }
.chevron { flex: 1; min-width: 110px; padding: 10px 18px 10px 22px; color: #fff; font-size: 12.5px; font-weight: var(--fw-semibold); clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%); line-height: 1.3; }
.chevron:first-child { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); border-radius: 8px 0 0 8px; }
.chevron small { display: block; font-weight: var(--fw-regular); opacity: .85; font-size: 11px; }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--divider); }
.tl-item { position: relative; padding-bottom: var(--sp-4); }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: -26px; top: 1px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-solid); border: 2px solid var(--teal); color: var(--teal); }
.tl-dot svg { width: 10px; height: 10px; stroke-width: 3; }
.tl-item.r .tl-dot { border-color: var(--red); color: var(--red); } .tl-item.a .tl-dot { border-color: var(--amber); color: var(--amber); }
.tl-item.n .tl-dot { border-color: var(--border-strong); color: var(--text-3); }
.tl-title { font-size: 13.5px; font-weight: var(--fw-medium); }
.tl-meta { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }
.tl-body { font-size: var(--fs-sm); color: var(--text-2); margin-top: 4px; }
.tl-diff { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.tl-diff del { color: var(--red); } .tl-diff ins { color: var(--green); text-decoration: none; }
.tl-h { display: flex; gap: var(--sp-4); overflow-x: auto; padding: 4px 0; }
.tl-h-item { flex: 1; min-width: 120px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; position: relative; }
.tl-h-item::after { content: ""; position: absolute; top: 22px; left: calc(50% + 26px); width: calc(100% - 52px + var(--sp-4)); border-top: 2px dotted var(--border-strong); }
.tl-h-item:last-child::after { display: none; }
.tl-h-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--teal); }
.tl-h-icon svg { width: 18px; height: 18px; }

/* ---------- Drawer & modal ---------- */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s; backdrop-filter: blur(2px); }
.overlay.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 10px; right: 10px; bottom: 10px; width: min(620px, calc(100vw - 20px)); z-index: 61;
  display: flex; flex-direction: column;
  background: var(--surface-solid); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  transform: translateX(calc(100% + 20px)); transition: transform .28s var(--ease);
}
.drawer.wide { width: min(880px, calc(100vw - 20px)); }
.drawer.on { transform: none; }
.drawer-head { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--divider); }
.drawer-head .titles { flex: 1; min-width: 0; }
.drawer-head .eyebrow { font-size: var(--fs-xs); color: var(--text-3); font-weight: var(--fw-medium); text-transform: uppercase; letter-spacing: .06em; }
.drawer-head h2 { margin-top: 4px; overflow-wrap: anywhere; }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--sp-5) var(--sp-6); }
.drawer-foot { display: flex; gap: var(--sp-2); justify-content: flex-end; padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--divider); flex-wrap: wrap; }
.control-note { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-md); background: var(--amber-50); color: var(--text); font-size: var(--fs-sm); margin-bottom: var(--sp-4); line-height: 1.45; }
.control-note svg { width: 16px; height: 16px; color: var(--amber); flex: none; margin-top: 1px; }
.control-note.info { background: var(--blue-50); } .control-note.info svg { color: var(--blue); }
.control-note.bad { background: var(--red-50); } .control-note.bad svg { color: var(--red); }
.control-note.good { background: var(--green-50); } .control-note.good svg { color: var(--green); }
.modal {
  position: fixed; left: 50%; top: 50%; z-index: 62; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto;
  background: var(--surface-solid); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); border: 1px solid var(--border);
  transform: translate(-50%, -46%) scale(.98); opacity: 0; pointer-events: none; transition: transform .2s var(--ease), opacity .2s;
}
.modal.on { transform: translate(-50%, -50%); opacity: 1; pointer-events: auto; }
.modal-body { padding: var(--sp-6); }
.modal-body h2 { margin-bottom: 8px; }
.modal-foot { display: flex; gap: var(--sp-2); justify-content: flex-end; padding: 0 var(--sp-6) var(--sp-6); flex-wrap: wrap; }

/* Detail view */
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; }
.detail-grid .dl-item { min-width: 0; }
.detail-grid dt { font-size: var(--fs-xs); color: var(--text-3); margin-bottom: 3px; }
.detail-grid dd { margin: 0; font-size: 13.5px; font-weight: var(--fw-medium); overflow-wrap: anywhere; }
.detail-section + .detail-section { margin-top: var(--sp-6); }
.detail-section > h4 { margin-bottom: var(--sp-3); display: flex; align-items: center; gap: 8px; }
.detail-section > h4 .chip { font-weight: var(--fw-regular); }
.attach { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: 13px; }
.attach + .attach { margin-top: 8px; }
.attach svg { width: 18px; height: 18px; color: var(--text-3); }
.attach .faint { margin-left: auto; font-size: var(--fs-xs); }
.approvals { display: flex; flex-direction: column; gap: 8px; }
.approval { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-sunk); font-size: 13px; }
.approval .badge { margin-left: auto; }
.action-bar { display: flex; gap: var(--sp-3); flex-wrap: wrap; align-items: flex-start; padding: var(--sp-4); border-radius: var(--r-md); background: var(--surface-sunk); margin-bottom: var(--sp-5); }
@media (max-width: 640px) { .detail-grid { grid-template-columns: 1fr; } .drawer { top: 0; right: 0; bottom: 0; border-radius: 0; width: 100vw; } .drawer.wide { width: 100vw; } }

/* ---------- Toast ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 90; display: flex; flex-direction: column; gap: 8px; pointer-events: none; max-width: calc(100vw - 40px); }
.toast { display: flex; align-items: flex-start; gap: 10px; min-width: 280px; max-width: 420px; padding: 12px 14px; border-radius: var(--r-md); background: #162E5B; color: #fff; box-shadow: var(--shadow-lg); font-size: 13.5px; pointer-events: auto; animation: toast-in .25s var(--ease); }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.g svg { color: #7FD3A8; } .toast.r svg { color: #FF9C8F; } .toast.a svg { color: #F5C46E; }
.toast small { display: block; opacity: .75; font-size: 12px; margin-top: 2px; }
.toast.out { animation: toast-out .2s forwards; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(10px); opacity: 0; } }
:root[data-theme="dark"] .toast { background: #26324D; }

/* ---------- Empty, skeleton ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: var(--sp-10) var(--sp-6); color: var(--text-3); }
.empty-icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--surface-sunk); color: var(--text-3); }
.empty-icon svg { width: 24px; height: 24px; }
.empty h4 { color: var(--text); }
.empty p { max-width: 360px; font-size: var(--fs-sm); }
.skel { background: linear-gradient(90deg, var(--surface-sunk) 0%, var(--divider) 50%, var(--surface-sunk) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.skel-card { height: 120px; border-radius: var(--r-lg); }
.skel-line { height: 12px; margin: 10px 0; }

/* ---------- Disclosure: features on this screen ---------- */
.features { margin-top: var(--sp-6); }
.features summary { list-style: none; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; font-weight: var(--fw-medium); color: var(--text-2); padding: 8px 14px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface-solid); }
.features summary::-webkit-details-marker { display: none; }
.features summary svg { width: 15px; height: 15px; }
.features[open] summary { background: #162E5B; color: #fff; border-color: #162E5B; }
.features ol { margin: var(--sp-3) 0 0; padding: var(--sp-4) var(--sp-5) var(--sp-4) calc(var(--sp-5) + 18px); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); columns: 2 360px; column-gap: var(--sp-8); }
.features li { font-size: 13px; padding: 4px 0; break-inside: avoid; color: var(--text); }
.features li button { border: 0; background: none; padding: 0; color: inherit; text-align: left; font: inherit; cursor: pointer; }
.features li button:hover { color: var(--teal-600); text-decoration: underline; }
.features li .where { display: block; font-size: var(--fs-xs); color: var(--text-3); }

/* ---------- Alerts list ---------- */
.alert { display: flex; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); font-size: 13px; line-height: 1.45; background: var(--surface-sunk); }
.alert + .alert { margin-top: 8px; }
.alert svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.alert.r { background: var(--red-50); } .alert.r svg { color: var(--red); }
.alert.a { background: var(--amber-50); } .alert.a svg { color: var(--amber); }
.alert.g { background: var(--green-50); } .alert.g svg { color: var(--green); }
.alert.b { background: var(--blue-50); } .alert.b svg { color: var(--blue); }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 300px; }
.chart-box.short { height: 180px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: var(--fs-sm); color: var(--text-2); }
.chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.gauge-wrap { position: relative; height: 170px; }
.gauge-center { position: absolute; left: 0; right: 0; bottom: 14px; text-align: center; }
.gauge-center b { display: block; font-size: 28px; font-weight: var(--fw-semibold); letter-spacing: -0.02em; }
.gauge-center span { font-size: var(--fs-sm); color: var(--text-3); }
.donut-wrap { position: relative; height: 200px; }
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; pointer-events: none; }
.donut-center b { display: block; font-size: 22px; font-weight: var(--fw-semibold); }
.donut-center span { font-size: var(--fs-xs); color: var(--text-3); }
.stat-list { display: flex; flex-direction: column; gap: 10px; }
.stat-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.stat-row i { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.stat-row span { flex: 1; color: var(--text-2); }
.stat-row b { font-weight: var(--fw-semibold); }

/* ---------- Command palette ---------- */
.palette { position: fixed; left: 50%; top: 12vh; z-index: 80; width: min(640px, calc(100vw - 24px)); transform: translateX(-50%) scale(.98); opacity: 0; pointer-events: none; transition: all .18s var(--ease); background: var(--surface-solid); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); border: 1px solid var(--border); overflow: hidden; }
.palette.on { opacity: 1; pointer-events: auto; transform: translateX(-50%); }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--divider); }
.palette-input svg { width: 18px; height: 18px; color: var(--text-3); }
.palette-input input { flex: 1; border: 0; background: transparent; font-size: 16px; outline: none; min-width: 0; }
.palette-results { max-height: 56vh; overflow-y: auto; padding: 8px; }
.palette-group { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 10px; border: 0; background: transparent; border-radius: var(--r-sm); text-align: left; }
.palette-item.sel, .palette-item:hover { background: var(--teal-50); }
.palette-item .pi-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-sunk); color: var(--text-2); flex: none; }
.palette-item .pi-icon svg { width: 15px; height: 15px; }
.palette-item .pi-main { flex: 1; min-width: 0; }
.palette-item .pi-title { font-size: 13.5px; font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .pi-sub { font-size: var(--fs-xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-foot { display: flex; gap: 14px; padding: 10px 18px; border-top: 1px solid var(--divider); font-size: var(--fs-xs); color: var(--text-3); }

/* ---------- Popover (notifications) ---------- */
.popover { position: fixed; top: calc(var(--topbar-h) - 4px); right: 16px; z-index: 70; width: min(400px, calc(100vw - 24px)); max-height: 70vh; display: flex; flex-direction: column; background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(-6px); pointer-events: none; transition: all .18s var(--ease); }
.popover.on { opacity: 1; transform: none; pointer-events: auto; }
.popover-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--divider); }
.popover-head h4 { flex: 1; }
.popover-body { overflow-y: auto; padding: 4px 16px 8px; }
.notif { display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--divider); cursor: pointer; }
.notif:last-child { border-bottom: 0; }
.notif.unread .notif-title::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--coral); margin-left: 6px; vertical-align: middle; }
.notif-title { font-size: 13px; font-weight: var(--fw-medium); }
.notif-sub { font-size: var(--fs-xs); color: var(--text-3); margin-top: 2px; }

/* ---------- Feedback pins ---------- */
body.feedback-on .content { cursor: crosshair; }
body.feedback-on .content::after { content: "Feedback mode: click anywhere to add a comment"; position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--coral); color: #fff; padding: 8px 16px; border-radius: var(--r-pill); font-size: 13px; font-weight: var(--fw-medium); box-shadow: var(--shadow-lg); z-index: 40; pointer-events: none; }
.fb-layer { position: absolute; inset: 0; pointer-events: none; z-index: 20; }
.fb-pin { position: absolute; width: 28px; height: 28px; margin: -28px 0 0 -4px; border-radius: 50% 50% 50% 4px; transform: rotate(0); background: var(--coral); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; box-shadow: 0 4px 10px -2px rgba(233, 102, 83, .6); pointer-events: auto; cursor: pointer; border: 2px solid #fff; }
.fb-pin.done { background: var(--green); }
.fb-pop { position: absolute; z-index: 45; width: 300px; padding: 14px; background: var(--surface-solid); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-lg); pointer-events: auto; cursor: default; }
.fb-pop textarea { width: 100%; min-height: 80px; }
.fb-pop .row { margin-top: 10px; justify-content: flex-end; }

/* Lock screen */
.locked-view { max-width: 560px; margin: 8vh auto; text-align: center; }
.locked-view .empty-icon { margin: 0 auto 16px; width: 64px; height: 64px; background: var(--coral-50); color: var(--coral); }

/* Floor (tablet) mode helpers */
.floor .btn { height: var(--touch); }
.big-choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.big-choice button { min-height: 64px; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-solid); font-weight: var(--fw-semibold); font-size: 15px; }
.big-choice button.sel { border-color: var(--teal); background: var(--teal-50); color: var(--teal-700); }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.numpad button { height: 52px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface-solid); font-size: 18px; font-weight: var(--fw-semibold); }
.readout { font-size: 34px; font-weight: var(--fw-semibold); letter-spacing: -0.02em; padding: 10px 14px; border-radius: var(--r-md); background: var(--surface-sunk); text-align: right; font-variant-numeric: tabular-nums; }

/* Check list (five checks) */
.checklist { display: flex; flex-direction: column; gap: 8px; }
.check-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-solid); }
.check-row .ck { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-sunk); color: var(--text-3); flex: none; font-size: 12px; font-weight: 700; }
.check-row .ck svg { width: 15px; height: 15px; stroke-width: 3; }
.check-row.ok .ck { background: var(--green); color: #fff; }
.check-row.fail .ck { background: var(--red); color: #fff; }
.check-row .ck-main { flex: 1; min-width: 0; }
.check-row .ck-title { font-weight: var(--fw-medium); font-size: 13.5px; }
.check-row .ck-sub { font-size: var(--fs-xs); color: var(--text-3); }

/* QR */
.qr { display: grid; grid-template-columns: repeat(21, 1fr); width: 126px; height: 126px; padding: 8px; background: #fff; border-radius: 10px; border: 1px solid var(--border); }
.qr i { background: #162E5B; } .qr b { background: transparent; }

/* Map */
.map { position: relative; height: 300px; border-radius: var(--r-lg); overflow: hidden; background:
  linear-gradient(var(--divider) 1px, transparent 1px) 0 0 / 40px 40px,
  linear-gradient(90deg, var(--divider) 1px, transparent 1px) 0 0 / 40px 40px, var(--surface-sunk); }
.map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-legend { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 12px; flex-wrap: wrap; padding: 8px 12px; border-radius: var(--r-pill); background: var(--surface-solid); font-size: var(--fs-xs); box-shadow: var(--shadow-sm); }
.map-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

/* Phone mock */
.phone { width: 230px; margin: 0 auto; border-radius: 28px; padding: 12px; background: #162E5B; box-shadow: var(--shadow-lg); }
.phone-screen { border-radius: 18px; background: #F4F6F9; color: #172033; padding: 14px; min-height: 300px; font-size: 12.5px; font-family: var(--mono); line-height: 1.55; }
.sms { background: #fff; border-radius: 12px 12px 12px 4px; padding: 10px 12px; margin-bottom: 8px; font-family: var(--font); font-size: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.06); color: #172033; }

/* Workflow tiles (cockpit) */
.wf-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--sp-3); }
.wf-tile { display: flex; flex-direction: column; gap: 6px; padding: var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-solid); color: var(--text); text-decoration: none !important; transition: transform .15s, box-shadow .15s; }
.wf-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.wf-tile-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.wf-tile .kpi-icon { width: 32px; height: 32px; } .wf-tile .kpi-icon svg { width: 16px; height: 16px; }
.wf-key { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-3); letter-spacing: .06em; }
.wf-tile-title { font-weight: var(--fw-semibold); font-size: 13.5px; line-height: 1.3; min-height: 2.6em; }
.wf-tile-meta { font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.wf-tile .progress { margin-top: 4px; }
@media (max-width: 1280px) { .wf-tiles { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); } }
.screen-link { border: 1px solid var(--border); background: var(--surface-solid); min-height: 46px; }
.screen-link:hover { background: var(--surface-solid); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.screen-link > svg:first-child { color: var(--teal); }
