/* ESignApp — Main Stylesheet */

:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-light: #dbeafe;

  --success: #22c55e;
  --success-light: #dcfce7;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --error: #ef4444;
  --error-light: #fee2e2;
  --info: #0ea5e9;
  --info-light: #e0f2fe;

  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  --sidebar-width: 240px;
  --topbar-height: 60px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);

  --font: system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}

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

html { font-size: 15px; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--gray-800);
  background: var(--gray-100);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* =====================
   APP LAYOUT
   ===================== */

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--gray-900);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  transition: transform .25s ease;
}

.sidebar-header {
  padding: 20px 20px 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-logo {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  line-height: 1;
}

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}

.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--gray-500);
  padding: 12px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--gray-400);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
  border-radius: 0;
}

.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}

.nav-item.active {
  background: var(--brand);
  color: #fff;
}

.nav-item-danger {
  color: #fca5a5 !important;
  margin-top: auto;
}

.nav-item-danger:hover {
  background: rgba(239,68,68,.15) !important;
  color: #f87171 !important;
}

.nav-icon { font-size: 14px; width: 18px; text-align: center; }

/* Main wrapper */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  color: var(--gray-600);
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
  flex: 1;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.user-name { font-size: 13px; font-weight: 500; color: var(--gray-600); }

.main-content {
  padding: 24px;
  flex: 1;
}

/* =====================
   CARDS
   ===================== */

.card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-800);
}

.card-body { padding: 20px; }

.mb-24 { margin-bottom: 24px; }

/* =====================
   BUTTONS
   ===================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, opacity .15s;
  line-height: 1.4;
  white-space: nowrap;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }

.btn-outline { background: #fff; color: var(--gray-700); border-color: var(--gray-300); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-danger { background: var(--error); color: #fff; border-color: var(--error); }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 5px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; }

.inline-form { display: inline-flex; }

/* =====================
   FORMS
   ===================== */

.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-label.required::after {
  content: ' *';
  color: var(--error);
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--gray-800);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  font-family: var(--font);
}

.form-control:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.form-control-sm { padding: 6px 10px; font-size: 13px; }

textarea.form-control { resize: vertical; min-height: 80px; }

select.form-control { cursor: pointer; }

.form-hint { font-size: 12px; color: var(--gray-500); margin: 4px 0 0; }

.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--gray-700);
}

.hidden { display: none !important; }

/* =====================
   TABLES
   ===================== */

.table-responsive { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--gray-50); }

/* =====================
   BADGES
   ===================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
}

.badge-gray   { background: var(--gray-100); color: var(--gray-600); }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-cyan   { background: #cffafe; color: #0e7490; }
.badge-amber  { background: #fef3c7; color: #b45309; }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-dark   { background: var(--gray-700); color: #fff; }

/* =====================
   ALERTS
   ===================== */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert-success { background: var(--success-light); color: #166534; border-color: #86efac; }
.alert-error   { background: var(--error-light); color: #991b1b; border-color: #fca5a5; }
.alert-warning { background: var(--warning-light); color: #92400e; border-color: #fcd34d; }
.alert-info    { background: var(--info-light); color: #0c4a6e; border-color: #7dd3fc; }

/* =====================
   AUTH PAGES
   ===================== */

.auth-body { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; background: var(--gray-100); }

.auth-container { width: 100%; max-width: 420px; padding: 0 16px; }

.auth-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.auth-header {
  background: var(--brand);
  padding: 28px 32px;
  text-align: center;
}

.auth-header h1 { margin: 0; color: #fff; font-size: 22px; }
.auth-header p  { margin: 6px 0 0; color: rgba(255,255,255,.75); font-size: 14px; }

.auth-body-inner { padding: 28px 32px; }

.auth-footer { text-align: center; font-size: 12px; color: var(--gray-500); margin-top: 16px; }
.auth-footer a { color: var(--brand); }

/* =====================
   DASHBOARD
   ===================== */

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon-blue  { background: #dbeafe; }
.stat-icon-amber { background: #fef3c7; }
.stat-icon-green { background: #dcfce7; }
.stat-icon-teal  { background: #cffafe; }

.stat-value { font-size: 22px; font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

/* =====================
   PAGE LAYOUT HELPERS
   ===================== */

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.page-cols {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

.page-col-main { min-width: 0; }
.page-col-side { min-width: 0; }

/* =====================
   ACTIVITY / AUDIT
   ===================== */

.activity-list { padding: 4px 0; }

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--gray-100);
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.activity-icon-green { background: var(--success-light); }

.activity-title { font-size: 14px; color: var(--gray-800); }
.activity-title a { color: var(--brand); text-decoration: none; }
.activity-meta { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* Audit timeline */
.audit-timeline { padding: 16px 20px; }

.audit-event {
  display: flex;
  gap: 12px;
  padding-bottom: 16px;
  position: relative;
}

.audit-event:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 20px;
  bottom: 0;
  width: 2px;
  background: var(--gray-200);
}

.audit-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brand);
  flex-shrink: 0;
  margin-top: 4px;
}

.audit-label { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.audit-desc  { font-size: 13px; color: var(--gray-600); margin: 2px 0; }
.audit-meta  { font-size: 11px; color: var(--gray-400); }

/* =====================
   SIGNERS
   ===================== */

.signer-card {
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-100);
}

.signer-card:last-child { border-bottom: none; }

.signer-name  { font-weight: 600; font-size: 14px; }
.signer-email { font-size: 12px; color: var(--gray-500); }
.signer-role  { font-size: 12px; color: var(--gray-400); font-style: italic; }
.signer-meta  { font-size: 11px; color: var(--gray-500); margin-top: 4px; }

.signer-status-block { margin-top: 8px; }
.signer-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

.signer-entry { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.signer-num   { font-size: 13px; font-weight: 700; color: var(--gray-600); margin-bottom: 12px; }

/* =====================
   LINE ITEMS
   ===================== */

.line-items-table { overflow-x: auto; }

.line-items-header {
  display: grid;
  grid-template-columns: 2fr 2fr 80px 120px 100px 40px;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-500);
  padding: 0 0 8px;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 8px;
}

.line-item-row {
  display: grid;
  grid-template-columns: 2fr 2fr 80px 120px 100px 40px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.totals-section {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}

.totals-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
}

.totals-row label { font-size: 13px; font-weight: 600; color: var(--gray-600); min-width: 80px; text-align: right; }

.total-row { border-top: 2px solid var(--gray-800); padding-top: 8px; }

.grand-total { font-size: 20px; font-weight: 700; color: var(--brand); }

.input-prefix { display: flex; align-items: center; border: 1px solid var(--gray-300); border-radius: var(--radius); overflow: hidden; }
.input-prefix span { padding: 9px 10px; background: var(--gray-50); border-right: 1px solid var(--gray-300); font-size: 13px; color: var(--gray-500); }
.input-prefix input { border: none; border-radius: 0; flex: 1; width: 100px; }
.input-prefix input:focus { box-shadow: none; border: none; outline: none; }

/* =====================
   EDITOR
   ===================== */

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px;
  background: var(--gray-50);
  border: 1px solid var(--gray-300);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  flex-wrap: wrap;
}

.editor-toolbar button {
  padding: 5px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  transition: .15s;
}

.editor-toolbar button:hover { background: var(--gray-100); }

.editor-toolbar select {
  padding: 4px 8px;
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}

.toolbar-sep { color: var(--gray-300); font-size: 18px; padding: 0 2px; }

.rich-editor {
  min-height: 350px;
  border: 1px solid var(--gray-300);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 16px;
  font-size: 14px;
  line-height: 1.7;
  background: #fff;
  outline: none;
  overflow-y: auto;
}

.rich-editor:focus { border-color: var(--brand); }

.rich-editor-lg { min-height: 500px; }

.rich-editor h1, .rich-editor h2, .rich-editor h3 { color: var(--gray-900); margin: 16px 0 8px; }
.rich-editor p { margin: 8px 0; }
.rich-editor ul, .rich-editor ol { padding-left: 24px; }

/* =====================
   DOCUMENT PREVIEW
   ===================== */

.doc-preview {
  font-size: 14px;
  line-height: 1.8;
  color: var(--gray-800);
  max-height: 600px;
  overflow-y: auto;
  padding: 4px 0;
}

.doc-preview h1, .doc-preview h2, .doc-preview h3 { color: var(--gray-900); }
.doc-preview table { width: 100%; border-collapse: collapse; }
.doc-preview td, .doc-preview th { padding: 6px 8px; border: 1px solid var(--gray-200); }

/* =====================
   DETAIL LIST
   ===================== */

.detail-list { font-size: 13px; }

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
}

.detail-row:last-child { border-bottom: none; }
.detail-row > span:first-child { color: var(--gray-500); flex-shrink: 0; }
.detail-row > span:last-child { text-align: right; }

/* =====================
   TOTALS DISPLAY
   ===================== */

.totals-display { padding: 12px 0; }
.total-line {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
  color: var(--gray-600);
}

.total-final {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  border-top: 2px solid var(--gray-200);
  padding-top: 8px;
  margin-top: 4px;
}

/* =====================
   TEMPLATE GRID
   ===================== */

.section-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-500);
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--gray-200);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.template-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: border-color .15s, box-shadow .15s;
}

.template-card:hover { border-color: var(--brand); box-shadow: var(--shadow-md); }

.template-icon { font-size: 28px; margin-bottom: 10px; }
.template-name { font-weight: 600; font-size: 14px; color: var(--gray-800); margin-bottom: 4px; }
.template-desc { font-size: 12px; color: var(--gray-500); margin-bottom: 12px; line-height: 1.4; }
.template-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* =====================
   QUICK ACTIONS
   ===================== */

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 20px 20px;
}

.quick-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--gray-700);
  font-size: 13px;
  font-weight: 600;
  transition: .15s;
}

.quick-btn:hover { background: var(--brand-light); border-color: var(--brand); color: var(--brand); }

.quick-icon { font-size: 16px; }

/* =====================
   PAGINATION
   ===================== */

.pagination {
  display: flex;
  gap: 4px;
  padding: 16px 20px;
  border-top: 1px solid var(--gray-200);
  justify-content: center;
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
  transition: .15s;
}

.page-link:hover  { background: var(--gray-100); }
.page-link.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* =====================
   MISC UTILITIES
   ===================== */

.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--gray-500); }
.text-red     { color: var(--error); }
.text-success { color: var(--success); }

.p-16   { padding: 16px; }
.p-48   { padding: 48px; }
.mt-4   { margin-top: 4px; }
.mt-8   { margin-top: 8px; }
.mt-12  { margin-top: 12px; }
.mt-16  { margin-top: 16px; }
.py-32  { padding-top: 32px; padding-bottom: 32px; }

.w-full { width: 100%; }

.link-strong { font-weight: 600; color: var(--gray-800); text-decoration: none; }
.link-strong:hover { color: var(--brand); }
.link-primary { color: var(--brand); text-decoration: none; font-weight: 600; }

.doc-id { background: var(--gray-100); padding: 2px 8px; border-radius: 4px; font-size: 12px; font-family: monospace; color: var(--gray-600); }

.signer-progress { font-size: 13px; font-weight: 600; color: var(--gray-600); background: var(--gray-100); padding: 2px 8px; border-radius: 20px; }
.signer-progress.complete { background: var(--success-light); color: #15803d; }

.action-btns { display: flex; gap: 4px; flex-wrap: wrap; }

.legal-notice {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 12px;
  color: #92400e;
  line-height: 1.5;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.tab {
  padding: 10px 18px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-600);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: .15s;
}

.tab:hover { color: var(--brand); }
.tab.active { color: var(--brand); border-color: var(--brand); }

.webhook-entry { background: var(--gray-50); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }

code { background: var(--gray-100); padding: 2px 6px; border-radius: 4px; font-size: 12px; font-family: monospace; }

/* Line items preview */
.line-items-preview { margin-top: 24px; border-top: 1px solid var(--gray-200); padding-top: 20px; }

/* =====================
   RESPONSIVE
   ===================== */

@media (max-width: 1100px) {
  .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid  { grid-template-columns: 1fr; }
  .template-grid   { grid-template-columns: repeat(2, 1fr); }
  .page-cols       { grid-template-columns: 1fr; }
  .form-row-3      { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }

  .sidebar {
    transform: translateX(-100%);
    width: 260px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 16px rgba(0,0,0,.2);
  }

  .sidebar-close { display: block; }
  .menu-toggle   { display: block; }
  .main-wrapper  { margin-left: 0; }

  .main-content  { padding: 16px; }
  .topbar        { padding: 0 16px; }

  .dashboard-stats { grid-template-columns: 1fr 1fr; }
  .template-grid   { grid-template-columns: 1fr; }
  .form-row-2      { grid-template-columns: 1fr; }
  .form-row-3      { grid-template-columns: 1fr; }
  .line-items-header { display: none; }
  .line-item-row   { grid-template-columns: 1fr 1fr; grid-gap: 6px; }
  .page-toolbar    { flex-direction: column; align-items: stretch; }
  .toolbar-right   { justify-content: flex-end; }
}

@media (max-width: 480px) {
  .dashboard-stats { grid-template-columns: 1fr; }
  .auth-body-inner { padding: 20px; }
  .stat-card       { padding: 14px; }
}
