:root {
  --bg: #eef2f6;
  --surface: #fff;
  --ink: #111827;
  --muted: #697386;
  --line: #d9e0ea;
  --soft: #f7f9fc;
  --brand: #1f5eff;
  --brand-dark: #1746bf;
  --ok: #099268;
  --warn: #e67700;
  --danger: #d92d20;
  --nav: #101624;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font: Inter, "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.app { min-height: 100vh; display: grid; grid-template-columns: 252px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--nav); color: #d8dee9; padding: 18px 14px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 8px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark { width: 38px; height: 38px; border-radius: 8px; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 900; }
.brand strong { display: block; color: #fff; }
.brand small { display: block; color: #9aa4b2; margin-top: 3px; }
#deptNav { display: flex; flex-direction: column; gap: 5px; margin-top: 18px; }
.dept-btn { border: 1px solid transparent; background: transparent; color: #c8d1df; border-radius: 8px; min-height: 48px; padding: 8px 10px; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: center; text-align: left; }
.dept-btn:hover, .dept-btn.active { background: #1a2440; border-color: #2d5bff; color: #fff; }
.dept-btn code { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; background: rgba(255,255,255,.08); color: #93b4ff; font-family: var(--mono); font-size: 11px; }
.dept-btn span { display: block; min-width: 0; }
.dept-btn small { display: block; margin-top: 2px; color: #7f8ca3; font-size: 11px; }
.sidebar-note { margin-top: auto; border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.05); border-radius: 8px; padding: 12px; }
.sidebar-note strong { color: #fff; }
.sidebar-note p { margin: 6px 0 0; color: #a6afbe; line-height: 1.55; font-size: 12px; }
main { min-width: 0; }
.topbar { min-height: 78px; border-bottom: 1px solid var(--line); background: rgba(238,242,246,.94); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 16px 28px; }
.eyebrow { font-family: var(--mono); color: var(--brand); font-size: 11px; font-weight: 850; text-transform: uppercase; letter-spacing: 0; }
h1 { margin: 4px 0 0; font-size: 24px; letter-spacing: 0; }
.top-actions { display: flex; gap: 10px; align-items: center; }
input, select { height: 38px; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 0 11px; min-width: 140px; outline: none; }
input:focus, select:focus { border-color: #8aadff; box-shadow: 0 0 0 3px rgba(31,94,255,.12); }
#search { width: 270px; }
.btn { height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: 0 13px; font-weight: 800; color: var(--ink); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.admin-link { color: var(--brand); border-color: #9ab6ff; }
.user-chip { min-height: 38px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 5px 10px; text-align: left; }
.user-chip span, .user-chip small { display: block; }
.user-chip span { font-weight: 850; }
.user-chip small { color: var(--muted); font-size: 10px; margin-top: 1px; }
.kpis { padding: 20px 28px 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.kpis article, .stage, .panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.kpis article { padding: 15px; }
.kpis span { color: var(--muted); font-size: 12px; font-weight: 850; }
.kpis strong { display: block; margin-top: 12px; font-family: var(--mono); font-size: 28px; }
.kpis small { display: block; margin-top: 9px; color: var(--muted); }
.workflow { padding: 14px 28px 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.stage { padding: 13px 14px; }
.stage > div:first-child { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stage strong { font-size: 14px; }
.stage span { color: var(--muted); font-size: 12px; }
.stage b { display: block; margin-top: 12px; font-family: var(--mono); font-size: 22px; }
.stage small { display: block; margin-top: 8px; color: var(--muted); font-family: var(--mono); }
.bar { height: 8px; margin-top: 9px; overflow: hidden; border-radius: 999px; background: #e9eef6; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #1f5eff, #099268); }
.bar.slim { height: 6px; margin-top: 0; }
.content-grid { padding: 18px 28px 40px; display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.panel { overflow: hidden; }
.panel-head { min-height: 64px; padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.panel-head.compact { min-height: 54px; }
h2 { margin: 0; font-size: 15px; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.tabs { display: inline-flex; padding: 3px; background: #eef2f7; border-radius: 8px; }
.tab { min-height: 30px; border: 0; border-radius: 7px; padding: 0 12px; background: transparent; color: var(--muted); font-weight: 850; }
.tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.table-wrap { max-height: 620px; overflow: auto; }
table { width: 100%; min-width: 1040px; border-collapse: separate; border-spacing: 0; }
th { position: sticky; top: 0; z-index: 2; background: #f7f9fc; border-bottom: 1px solid var(--line); color: var(--muted); font-family: var(--mono); font-size: 11px; text-align: left; padding: 11px 12px; white-space: nowrap; }
td { border-bottom: 1px solid #edf1f6; color: #344054; padding: 10px 12px; white-space: nowrap; }
tr:hover td, tr.selected td { background: #f5f8ff; }
.sticky-col { position: sticky; left: 0; z-index: 1; background: inherit; box-shadow: 1px 0 0 #edf1f6; }
.item { font-weight: 900; color: var(--ink); }
.sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.cell { width: 130px; min-width: 96px; height: 34px; border: 1px solid var(--line); border-radius: 7px; padding: 0 9px; }
.cell.number { width: 90px; text-align: right; font-family: var(--mono); }
.cell:disabled { opacity: .6; }
.badge { display: inline-flex; align-items: center; height: 24px; border-radius: 999px; padding: 0 9px; background: #f2f4f7; color: #475467; font-weight: 850; font-size: 12px; }
.badge.ok { background: #e7f8f1; color: #067647; }
.badge.warn { background: #fff4e5; color: #b54708; }
.badge.danger { background: #fff0ed; color: #b42318; }
.badge.blue { background: #edf3ff; color: #1849a9; }
.priority { display: inline-grid; place-items: center; min-width: 30px; height: 24px; border-radius: 7px; background: #111827; color: #fff; font-family: var(--mono); font-size: 11px; font-weight: 900; }
.progress-cell { min-width: 118px; }
.progress-cell span { display: block; margin-bottom: 6px; font-family: var(--mono); font-weight: 850; }
.detail-panel #detail { padding: 16px; }
.detail-title { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.detail-title strong { display: block; font-size: 19px; }
.metric-grid { margin-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.metric { border: 1px solid var(--line); border-radius: 8px; background: var(--soft); padding: 12px; min-width: 0; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 6px; font-family: var(--mono); font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline { margin-top: 16px; display: grid; gap: 10px; }
.timeline-row { display: grid; grid-template-columns: 42px 1fr 58px 62px; gap: 8px; align-items: center; font-size: 12px; }
.timeline-row b { text-align: right; font-family: var(--mono); }
.timeline-row small { color: var(--muted); text-align: right; }
.order-list { padding: 10px; display: grid; gap: 8px; }
.order-card { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 11px 12px; display: flex; justify-content: space-between; gap: 12px; align-items: center; text-align: left; }
.order-card:hover, .order-card.active { border-color: #8aadff; background: #f5f8ff; }
.order-card strong, .order-card small { display: block; }
.order-card small { margin-top: 3px; color: var(--muted); }
.order-card b { font-family: var(--mono); color: var(--brand); }
.empty { margin: 0; color: var(--muted); }
.modal { position: fixed; inset: 0; z-index: 20; display: none; place-items: center; background: rgba(16,24,40,.35); padding: 18px; }
.modal.show { display: grid; }
.modal-card { width: min(680px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 24px 70px rgba(16,24,40,.25); }
.modal-card.narrow { width: min(460px, 100%); }
.modal-card.import-card { width: min(900px, 100%); }
.modal-head { min-height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.icon-btn { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 20px; line-height: 1; }
.form-grid { padding: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.form-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 800; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid input { width: 100%; min-width: 0; }
.form-stack { padding: 18px; display: grid; gap: 14px; }
.form-stack label { display: grid; gap: 6px; color: var(--muted); font-weight: 800; font-size: 12px; }
.form-stack input { width: 100%; }
.form-stack > small, .modal-head p { color: var(--muted); margin: 4px 0 0; }
.modal-actions { padding: 14px 16px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.import-body { padding: 16px; }
.import-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.file-picker { min-height: 42px; flex: 1; min-width: 260px; border: 1px dashed #9ab6ff; border-radius: 8px; background: #f5f8ff; padding: 9px 12px; display: flex; align-items: center; gap: 10px; color: #344054; font-weight: 800; }
.file-picker input { height: auto; min-width: 0; flex: 1; border: 0; padding: 0; background: transparent; }
.import-hint { color: var(--muted); line-height: 1.65; margin: 12px 0; }
.import-result { border: 1px solid var(--line); border-radius: 8px; min-height: 150px; overflow: hidden; }
.import-result > .empty { padding: 24px; }
.import-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.import-summary span { background: var(--soft); padding: 12px; color: var(--muted); font-size: 12px; }
.import-summary b { display: block; color: var(--ink); font-family: var(--mono); font-size: 20px; margin-top: 5px; }
.import-messages { margin: 0; padding: 12px 32px; max-height: 150px; overflow: auto; background: #fff7ed; color: var(--danger); border-bottom: 1px solid var(--line); }
.import-messages li { margin: 4px 0; }
.import-messages li.warning { color: var(--warn); }
.import-errors { padding: 20px; color: var(--danger); }
.import-preview-table { max-height: 300px; overflow: auto; }
.import-preview-table table { min-width: 560px; }
.import-preview-table th { position: sticky; top: 0; }
#toast { position: fixed; right: 24px; bottom: 24px; background: #101828; color: #fff; border-radius: 8px; padding: 12px 14px; box-shadow: 0 18px 40px rgba(16,24,40,.22); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .18s ease; z-index: 30; }
#toast.show { opacity: 1; transform: translateY(0); }
.auth-page { min-height: 100vh; background: #0f172a; }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 480px); align-items: center; gap: 70px; max-width: 1120px; margin: 0 auto; padding: 48px 28px; }
.auth-brand { color: #fff; }
.auth-brand .brand-mark { margin-bottom: 28px; }
.auth-brand h1 { font-size: clamp(36px, 5vw, 64px); line-height: 1.08; max-width: 680px; }
.auth-brand > p:not(.eyebrow) { color: #b8c2d6; font-size: 17px; line-height: 1.8; max-width: 580px; }
.auth-points { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 30px; }
.auth-points span { border: 1px solid #334155; border-radius: 999px; padding: 8px 12px; color: #dbe5f6; }
.auth-card { background: #fff; border-radius: 12px; padding: 30px; display: grid; gap: 18px; box-shadow: 0 30px 90px rgba(0,0,0,.3); }
.auth-card h2 { margin-top: 5px; font-size: 25px; }
.auth-card p { color: var(--muted); }
.auth-card label { display: grid; gap: 7px; font-weight: 800; color: #344054; }
.auth-card input, .auth-card button { width: 100%; }
.auth-card button { height: 44px; }
.auth-card > small { color: var(--muted); text-align: center; }
.form-error { min-height: 20px; margin: 0; color: var(--danger) !important; }
.admin-page { min-height: 100vh; }
.admin-header { min-height: 84px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 30px; }
.admin-content { padding: 24px 30px 48px; }
.admin-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.admin-stats article { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.admin-stats span { color: var(--muted); font-weight: 800; }
.admin-stats strong { display: block; font-family: var(--mono); font-size: 28px; margin-top: 10px; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.admin-table { min-width: 900px; }
.admin-table td strong, .admin-table td small { display: block; }
.admin-table td small { color: var(--muted); margin-top: 3px; }
.audit-list { max-height: 680px; overflow: auto; padding: 10px 14px; }
.audit-list article { padding: 12px 2px; border-bottom: 1px solid var(--line); }
.audit-list article > div { display: flex; justify-content: space-between; gap: 8px; }
.audit-list span, .audit-list time { color: var(--muted); font-size: 12px; }
.audit-list p { margin: 7px 0; line-height: 1.5; word-break: break-word; }
fieldset { border: 1px solid var(--line); border-radius: 8px; }
legend { color: var(--muted); font-weight: 800; font-size: 12px; padding: 0 6px; }
.department-checks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 8px; }
.department-checks label { display: flex; align-items: center; gap: 7px; color: #344054; }
.department-checks input { width: auto; min-width: auto; height: auto; }
@media (max-width: 1120px) {
  .content-grid { grid-template-columns: 1fr; }
  .detail-panel { display: grid; grid-template-columns: 1fr 1fr; }
  .detail-panel .panel-head { grid-column: auto; }
  .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .app { display: block; }
  .sidebar { position: static; height: auto; }
  #deptNav { display: grid; grid-template-columns: repeat(2, 1fr); }
  .topbar, .top-actions { flex-wrap: wrap; }
  .top-actions { width: 100%; }
  #search { flex: 1; min-width: 180px; }
  .kpis, .workflow, .content-grid { grid-template-columns: 1fr; padding-left: 16px; padding-right: 16px; }
  .detail-panel { display: block; }
  .auth-shell { grid-template-columns: 1fr; gap: 30px; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .auth-page .auth-shell { display: block; min-height: 100vh; padding: 28px 18px; }
  .auth-page .auth-brand { display: none; }
  .auth-page .auth-card { max-width: 420px; margin: 0 auto; padding: 24px 20px; }
  .auth-page .auth-card input { height: 56px; font-size: 18px; }
  .auth-page .auth-card button { height: 60px; font-size: 19px; }
  .topbar { padding-left: 16px; padding-right: 16px; }
  .top-actions > * { width: 100%; }
  #deptNav { grid-template-columns: 1fr; }
  .kpis article { padding: 13px; }
  .form-grid { grid-template-columns: 1fr; }
  .timeline-row { grid-template-columns: 40px 1fr 50px; }
  .timeline-row small { display: none; }
  .admin-header { align-items: flex-start; flex-direction: column; padding: 16px; }
  .admin-content { padding: 16px; }
  .admin-stats { grid-template-columns: 1fr 1fr; }
  .department-checks { grid-template-columns: 1fr; }
  .import-summary { grid-template-columns: 1fr 1fr; }
}
