* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --border: #e3e7ed;
  --text: #1f2937;
  --text2: #6b7280;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --na: #6b7280;
  --na-bg: #f3f4f6;
  --info: #0891b2;
  --info-bg: #cffafe;
  --shadow: 0 2px 6px rgba(0,0,0,0.06);
}
body {
  font-family: 'Sarabun', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

/* Top bar */
.topbar {
  background: linear-gradient(90deg, #1e3a8a 0%, #2563eb 100%);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 44px; height: 44px;
  background: rgba(255,255,255,0.18);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.brand h1 { font-size: 18px; font-weight: 700; }
.brand small { font-size: 12px; opacity: 0.85; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.topbar-actions input[type=month] {
  padding: 8px 10px;
  border-radius: 8px;
  border: none;
  background: rgba(255,255,255,0.95);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

/* Tabs */
.tabs {
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  padding: 0 24px;
}
.tab {
  background: none;
  border: none;
  padding: 14px 20px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  color: var(--text2);
  border-bottom: 3px solid transparent;
  transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* Container */
.container { max-width: 1400px; margin: 0 auto; padding: 20px 24px 40px; }

/* Buttons */
.btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  transition: all 0.15s;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { background: rgba(255,255,255,0.15); color: #fff; border-color: rgba(255,255,255,0.25); }
.btn-ghost:hover { background: rgba(255,255,255,0.25); }
.btn-danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Summary cards */
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.card-label { font-size: 12px; color: var(--text2); margin-bottom: 6px; }
.card-value { font-size: 26px; font-weight: 700; }
.card-sub { font-size: 11px; color: var(--text2); margin-top: 4px; }
.card-ok { border-left: 4px solid var(--ok); }
.card-warn { border-left: 4px solid var(--warn); }
.card-bad { border-left: 4px solid var(--bad); }
.card-info { border-left: 4px solid var(--info); }

/* Panel */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.panel h2 { font-size: 16px; font-weight: 600; }
.hidden { display: none !important; }
.hint { font-size: 12px; color: var(--text2); margin-top: 10px; }

/* Legend */
.legend { display: flex; gap: 8px; align-items: center; font-size: 12px; }
.lg { padding: 3px 8px; border-radius: 6px; font-size: 11px; }
.lg-done { background: var(--ok-bg); color: var(--ok); }
.lg-pending { background: var(--warn-bg); color: var(--warn); }
.lg-issue { background: var(--bad-bg); color: var(--bad); }
.lg-na { background: var(--na-bg); color: var(--na); }
.lg-empty { background: #fff; color: var(--text2); border: 1px dashed var(--border); }

/* Matrix table */
.matrix-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.matrix {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  background: #fff;
}
.matrix th, .matrix td { border: 1px solid var(--border); }
.matrix thead th {
  background: #f9fafb;
  font-weight: 600;
  padding: 8px 4px;
  position: sticky; top: 0;
  z-index: 2;
}
.matrix thead th.col-name {
  text-align: left;
  padding: 8px 12px;
  min-width: 280px;
  position: sticky; left: 0; z-index: 3;
  background: #f9fafb;
}
.matrix th.day-col { width: 32px; text-align: center; }
.matrix th.day-col.weekend { background: #fafafa; color: var(--text2); }
.matrix th.day-col.today { background: #fef9c3; color: #854d0e; font-weight: 700; }
.matrix tbody td.col-name {
  text-align: left;
  padding: 8px 12px;
  position: sticky; left: 0;
  background: #fff;
  z-index: 1;
  font-weight: 500;
}
.matrix tbody tr:nth-child(even) td.col-name { background: #fafbfc; }
.matrix .item-name { font-weight: 500; }
.matrix .item-desc { font-size: 11px; color: var(--text2); margin-top: 2px; }
.matrix .badge-detail {
  display: inline-block;
  font-size: 10px;
  background: var(--info-bg); color: var(--info);
  padding: 1px 6px; border-radius: 4px;
  margin-left: 6px;
}
.matrix .badge-monthly {
  display: inline-block;
  font-size: 10px;
  background: #ede9fe; color: #6d28d9;
  padding: 1px 6px; border-radius: 4px;
  margin-left: 6px;
}

.cell {
  width: 32px; height: 36px;
  text-align: center;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
  transition: transform 0.05s;
}
.cell:hover { transform: scale(1.15); }
.cell.empty { background: #fff; color: #d1d5db; }
.cell.empty::after { content: '·'; }
.cell.done { background: var(--ok-bg); color: var(--ok); font-weight: 700; }
.cell.done::after { content: '✓'; }
.cell.pending { background: var(--warn-bg); color: var(--warn); }
.cell.pending::after { content: '⏳'; }
.cell.issue { background: var(--bad-bg); color: var(--bad); }
.cell.issue::after { content: '⚠'; }
.cell.na { background: var(--na-bg); color: var(--na); }
.cell.na::after { content: '—'; }
.cell.has-note { box-shadow: inset 0 0 0 2px var(--info); }
.cell.weekend { background-image: linear-gradient(135deg, transparent 95%, rgba(0,0,0,0.04) 95%); }
.cell.future { opacity: 0.4; cursor: not-allowed; }

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th, .table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.table thead { background: #f9fafb; }
.table thead th { font-weight: 600; font-size: 12px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.05em; }
.table tbody tr:hover { background: #fafbfc; }
.status-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.status-pill.done { background: var(--ok-bg); color: var(--ok); }
.status-pill.pending { background: var(--warn-bg); color: var(--warn); }
.status-pill.issue { background: var(--bad-bg); color: var(--bad); }
.status-pill.na { background: var(--na-bg); color: var(--na); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.modal h3 { font-size: 18px; margin-bottom: 16px; }
.modal h4 { font-size: 14px; margin: 14px 0 8px; color: var(--text2); }
.form-row { margin-bottom: 12px; }
.form-row label {
  display: block;
  font-size: 12px;
  color: var(--text2);
  margin-bottom: 4px;
  font-weight: 500;
}
.form-row input, .form-row textarea, .form-row select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  background: #fff;
}
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.readonly {
  padding: 8px 10px;
  background: #f9fafb;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.modal-actions .btn-ghost { background: transparent; color: var(--text2); border-color: var(--border); margin-right: auto; }
.modal-actions .btn-ghost:hover { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); }

/* Status picker */
.status-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.st {
  padding: 10px 8px;
  border: 2px solid var(--border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.st-done { color: var(--ok); }
.st-pending { color: var(--warn); }
.st-issue { color: var(--bad); }
.st-na { color: var(--na); }
.st.active.st-done { background: var(--ok-bg); border-color: var(--ok); }
.st.active.st-pending { background: var(--warn-bg); border-color: var(--warn); }
.st.active.st-issue { background: var(--bad-bg); border-color: var(--bad); }
.st.active.st-na { background: var(--na-bg); border-color: var(--na); }

/* Detail block */
.detail-block {
  background: var(--info-bg);
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 8px;
}
.detail-block h4 { color: var(--info); margin-top: 0; }
.detail-block .form-row input,
.detail-block .form-row textarea {
  background: #fff;
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Section header (Weekly/Monthly) */
.section-head {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: 6px;
  border-left: 3px solid var(--border);
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-store { background: #2563eb; }
.dot-receive { background: #db2777; }
.section-head:has(.dot-store) { border-left-color: #2563eb; }
.section-head:has(.dot-receive) { border-left-color: #db2777; }

/* Empty row */
.empty-row { padding: 16px 12px !important; color: var(--text2); font-style: italic; text-align: center; background: #fafbfc; }

/* Wide cells (weekly/monthly) */
.cell.wide { width: 60px; height: 40px; }
.matrix th.week-col { width: 64px; text-align: center; padding: 6px 4px; font-size: 11px; line-height: 1.3; }
.matrix th.week-col .sub { font-weight: 400; color: var(--text2); font-size: 10px; }
.matrix th.month-col { width: 60px; text-align: center; padding: 6px 4px; font-size: 12px; }
.matrix th.month-col.today { background: #fef9c3; color: #854d0e; font-weight: 700; }

/* New badges */
.badge-special, .badge-week, .badge-store, .badge-receive {
  display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 4px; margin-left: 6px;
}
.badge-special { background: #fef3c7; color: #b45309; }
.badge-week { background: #ddd6fe; color: #5b21b6; }
.badge-store { background: #dbeafe; color: #1e40af; }
.badge-receive { background: #fce7f3; color: #9d174d; }

.cell.has-detail::before { content: '·'; position: absolute; }
.cell { position: relative; }

/* Wide modal for special forms */
.modal-wide { max-width: 1200px !important; }

/* Special-form toolbar */
.penalty-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 10px;
  padding: 8px 12px; background: #f9fafb; border-radius: 6px;
}
.penalty-summary { font-size: 12px; color: var(--text2); }
.penalty-summary strong { color: var(--text); }

/* Special-form table */
.penalty-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 6px; max-height: 360px; overflow-y: auto; }
.penalty-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.penalty-table th {
  background: #fef3c7; color: #78350f;
  padding: 6px 4px; border: 1px solid #fcd34d;
  position: sticky; top: 0; z-index: 1;
  font-weight: 600; white-space: nowrap;
}
.penalty-table td { border: 1px solid var(--border); padding: 0; }
.penalty-table input, .penalty-table select {
  border: none; width: 100%; padding: 6px 8px; font-family: inherit; font-size: 12px;
  background: transparent;
}
.penalty-table input:focus, .penalty-table select:focus {
  outline: 2px solid var(--primary); outline-offset: -2px; background: #fff;
}
.penalty-table input[type=number] { text-align: right; }
.penalty-table tr:nth-child(even) td { background: #fafbfc; }
.btn-del-row {
  border: none; background: transparent; color: var(--bad); cursor: pointer;
  font-size: 14px; padding: 4px 8px; border-radius: 4px;
}
.btn-del-row:hover { background: var(--bad-bg); }

/* Signatures */
.signatures {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px; margin-top: 8px;
}
.sig-card {
  background: #f9fafb; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px;
}
.sig-card.signed-card { background: #ecfdf5; border-color: #6ee7b7; }
.sig-label { font-size: 11px; color: var(--text2); font-weight: 600; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.sig-name {
  width: 100%; padding: 6px 8px; font-family: inherit; font-size: 13px;
  border: 1px solid var(--border); border-radius: 4px; background: #fff; margin-bottom: 6px;
}
.sig-time {
  font-size: 11px; color: var(--text2); padding: 4px 0; min-height: 20px;
}
.sig-time.signed { color: var(--ok); font-weight: 600; }
.sig-actions { display: flex; gap: 6px; margin-top: 4px; }
.sig-actions .btn { flex: 1; padding: 5px 8px; font-size: 11px; }
.btn-unsign { color: var(--text2); }
.btn-unsign:hover { color: var(--bad); }

/* Cover Sheet header */
.cs-header {
  background: #f9fafb; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; margin-bottom: 12px;
}
.cs-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.cs-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.cs-grid label { font-size: 11px; color: var(--text2); display: flex; flex-direction: column; gap: 4px; }
.cs-grid input { padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; font-family: inherit; font-size: 13px; background: #fff; }

/* HR per-row signing (Carcass) */
.hr-cell { padding: 4px !important; min-width: 130px; }
.hr-cell input[type="text"] { display: block; }
.btn-hr-sign {
  width: 100%; padding: 4px 6px; border: 1px solid var(--border); background: #fff;
  border-radius: 4px; font-size: 11px; font-family: inherit; cursor: pointer;
}
.btn-hr-sign:hover { background: var(--bg); }
.btn-hr-sign.signed { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); font-weight: 600; }

/* Penalty-table textarea */
.penalty-table textarea {
  border: none; width: 100%; padding: 6px 8px; font-family: inherit; font-size: 12px;
  background: transparent; resize: vertical; min-height: 28px;
}
.penalty-table textarea:focus { outline: 2px solid var(--primary); outline-offset: -2px; background: #fff; }

/* Minibar inspection grid */
.mb-toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: #f9fafb; border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 12px; margin-bottom: 10px;
}
.mb-toolbar label { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.mb-toolbar select {
  padding: 4px 8px; border: 1px solid var(--border); border-radius: 4px;
  font-family: inherit; font-size: 13px; background: #fff;
}
.mb-spacer { flex: 1; }
.mb-grid-wrap {
  overflow: auto; border: 1px solid var(--border); border-radius: 6px;
  max-height: 60vh;
}
.mb-grid {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.mb-grid th, .mb-grid td { border: 1px solid var(--border); padding: 0; }
.mb-grid thead th {
  background: #f9fafb; padding: 6px 4px; font-size: 11px; font-weight: 600;
  position: sticky; top: 0; z-index: 2;
}
.mb-grid thead th.mb-head-name { text-align: left; padding: 6px 10px; min-width: 200px; }
.mb-grid thead th.mb-head-par { width: 70px; background: #fef3c7; }
.mb-grid thead th.mb-head-date { background: #ddd6fe; color: #5b21b6; min-width: 110px; }
.mb-grid thead th.mb-head-sub { background: #ede9fe; font-weight: 500; font-size: 10px; padding: 4px 2px; min-width: 36px; }
.mb-grid thead th.mb-bk { background: #fee2e2; color: #991b1b; }
.mb-grid thead th.mb-sl { background: #d1fae5; color: #065f46; }
.mb-grid thead th.mb-ac { background: #fef3c7; color: #78350f; }
.mb-grid td.mb-prod { padding: 6px 10px; font-weight: 500; min-width: 200px; background: #fafbfc; }
.mb-grid td.mb-cat { display: none; }
.mb-grid .mb-cat { font-size: 10px; color: var(--text2); font-weight: 400; margin-top: 2px; }
.mb-grid td.mb-par input { background: #fffbeb; }
.mb-grid input {
  border: none; width: 100%; padding: 6px 4px; font-family: inherit; font-size: 12px;
  text-align: center; background: transparent;
}
.mb-grid input:focus { outline: 2px solid var(--primary); outline-offset: -2px; background: #fff; }
.mb-grid tbody tr:nth-child(even) td:not(.mb-prod) { background: #fafbfc; }
.mb-grid tbody tr:hover td { background: #eff6ff; }

/* Store Close report */
.sc-progress {
  display: flex; align-items: center; gap: 12px; margin-top: 10px;
  font-size: 13px;
}
.sc-progress-bar {
  flex: 1; height: 10px; background: #e5e7eb; border-radius: 5px; overflow: hidden;
}
.sc-progress-fill {
  height: 100%; background: linear-gradient(90deg, #16a34a, #22c55e);
  transition: width 0.3s ease;
}
.bf-tag {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600;
}
.bf-s { background: #dbeafe; color: #1e40af; }
.bf-z { background: #f3f4f6; color: #4b5563; }
.bf-c { background: #fef3c7; color: #b45309; }
.sc-files { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.sc-chips { display: flex; flex-wrap: wrap; gap: 4px; max-width: 200px; }
.sc-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: #ecfdf5; border: 1px solid #6ee7b7;
  border-radius: 12px; padding: 2px 4px 2px 8px; font-size: 11px;
}
.sc-chip a { color: var(--ok); text-decoration: none; }
.sc-chip a:hover { text-decoration: underline; }
.sc-chip-del {
  border: none; background: rgba(239,68,68,0.1); color: var(--bad);
  width: 16px; height: 16px; border-radius: 50%; cursor: pointer; font-size: 11px;
  line-height: 1; padding: 0;
}
.sc-chip-del:hover { background: var(--bad); color: #fff; }
.sc-file-btn { padding: 2px 8px !important; font-size: 11px !important; }
.sc-table input[type=checkbox] { width: 18px; height: 18px; cursor: pointer; }

/* ===== Login overlay ===== */
.login-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #0891b2 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.login-box {
  background: #fff; border-radius: 16px; padding: 32px 28px;
  width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.login-header { text-align: center; margin-bottom: 22px; }
.login-logo {
  width: 64px; height: 64px; margin: 0 auto 12px;
  background: linear-gradient(135deg, #2563eb, #0891b2);
  border-radius: 16px; display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: #fff;
}
.login-header h1 { font-size: 22px; margin-bottom: 4px; }
.login-header p { color: var(--text2); font-size: 13px; }
.login-error { color: var(--bad); font-size: 12px; min-height: 18px; margin-top: 4px; }
.login-hint { font-size: 11px; color: var(--text2); margin-top: 14px; padding: 8px; background: #f9fafb; border-radius: 6px; }
.btn-full { width: 100%; padding: 10px; margin-top: 8px; }

/* ===== User chip in topbar ===== */
.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.2); padding: 4px 10px 4px 4px;
  border-radius: 20px; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.3);
  margin-left: 8px;
}
.user-chip:hover { background: rgba(255,255,255,0.3); }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,0.95); color: #2563eb;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.user-info { line-height: 1.2; color: #fff; }
.user-name { font-size: 12px; font-weight: 600; }
.user-roles { font-size: 10px; opacity: 0.9; }

/* Tab badge */
.tab-badge {
  display: inline-block; background: var(--bad); color: #fff;
  border-radius: 10px; padding: 1px 7px; font-size: 11px;
  margin-left: 4px; font-weight: 700;
}

/* ===== New sig card (sequential, role-gated) ===== */
.sig-flow-hint {
  background: #fffbeb; border: 1px solid #fcd34d; color: #78350f;
  padding: 8px 12px; border-radius: 6px; font-size: 12px; margin: 8px 0 12px;
}
.sig-card {
  position: relative;
  background: #f9fafb; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; padding-left: 38px;
}
.sig-card.signed-card { background: #ecfdf5; border-color: #6ee7b7; }
.sig-card.can-sign { background: #eff6ff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.sig-step-num {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.sig-card.signed-card .sig-step-num { background: var(--ok); }
.sig-label { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.sig-required { font-size: 11px; color: var(--text2); margin-bottom: 6px; }
.sig-time.waiting { color: var(--text2); font-size: 12px; }
.sig-time.blocked { color: var(--bad); font-size: 12px; }
.sig-time.pending { color: var(--primary); font-size: 12px; }
.sig-time.signed { color: var(--ok); font-size: 12px; line-height: 1.3; }
.sig-time.signed small { color: var(--text2); }
.sig-actions { margin-top: 6px; }
.sig-actions .btn { width: 100%; }

/* ===== Pending dashboard ===== */
.pending-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px; margin-bottom: 18px;
}
.pending-role-card {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #f59e0b; border-radius: 10px;
  padding: 14px; text-align: center;
}
.pending-role-count { font-size: 28px; font-weight: 700; color: #b45309; }
.pending-role-label { font-size: 12px; color: #78350f; }

.flow-line { display: inline-flex; align-items: center; gap: 4px; }
.flow-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: #e5e7eb; border: 2px solid #d1d5db;
}
.flow-dot.done { background: var(--ok); border-color: var(--ok); }
.flow-dot.next { background: var(--warn); border-color: var(--warn); animation: pulse 1.5s infinite; }
.flow-arrow { color: var(--text2); font-size: 11px; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(217, 119, 6, 0); }
}

/* ===== Admin users ===== */
.role-pill {
  display: inline-block; background: #ede9fe; color: #5b21b6;
  border-radius: 10px; padding: 1px 8px; font-size: 10px; font-weight: 600;
  margin: 1px;
}
.roles-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 4px; max-height: 220px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 6px; padding: 8px;
}
.role-check {
  display: flex; align-items: center; gap: 6px; padding: 4px 8px;
  border-radius: 4px; cursor: pointer; font-size: 12px;
}
.role-check:hover { background: var(--bg); }
.role-check input { margin: 0; }
.role-check small { color: var(--text2); font-size: 10px; }

/* ===== Dashboard ===== */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.dash-card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; box-shadow: var(--shadow);
}
.dash-card.cur { border-left: 6px solid var(--primary); }
.dash-card.prev { border-left: 6px solid #9ca3af; }
.dash-card-title { font-size: 12px; color: var(--text2); margin-bottom: 8px; }
.dash-big { font-size: 48px; font-weight: 800; line-height: 1; color: var(--primary); }
.dash-card.prev .dash-big { color: #9ca3af; }
.dash-bar { height: 8px; background: #e5e7eb; border-radius: 4px; margin: 12px 0; overflow: hidden; }
.dash-bar-fill { height: 100%; background: linear-gradient(90deg, var(--ok), var(--primary)); transition: width 0.3s; }
.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; font-size: 12px; }
.dash-stats .dot { width: 8px; height: 8px; display: inline-block; vertical-align: middle; border-radius: 50%; margin-right: 4px; }
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-bad { background: var(--bad); }
.dot-grey { background: #9ca3af; }
.dot-info { background: var(--info); }
.dash-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text2); }
.dash-h { font-size: 14px; font-weight: 600; margin: 24px 0 10px; padding-left: 10px; border-left: 4px solid var(--primary); }
.dash-table { font-size: 12px; }
.mini-bar { display: inline-block; width: 80px; height: 6px; background: #e5e7eb; border-radius: 3px; vertical-align: middle; overflow: hidden; }
.mini-bar-fill { height: 100%; background: var(--ok); }

/* ===== Backdate banner ===== */
.backdate-banner {
  padding: 12px 14px; border-radius: 8px; margin-bottom: 12px;
  font-size: 13px; line-height: 1.5;
}
.backdate-banner.blocked { background: #fee2e2; border: 1px solid var(--bad); color: #7f1d1d; }
.backdate-banner.pending { background: #fef3c7; border: 1px solid var(--warn); color: #78350f; }
.backdate-banner.ok { background: #dcfce7; border: 1px solid var(--ok); color: #166534; }

/* ===== Admin sub-tabs ===== */
.admin-subtabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px; padding-bottom: 0;
}
.subtab {
  padding: 8px 14px; background: transparent; border: none;
  font-family: inherit; font-size: 13px; cursor: pointer;
  color: var(--text2); border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.subtab:hover { color: var(--text); }
.subtab.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }
.subpanel.hidden { display: none; }

/* ===== Backdate scope tags ===== */
.bd-scope { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.bd-scope.always { background: #fee2e2; color: var(--bad); }
.bd-scope.per_item { background: #fef3c7; color: var(--warn); }
.bd-scope.once { background: #dbeafe; color: var(--primary); }
.bd-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* Responsive */
@media (max-width: 768px) {
  .topbar { flex-direction: column; gap: 10px; align-items: stretch; }
  .topbar-actions { justify-content: center; flex-wrap: wrap; }
  .container { padding: 12px; }
  .matrix .col-name { min-width: 200px; }
  .summary { grid-template-columns: 1fr 1fr; }
}
