/* ============================================================
   BillingKob — Modern Design System
   ============================================================ */

:root {
  /* Colors — Slate + Indigo + Emerald */
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  --indigo-50:  #eef2ff;
  --indigo-100: #e0e7ff;
  --indigo-500: #6366f1;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;

  --emerald-50:  #ecfdf5;
  --emerald-500: #10b981;
  --emerald-600: #059669;

  --amber-50:  #fffbeb;
  --amber-500: #f59e0b;
  --amber-600: #d97706;

  --rose-50:  #fff1f2;
  --rose-500: #f43f5e;
  --rose-600: #e11d48;

  --blue-50: #eff6ff;
  --blue-500: #3b82f6;

  /* Semantic */
  --bg: var(--slate-50);
  --surface: #ffffff;
  --surface-2: var(--slate-50);
  --border: var(--slate-200);
  --border-strong: var(--slate-300);
  --text: var(--slate-900);
  --text-muted: var(--slate-500);
  --text-subtle: var(--slate-400);
  --primary: var(--indigo-600);
  --primary-hover: var(--indigo-700);

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.06);

  /* Radii */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Layout */
  --sidebar-w: 260px;
  --header-h: 64px;
}

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

html, body {
  margin: 0; padding: 0;
  font-family: 'Sarabun', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4, h5 { margin: 0; line-height: 1.3; color: var(--text); font-weight: 600; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 15px; }

p { margin: 0 0 0.75rem; }

code {
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 0.9em;
  padding: 2px 6px;
  background: var(--slate-100);
  border-radius: 4px;
  color: var(--slate-700);
}

/* ============================================================
   Layout
   ============================================================ */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--slate-900);
  color: #cbd5e1;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar .brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar .brand-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 4px;
}
.sidebar .brand-logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--indigo-500), var(--indigo-700));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 18px;
}
.sidebar .brand h1 { color: white; font-size: 18px; margin: 0; letter-spacing: -0.02em; }
.sidebar .brand p { color: var(--slate-400); font-size: 12px; margin: 4px 0 0; }

.sidebar nav { padding: 12px 10px; flex: 1; }
.sidebar .nav-section { margin-bottom: 16px; }
.sidebar .nav-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--slate-500);
  padding: 4px 12px;
  margin-bottom: 4px;
}
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  color: var(--slate-300);
  text-decoration: none;
  font-size: 14px;
  border-radius: 8px;
  transition: all 0.15s;
  margin-bottom: 2px;
}
.sidebar nav a:hover {
  background: rgba(255,255,255,0.05);
  color: white;
  text-decoration: none;
}
.sidebar nav a.active {
  background: var(--indigo-600);
  color: white;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3);
}
.sidebar nav a .icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar .user-box {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px;
  color: var(--slate-300);
}
.sidebar .u-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--indigo-500);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 600; font-size: 14px;
  flex-shrink: 0; overflow: hidden;
}
.sidebar .u-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar .u-info { flex: 1; min-width: 0; }
.sidebar .u-name { font-size: 13px; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .u-email { font-size: 11px; color: var(--slate-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .u-logout {
  color: var(--slate-400); padding: 4px; border-radius: 4px;
  display: flex; align-items: center;
}
.sidebar .u-logout:hover { color: white; background: rgba(255,255,255,0.08); }
.sidebar .u-logout svg { width: 16px; height: 16px; }

.sidebar .footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 11px;
  color: var(--slate-500);
}

.main {
  flex: 1;
  padding: 32px 40px;
  max-width: 1280px;
  width: 100%;
}

.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
}
.page-header .title-group h1 {
  font-size: 24px;
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}
.page-header .title-group p {
  color: var(--text-muted);
  margin: 0;
  font-size: 14px;
}
.page-header .actions {
  display: flex; gap: 8px; flex-shrink: 0;
}

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin: -20px -20px 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.card-header h3 { margin: 0; font-size: 15px; }
.card-header .hint { font-size: 13px; color: var(--text-muted); }
.card-body { }
.card-footer {
  margin: 16px -20px -20px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  display: flex; justify-content: flex-end; gap: 8px;
}

.section-title {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}
.section-title .icon { width: 18px; height: 18px; color: var(--text-muted); }

/* ============================================================
   Forms
   ============================================================ */

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.field { display: flex; flex-direction: column; }
.field.full { grid-column: 1 / -1; }
.field label {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
  display: flex; align-items: center; gap: 4px;
}
.field label .req { color: var(--rose-500); }
.field label .hint-icon { color: var(--text-subtle); cursor: help; }

.field input, .field select, .field textarea {
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: all 0.12s;
  outline: none;
}
.field input:hover, .field select:hover, .field textarea:hover {
  border-color: var(--slate-400);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-subtle); }
.field input[readonly] {
  background: var(--slate-50);
  color: var(--text-muted);
  cursor: not-allowed;
}
.field textarea { min-height: 72px; resize: vertical; font-family: inherit; }
.field .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.input-group {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: all 0.12s;
}
.input-group:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15); }
.input-group input { border: none; flex: 1; }
.input-group input:focus { box-shadow: none; }
.input-group .addon {
  background: var(--slate-50);
  padding: 0 12px;
  display: flex; align-items: center;
  color: var(--text-muted);
  font-size: 13px;
  border-left: 1px solid var(--border);
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
}
.btn .icon { width: 16px; height: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--slate-50);
  border-color: var(--slate-400);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--slate-100);
  color: var(--text);
}

.btn-success {
  background: var(--emerald-500);
  color: white;
}
.btn-success:hover:not(:disabled) { background: var(--emerald-600); }

.btn-danger {
  background: var(--rose-500);
  color: white;
}
.btn-danger:hover:not(:disabled) { background: var(--rose-600); }

.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-lg { padding: 11px 20px; font-size: 15px; }
.btn-icon { padding: 8px; }
.btn-icon .icon { width: 16px; height: 16px; }

/* ============================================================
   Tables
   ============================================================ */

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table th {
  text-align: left;
  padding: 11px 14px;
  background: var(--slate-50);
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
table tbody tr:last-child td { border-bottom: none; }
table tbody tr:hover td { background: var(--slate-50); }
table .right { text-align: right; }
table .center { text-align: center; }
table .small { font-size: 13px; }

.table-actions { display: flex; gap: 4px; justify-content: center; }

/* ============================================================
   Stats cards
   ============================================================ */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.stat-card .stat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-card .stat-icon .icon { width: 22px; height: 22px; }
.stat-card.primary .stat-icon { background: var(--indigo-50); color: var(--indigo-600); }
.stat-card.success .stat-icon { background: var(--emerald-50); color: var(--emerald-600); }
.stat-card.warning .stat-icon { background: var(--amber-50); color: var(--amber-600); }
.stat-card.neutral .stat-icon { background: var(--slate-100); color: var(--slate-600); }
.stat-card .stat-body { flex: 1; min-width: 0; }
.stat-card .label {
  font-size: 13px; color: var(--text-muted);
  margin-bottom: 4px; font-weight: 500;
}
.stat-card .value {
  font-size: 22px; font-weight: 700; color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.stat-card .sub {
  font-size: 12px; color: var(--text-subtle); margin-top: 2px;
}

/* ============================================================
   Badges
   ============================================================ */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}
.badge-pending    { background: var(--amber-50); color: var(--amber-600); border: 1px solid #fde68a; }
.badge-transferred{ background: var(--emerald-50); color: var(--emerald-600); border: 1px solid #a7f3d0; }
.badge-cancelled  { background: var(--rose-50); color: var(--rose-600); border: 1px solid #fecdd3; }
.badge-draft      { background: var(--slate-100); color: var(--slate-600); border: 1px solid var(--slate-200); }
.badge-signed     { background: var(--emerald-50); color: var(--emerald-600); border: 1px solid #a7f3d0; }
.badge-issued     { background: var(--blue-50); color: var(--blue-500); border: 1px solid #bfdbfe; }

.badge .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}

/* ============================================================
   Toast
   ============================================================ */

.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 10000;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--slate-900);
  color: white;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 400px;
  display: flex; align-items: center; gap: 10px;
  pointer-events: auto;
  animation: slideIn 0.18s ease-out;
  font-size: 14px;
}
.toast .icon { width: 18px; height: 18px; flex-shrink: 0; }
.toast.success { background: var(--emerald-600); }
.toast.error { background: var(--rose-600); }
.toast.info { background: var(--slate-800); }
@keyframes slideIn {
  from { transform: translateX(16px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   Modal
   ============================================================ */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn 0.15s;
}
.modal-overlay.show { display: flex; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 90%; max-width: 720px;
  max-height: 90vh; overflow: hidden;
  box-shadow: var(--shadow-xl);
  display: flex; flex-direction: column;
  animation: slideUp 0.2s;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-header .close-btn {
  width: 32px; height: 32px;
  background: transparent; border: none; cursor: pointer;
  border-radius: 6px; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.modal-header .close-btn:hover { background: var(--slate-100); color: var(--text); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--surface-2);
}

/* ============================================================
   Empty states
   ============================================================ */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .icon-wrap {
  width: 56px; height: 56px;
  margin: 0 auto 12px;
  background: var(--slate-100);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--slate-400);
}
.empty-state .icon-wrap .icon { width: 28px; height: 28px; }
.empty-state h4 { color: var(--text); margin-bottom: 4px; font-size: 16px; }
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ============================================================
   Workflow / stepper (for dashboard)
   ============================================================ */

.workflow {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  margin: 8px 0;
}
.workflow .step {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 16px 12px;
  text-align: center;
  position: relative;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s;
}
.workflow .step:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.workflow .step:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.workflow .step:not(:last-child) { border-right: none; }
.workflow .step:hover { background: var(--slate-50); text-decoration: none; }
.workflow .step:not(:last-child)::after {
  content: '';
  position: absolute;
  right: -8px; top: 50%;
  width: 16px; height: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: none; border-bottom: none;
  transform: translateY(-50%) rotate(45deg);
  z-index: 2;
}
.workflow .step .freq {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.workflow .step .freq-once    { background: var(--slate-100); color: var(--slate-600); }
.workflow .step .freq-every   { background: var(--indigo-50); color: var(--indigo-600); }
.workflow .step .freq-monthly { background: var(--amber-50); color: var(--amber-600); }
.workflow .step .freq-ondemand{ background: #dbeafe; color: #2563eb; }

.workflow .step .step-num {
  width: 28px; height: 28px;
  background: var(--indigo-50);
  color: var(--indigo-600);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 8px;
}
.workflow .step .step-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.workflow .step .step-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.workflow .step.done .step-num { background: var(--emerald-500); color: white; }

.workflow-legend {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.workflow-legend .lg-item {
  display: inline-flex; align-items: center; gap: 6px;
}
.workflow-legend .lg-dot {
  width: 10px; height: 10px; border-radius: 50%;
}

/* ============================================================
   Info banners
   ============================================================ */

.banner {
  padding: 14px 16px;
  border-radius: var(--radius);
  display: flex; gap: 12px;
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid;
}
.banner .icon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.banner .banner-body { flex: 1; }
.banner .banner-title { font-weight: 600; margin-bottom: 2px; }
.banner-info { background: var(--blue-50); border-color: #bfdbfe; color: #1e40af; }
.banner-info .icon { color: var(--blue-500); }
.banner-warning { background: var(--amber-50); border-color: #fde68a; color: #92400e; }
.banner-warning .icon { color: var(--amber-600); }
.banner-success { background: var(--emerald-50); border-color: #a7f3d0; color: #065f46; }
.banner-success .icon { color: var(--emerald-600); }

/* ============================================================
   Checkbox
   ============================================================ */

.cb {
  appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  cursor: pointer;
  position: relative;
  transition: all 0.12s;
  vertical-align: middle;
}
.cb:hover { border-color: var(--primary); }
.cb:checked {
  background: var(--primary);
  border-color: var(--primary);
}
.cb:checked::after {
  content: '';
  position: absolute;
  left: 4px; top: 0px;
  width: 5px; height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ============================================================
   Document layout (สำหรับพิมพ์/preview)
   ============================================================ */

.doc-wrap {
  background: #fff;
  width: 210mm;
  min-height: 297mm;
  margin: 24px auto;
  padding: 20mm;
  box-shadow: var(--shadow-lg);
  color: #000;
  font-size: 14px;
  line-height: 1.7;
  border-radius: 4px;
}
.doc-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 2px solid var(--slate-800);
  padding-bottom: 14px; margin-bottom: 20px;
}
.doc-header .left h1 { margin: 0 0 4px; font-size: 20px; color: var(--slate-900); }
.doc-header .left p { margin: 2px 0; font-size: 12px; color: var(--slate-700); }
.doc-header .right { text-align: right; font-size: 13px; }
.doc-header .right h2 { font-size: 18px; color: var(--slate-900); margin-bottom: 4px; }
.doc-header .right .doc-no { font-size: 15px; font-weight: 700; color: var(--slate-900); }

.doc-section { margin-bottom: 18px; }
.doc-section h4 {
  margin: 0 0 8px; padding-bottom: 4px;
  border-bottom: 1px solid var(--slate-300);
  font-size: 13px;
  color: var(--slate-700);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doc-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.doc-table th, .doc-table td { border: 1px solid var(--slate-300); padding: 7px 9px; }
.doc-table th { background: var(--slate-50); font-weight: 600; color: var(--slate-700); }
.doc-table .right { text-align: right; }
.doc-table .center { text-align: center; }
.doc-table tfoot td { font-weight: 600; background: #fafafa; }
.doc-table .highlight { background: #fef9c3; }

.doc-signature {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 60px; margin-top: 56px; text-align: center;
}
.doc-signature .sig-line {
  border-top: 1px solid var(--slate-800);
  padding-top: 6px; margin-top: 60px;
  font-size: 13px;
}
.doc-signature .role { font-size: 12px; color: var(--slate-600); margin-top: 2px; }

/* ============================================================
   Print
   ============================================================ */

@media print {
  .sidebar, .page-header, .no-print { display: none !important; }
  body { background: #fff; }
  .layout { display: block; }
  .main { padding: 0; max-width: none; }
  .doc-wrap {
    box-shadow: none;
    margin: 0;
    width: auto; min-height: auto;
    padding: 0;
    border-radius: 0;
  }
  @page { size: A4; margin: 15mm; }
}

/* ============================================================
   Utility
   ============================================================ */

.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-danger { color: var(--rose-500); }
.text-success { color: var(--emerald-600); }
.text-primary { color: var(--primary); }
.font-mono { font-family: ui-monospace, Consolas, monospace; }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.items-center { align-items: center; }
.justify-end { justify-content: flex-end; }
.grow { flex-grow: 1; }

.hidden { display: none !important; }

.divider {
  height: 1px; background: var(--border);
  margin: 16px 0;
}

/* Responsive */
@media (max-width: 1024px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .workflow { grid-template-columns: repeat(3, 1fr); }
  .workflow .step:nth-child(1) { border-radius: var(--radius) 0 0 0; }
  .workflow .step:nth-child(3) { border-radius: 0 var(--radius) 0 0; border-right: 1px solid var(--border); }
  .workflow .step:nth-child(4) { border-radius: 0 0 0 var(--radius); }
  .workflow .step:nth-child(6) { border-radius: 0 0 var(--radius) 0; border-right: 1px solid var(--border); }
  .workflow .step:not(:last-child)::after { display: none; }
}
@media (max-width: 768px) {
  .sidebar {
    width: 72px;
    position: sticky;
  }
  .sidebar .brand p, .sidebar nav a span.label, .sidebar .nav-label, .sidebar .footer {
    display: none;
  }
  .sidebar nav a { justify-content: center; padding: 12px; }
  .main { padding: 20px; }
  .form-grid, .form-grid.cols-3, .form-grid.cols-4 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header .actions { flex-wrap: wrap; }
  .doc-wrap { width: 100%; margin: 0; padding: 16px; }
}
