/* ═══════════════════════════════════════════════════════════════
   DOCFORGE – Light theme only (cleaned up)
   Navbar height increased to 72px (was 56px)
   ═══════════════════════════════════════════════════════════════ */

/* ── Design tokens ──────────────────────────────────────── */
:root {
  --bg:                    #FFFFFF;
  --bg-card:               #FFFFFF;
  --bg-elevated:           #F7F9F8;
  --surface-header:       #CBD3CF;
  --surface-sidebar:      #D3DAD6;
  --bg-hover:              #F0F3F1;
  --border:                #DCE3DF;
  --border-light:          #CBD3CF;
  --border-strong:         #53685C;

  --text:                  #304238;
  --text-muted:            #53685C;
  --text-faint:            #84928A;
  --text-heading:          #304238;
  --text-subtle:           #6C7D73;

  --accent:                #4C6E5D;
  --accent-hover:          #3E5D4D;
  --accent-active:         #304238;
  --primary-action:        #4C6E5D;
  --primary-action-hover:  #24362D;
  --accent-disabled:       #EDF1EE;
  --accent-disabled-fg:    #53685C;
  --accent-subtle:         rgba(76, 110, 93, 0.09);
  --accent-glow:           rgba(76, 110, 93, 0.18);
  --accent-focus:          #304238;
  --accent-fg:             #FFFFFF;
  --surface-muted:         #EDF1EE;

  --success:               #3F6B52;
  --success-bg:            #EDF3EE;
  --warning:               #9A4D00;
  --warning-bg:            #FBF4E6;
  --error:                 #B91C1C;
  --error-bg:              #FEF2F2;
  --info:                  #304238;
  --info-bg:               #EDF1EE;
  --purple:                #6B5B7A;
  --purple-bg:             #F3F0F6;

  --green:                 #3F6B52;
  --amber:                 #9A4D00;
  --red:                   #B91C1C;

  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    16px;

  --font:         'DM Sans', system-ui, sans-serif;
  --font-mono:    'DM Mono', 'Fira Code', monospace;

  --shadow-sm:    0 1px 2px rgba(0,0,0,0.05);
  --shadow:       0 4px 6px rgba(0,0,0,0.07);
  --shadow-lg:    0 12px 24px rgba(0,0,0,0.1);
  --transition:   0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  scrollbar-width: none;
}
html::-webkit-scrollbar { display: none; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
body { scrollbar-width: none; }
body::-webkit-scrollbar { display: none; }
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--accent);
  border: 1px solid var(--border);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary { background: var(--primary-action); color: #fff; border-color: var(--primary-action); }
.btn-primary:hover {
  background: var(--primary-action-hover);
  border-color: var(--primary-action-hover);
  color: #fff;
  box-shadow: 0 0 0 4px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-primary:disabled, .btn-primary[disabled] {
  background: var(--accent-disabled);
  border-color: var(--accent-disabled);
  color: var(--accent-disabled-fg);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
.btn:focus-visible { outline: 2px solid var(--accent-focus); outline-offset: 2px; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border); }
.btn-sm { font-size: 0.82rem; padding: 6px 14px; border-radius: var(--radius-sm); }
.btn-full { width: 100%; justify-content: center; }
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1.25rem;
}

.download-success-card {
  position: sticky;
  top: 0.75rem;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: min(100%, 600px);
  margin: 0 auto 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--success);
  border-radius: 8px;
  background: #fff;
  color: var(--success);
  box-shadow: 0 8px 24px rgba(48, 66, 56, 0.12);
}
.download-success-card[hidden] { display: none; }
.download-success-icon {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--success-bg);
  font-weight: 700;
}
.download-success-content { display: flex; flex: 1; min-width: 0; flex-direction: column; }
.download-success-content span {
  overflow-wrap: anywhere;
  color: #4b5563;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.preview-document-link { width: 100%; justify-content: flex-start; }

/* ── Auth layout ─────────────────────────────────────────── */
.auth-body { background: var(--bg); display: flex; align-items: stretch; }
.auth-split { display: flex; width: 100%; min-height: 100vh; }
.auth-left {
  flex: 1;
  background: linear-gradient(135deg, #F7F8F7 0%, #EDF1EE 50%, #F7F8F7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}
.auth-left::before {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(83, 104, 92, 0.15) 0%, transparent 70%);
  top: -80px; left: -80px;
  pointer-events: none;
}
.auth-left::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(83, 104, 92, 0.08) 0%, transparent 70%);
  bottom: -60px; right: -60px;
  pointer-events: none;
}
.auth-left-inner { max-width: 400px; position: relative; z-index: 1; }
.auth-login-page .auth-left { background: linear-gradient(135deg, #304238 0%, #4C6E5D 55%, #53685C 100%); }
.auth-login-page .auth-left-inner { width: 100%; max-width: 440px; }
.auth-suite-intro { color: var(--text-muted); }
.auth-suite-title { margin: 0 0 1.5rem; padding: 1.1rem 1.25rem; border-left: 4px solid var(--border-light); border-radius: 0 12px 12px 0; background: linear-gradient(110deg, rgba(255, 255, 255, 0.16), rgba(203, 211, 207, 0.08)); color: #FFFFFF; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(1.9rem, 3vw, 2.5rem); font-weight: 600; letter-spacing: -0.035em; line-height: 1.12; }
.auth-suite-title span { display: block; color: var(--border-light); }
.auth-suite-copy { display: grid; gap: 0.9rem; }
.auth-suite-copy p { margin: 0; color: #F7F9F8; font-size: 0.96rem; line-height: 1.75; }
.brand-link { display: flex; align-items: center; gap: 10px; margin-bottom: 4rem; color: var(--text); text-decoration: none; }
.brand-icon-lg { font-size: 2rem; color: var(--accent); line-height: 1; filter: drop-shadow(0 0 12px rgba(83, 104, 92, 0.4)); }
.brand-name-lg { font-weight: 600; letter-spacing: -0.02em; }
.auth-tagline h1 {
  font-size: 2.6rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.15;
  margin-bottom: 1.2rem;
  color: var(--text);
}
.auth-tagline h1 em { font-style: italic; color: var(--accent); font-weight: 300; }
.auth-tagline p { color: var(--text-muted); font-size: 1rem; line-height: 1.7; margin-bottom: 2.5rem; }
.auth-features { display: flex; flex-direction: column; gap: 12px; }
.af-item { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 0.9rem; }
.af-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; box-shadow: 0 0 8px rgba(83, 104, 92, 0.6); }

/* right panel */
.auth-right {
  width: 480px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2.5rem;
  background: #f8f9fa;
  border-left: 1px solid var(--border);
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card-header { margin-bottom: 2rem; }
.auth-card-header h2 { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.03em; margin-bottom: 4px; }
.auth-card-header p { color: var(--text-muted); font-size: 0.92rem; }

/* Forms */
.auth-form { display: flex; flex-direction: column; gap: 18px; margin-bottom: 1.5rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.85rem; font-weight: 500; color: var(--text-muted); letter-spacing: 0.01em; }
.form-group input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.92rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  outline: none;
}
.form-group input::placeholder { color: var(--text-muted); }
.form-group input:focus { border-color: var(--accent); outline: 2px solid var(--accent-focus); outline-offset: 2px; box-shadow: 0 0 0 4px var(--accent-glow); }
.form-group select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.92rem;
  width: 100%;
}

/* Help text */
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

/* ── Number input – remove spin buttons + standard appearance ── */
input[type='number'] { -moz-appearance: textfield; appearance: none; }
input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.input-wrap { position: relative; }
.input-wrap input { padding-right: 42px; }
.eye-toggle {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--text-muted);
  width: 44px; height: 44px;
  padding: 0; display: flex; align-items: center; justify-content: center;
  transition: color var(--transition);
}
.eye-toggle:hover { color: var(--text-muted); }

.pw-strength-wrap { display: flex; align-items: center; gap: 10px; margin-top: -6px; }
.pw-strength-bar { flex: 1; height: 3px; background: var(--border); border-radius: 99px; overflow: hidden; }
.pw-strength-fill { height: 100%; width: 0%; border-radius: 99px; transition: width 0.3s, background 0.3s; }
.pw-strength-label { font-size: 0.75rem; color: var(--text-muted); min-width: 50px; text-align: right; }

/* Alerts */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius); font-size: 0.88rem; margin-bottom: 4px; line-height: 1.5; }
.alert-error, .alert-danger { background: var(--error-bg); border: 1px solid var(--error); color: var(--error); }
.alert-error svg, .alert-danger svg { flex-shrink: 0; margin-top: 1px; }
.alert-danger .alert-inner { width: 100%; }
.alert-danger .alert-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 0.5rem; }
.alert-danger ul { margin: 0.5rem 0 0.75rem 1.1rem; padding: 0; }
.alert-danger p { margin: 0.25rem 0 0; }
.alert-close { border: none; background: transparent; color: inherit; font-size: 1.2rem; line-height: 1; cursor: pointer; opacity: 0.7; }
.alert-close:hover { opacity: 1; }

.auth-footer { text-align: center; font-size: 0.87rem; color: var(--text-muted); }
.auth-footer a { color: var(--accent); font-weight: 500; }
.auth-footer a:hover { color: var(--accent-hover); }

/* ── App layout ──────────────────────────────────────────── */
.app-body { display: flex; flex-direction: column; min-height: 100vh; overflow-x: hidden; background: #f1f2f1; }

/* Shared application navbar */
.navbar {
  height: 80px;
  background: var(--surface-header);
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  position: relative;
  z-index: 40;
}
.navbar-left { display: flex; align-items: center; gap: 12px; }
.navbar-brand { display: flex; align-items: center; min-width: 0; min-height: 44px; text-decoration: none; }
.navbar-logo { display: block; width: 170px; max-width: 100%; height: auto; flex: 0 1 auto; object-fit: contain; }
.navbar-right { display: flex; align-items: center; gap: 16px; }
.nav-user { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: var(--text-muted); }
.navbar .nav-logout-form .btn { background: transparent; border-color: transparent; }
.navbar .nav-logout-form .btn:hover { background: var(--bg-hover); border-color: transparent; }
.user-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(76, 110, 93, 0.12); }
.nav-user-avatar { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-subtle); border: 1px solid var(--border-light); color: var(--text-heading); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em; }
.nav-user-email { color: var(--text); }

.role-badge { display: inline-block; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.02em; padding: 3px 9px; border-radius: 99px; }
.role-user, .role-admin, .role-superadmin { background: var(--accent-subtle); color: var(--text-heading); }

.app-shell { display: flex; flex: 1; overflow: visible; background: #f1f2f1; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0;
  transition: transform var(--transition), left var(--transition);
  z-index: 30;
}
.sidebar-nav { flex: 1; padding: 0 0.75rem; display: flex; flex-direction: column; gap: 2px; }
.sidebar-link { display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: var(--radius); font-size: 0.88rem; font-weight: 500; color: var(--text-muted); text-decoration: none; transition: all var(--transition); }
.sidebar-link:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-link.active { background: var(--accent); color: #FFFFFF; }
.sidebar-link svg { flex-shrink: 0; }

.sidebar-bottom { padding: 1rem 0.75rem 0; border-top: 1px solid var(--border); margin-top: 1rem; }
.sidebar-user-card { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); background: var(--bg-elevated); }
.suc-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-subtle); color: var(--accent); font-size: 0.8rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.suc-info { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.suc-email { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main-content { flex: 1; overflow: visible; padding: 1rem; width: 100%; min-width: 0; background: #f1f2f1; }
.main-content-inner { width: 100%; max-width: 1600px; margin-inline: auto; }
.field-error { display: block; margin-top: 0.35rem; color: var(--error); font-size: 0.8rem; line-height: 1.4; }
#addUserForm input[aria-invalid="true"] { border-color: var(--error); }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 2rem; }
.page-title { font-family: 'Manline Slabs', Georgia, 'Times New Roman', serif; font-size: clamp(1.24rem, 1.6vw, 1.6rem); font-weight: 600; letter-spacing: -0.035em; margin-bottom: 2px; color: var(--accent); }
.page-subtitle { color: var(--text-muted); font-size: 0.9rem; line-height: 1.65; }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(280px, 1fr); gap: 24px; align-items: start; margin-bottom: 1rem; }
.guide-layout { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(280px, 0.95fr); gap: 24px; align-items: start; }
.guide-card, .cheatsheet-card { background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-elevated) 100%); border: 1px solid var(--border); border-radius: 20px; padding: 1.6rem; box-shadow: 0 8px 24px rgba(48, 66, 56, 0.06); }
.guide-hero { padding: 1.2rem 1.3rem 1.5rem; border: 1px solid var(--border); border-radius: 16px; background: linear-gradient(135deg, var(--accent-subtle), var(--bg-elevated)); margin-bottom: 1.5rem; }
.guide-hero h2 { margin: 0 0 0.45rem; font-size: clamp(1.7rem, 2vw, 2.2rem); line-height: 1.2; letter-spacing: -0.04em; color: var(--text-heading); }
.guide-hero p { margin: 0; font-size: 1rem; color: var(--text-muted); line-height: 1.7; }
.guide-section { margin-top: 1.25rem; padding: 1.35rem 1.2rem; border: 1px solid var(--border); border-radius: 16px; background: rgba(255, 255, 255, 0.7); }
.guide-section + .guide-section { margin-top: 1.6rem; }
.section-heading { margin-bottom: 0.75rem; }
.section-heading h3 { margin: 0; font-size: 1.14rem; letter-spacing: -0.02em; color: var(--accent); font-weight: 800; }
.guide-section h4 { margin: 1rem 0 0.5rem; font-size: 0.95rem; color: var(--text-heading); }
.guide-section p, .guide-section ul, .guide-section pre, .guide-section code { font-size: 0.96rem; line-height: 1.7; }
.guide-section p { margin: 0.5rem 0; color: var(--text); }
.guide-section ul { padding-left: 1.2rem; margin-top: 0.4rem; color: var(--text); }
.guide-section li { margin-bottom: 0.4rem; }
.guide-section pre { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; overflow-x: auto; white-space: pre-wrap; word-break: break-word; margin: 0.75rem 0; }
.calculation-table-wrap { width: 100%; margin: 1rem 0 1.1rem; overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; scrollbar-color: var(--accent) var(--bg-elevated); scrollbar-width: thin; }
.calculation-table-wrap::-webkit-scrollbar, .cheatsheet-list::-webkit-scrollbar { width: 8px; height: 8px; }
.calculation-table-wrap::-webkit-scrollbar-track, .cheatsheet-list::-webkit-scrollbar-track { background: var(--bg-elevated); border-radius: 999px; }
.calculation-table-wrap::-webkit-scrollbar-thumb, .cheatsheet-list::-webkit-scrollbar-thumb { background: var(--accent); border: 2px solid var(--bg-elevated); border-radius: 999px; }
.calculation-table { width: 100%; min-width: 560px; border-collapse: collapse; table-layout: fixed; background: var(--bg-card); }
.calculation-table th, .calculation-table td { padding: 0.85rem 0.9rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; line-height: 1.5; }
.calculation-table th:last-child, .calculation-table td:last-child { border-right: 0; }
.calculation-table tbody tr:last-child td { border-bottom: 0; }
.calculation-table th { background: var(--surface-muted); color: var(--text); font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; }
.calculation-table td { color: var(--text); font-size: 0.9rem; }
.calculation-table th:first-child, .calculation-table td:first-child { width: 25%; }
.calculation-table th:nth-child(2), .calculation-table td:nth-child(2) { width: 30%; }
.calculation-table td:first-child code { color: var(--accent); font-weight: 700; }
.note { background: var(--accent-subtle); border-left: 3px solid var(--accent); padding: 0.8rem 0.9rem; border-radius: 10px; }
.issue-list { display: grid; gap: 0.9rem; margin-top: 0.5rem; }
.issue-item { border: 1px solid var(--border); border-radius: 12px; padding: 1rem; background: var(--bg-elevated); }
.issue-item h4 { margin: 0 0 0.4rem; font-size: 0.96rem; }
.issue-item p { margin: 0.35rem 0; }
.tag-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem 1rem; margin-top: 0.8rem; }
.tag-grid.tag-grid-wide { grid-template-columns: minmax(0, 180px) minmax(0, 1fr); }
.tag-grid > div { padding: 0.8rem 0.9rem; border-radius: 12px; background: var(--bg-elevated); border: 1px solid var(--border); }
.tag-grid > div:nth-child(odd) { font-weight: 700; color: var(--accent); }
.check-list { margin-top: 0.8rem; }
.cheatsheet-header { margin-bottom: 1rem; }
.cheatsheet-header h2 { font-size: 1.18rem; margin-bottom: 0.35rem; letter-spacing: -0.02em; color: var(--accent); }
.cheatsheet-card { display: flex; flex-direction: column; gap: 1rem; position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: hidden; }
.cheatsheet-list { display: grid; gap: 0.7rem; overflow-y: auto; padding-right: 0.2rem; scroll-behavior: smooth; scrollbar-color: var(--accent) var(--bg-elevated); }
.cheatsheet-list a { display: block; background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-elevated) 100%); border: 1px solid var(--border); border-radius: 12px; padding: 0.8rem 0.9rem; transition: all var(--transition); text-decoration: none; }
.cheatsheet-list a:hover { border-color: var(--border); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(48, 66, 56, 0.08); }
.cheatsheet-list a:focus-visible { border-color: var(--accent); outline: 2px solid var(--accent-focus); outline-offset: 2px; }
.cheatsheet-list a.active { border-color: var(--accent); background: var(--accent-subtle); box-shadow: inset 0 0 0 1px var(--accent-subtle); }
.cheatsheet-list strong { display: block; margin-bottom: 0.22rem; color: var(--text-heading); font-size: 0.95rem; }
.cheatsheet-list span { display: block; color: var(--text-muted); font-size: 0.8rem; line-height: 1.5; }
.cheatsheet-card code, .guide-card code { display: inline-block; background: var(--bg-elevated); padding: 0.2rem 0.45rem; border-radius: 8px; border: 1px solid var(--border); font-weight: 500; }
.guide-card .tag-grid div:last-child, .guide-card .tag-grid div:nth-last-child(2) { min-height: 40px; }

@media (max-width: 900px) {
  .guide-layout, .content-grid { grid-template-columns: 1fr; }
  .guide-layout > * { min-width: 0; }
  .cheatsheet-card { position: static; order: -1; max-height: none; }
  .cheatsheet-list { display: flex; overflow-x: auto; gap: 0.65rem; padding-bottom: 0.3rem; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
  .cheatsheet-list a { min-width: min(240px, 80vw); flex: 0 0 auto; }
  .tag-grid { grid-template-columns: 1fr; }
  .tag-grid.tag-grid-wide { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .main-content { padding: 1.25rem 1rem; }
  .guide-card, .cheatsheet-card { padding: 1rem; }
  .guide-section { padding: 1rem 0.9rem; }
  .guide-hero { padding: 1rem 1rem 1.15rem; }
  .guide-hero h2 { font-size: 1.45rem; }
  .guide-section p, .guide-section ul, .guide-section pre, .guide-section code { font-size: 0.9rem; }
  .cheatsheet-list a { min-width: 210px; }
  .cheatsheet-list a { min-height: 44px; }
  .guide-card, .guide-section, .guide-hero, .tag-grid > div { min-width: 0; }
  .guide-card code, .cheatsheet-card code { max-width: 100%; overflow-wrap: anywhere; white-space: normal; }
  .guide-section p, .guide-section li, .tag-grid > div { overflow-wrap: anywhere; }
  .guide-section pre { max-width: 100%; overflow-x: auto; overflow-wrap: anywhere; }
}

@media (max-width: 640px) {
  .responsive-card-table {
    display: block;
    width: 100%;
    min-width: 0;
    border-collapse: separate;
    background: transparent;
  }

  .responsive-card-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .responsive-card-table tbody {
    display: grid;
    gap: 0.75rem;
    padding: 0.75rem;
  }

  .responsive-card-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem 0.75rem;
    min-width: 0;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
  }

  .responsive-card-table tbody td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    gap: 0.25rem;
    padding: 0.25rem 0;
    border: 0;
    overflow-wrap: anywhere;
  }

  .responsive-card-table tbody td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .responsive-card-table tbody tr td:only-child,
  .responsive-card-table tbody td[data-label="Name"],
  .responsive-card-table tbody td[data-label="Email"],
  .responsive-card-table tbody td[data-label="Actions"],
  .responsive-card-table tbody td[data-label="Template"],
  .responsive-card-table tbody td[data-label="File"],
  .responsive-card-table tbody td[data-label="Audit log"] {
    grid-column: 1 / -1;
  }

  .responsive-card-table .table-title-link {
    display: flex;
    align-items: flex-start;
    width: 100%;
    overflow-wrap: anywhere;
  }

  .responsive-card-table .user-email-value,
  .responsive-card-table .mono-sm {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: normal;
    white-space: normal;
  }

  .responsive-card-table .avatar-circle {
    flex: 0 0 32px;
  }

  .responsive-card-table .td-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
    align-items: stretch;
    width: 100%;
    gap: 0.5rem;
  }

  .responsive-card-table .td-actions > form {
    display: flex;
    min-width: 0;
  }

  .responsive-card-table .td-actions .btn {
    width: 100%;
    min-height: 44px;
    padding: 0.55rem 0.5rem;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 2.5rem; }
.stat-card { background: linear-gradient(135deg, #FFFFFF, #FAFCFB); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: 1.2rem 1.4rem; display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 42px; height: 42px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon-blue   { background: var(--accent-subtle); color: var(--accent); }
.stat-icon-green  { background: var(--success-bg); color: var(--success); }
.stat-icon-amber  { background: var(--warning-bg); color: var(--warning); }
.stat-body { display: flex; flex-direction: column; gap: 1px; }
.stat-value { font-size: 1.4rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); }
.section-header { margin-bottom: 1.2rem; }
.section-title { font-size: 1rem; font-weight: 600; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; min-width: 0; }
.template-card { min-width: 0; background: linear-gradient(135deg, #FFFFFF, #FCFDFC); border: 1px solid #E7ECE9; border-radius: var(--radius-lg); padding: 1.4rem; transition: all var(--transition); display: flex; flex-direction: column; gap: 10px; box-shadow: 0 2px 8px rgba(48, 66, 56, 0.035); }
.template-card:hover { border-color: var(--border-light); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(48, 66, 56, 0.08); }
.tc-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.tc-icon { width: 38px; height: 38px; background: var(--accent-subtle); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: var(--accent); }
.tc-usage { font-size: 0.75rem; color: var(--text-muted); font-family: var(--font-mono); }
.tc-title { min-width: 0; font-size: 0.97rem; font-weight: 600; letter-spacing: -0.01em; color: var(--text); overflow-wrap: anywhere; word-break: break-word; }
.tc-filename { font-size: 0.78rem; color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-footer { display: flex; gap: 8px; margin-top: 4px; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 5rem 2rem; gap: 12px; }
.empty-icon { width: 80px; height: 80px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; color: var(--text-muted); margin-bottom: 8px; }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; }
.empty-state p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.7; max-width: 380px; }
.error-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; text-align: center; padding: 2rem; gap: 12px; }
.error-title { font-size: 1.8rem; font-weight: 600; letter-spacing: -0.03em; }
.error-message { color: var(--text-muted); margin-bottom: 8px; }

/* ══ PHASE 2 STYLES ════════════════════════════════════════ */
.breadcrumb-back { display: inline-flex; align-items: center; gap: 5px; font-size: 0.82rem; color: var(--text-muted); text-decoration: none; margin-bottom: 6px; transition: color var(--transition); }
.breadcrumb-back:hover { color: var(--text-muted); }
.generate-template-name { margin: 0.35rem 0 0.5rem; color: #4C6E5D; font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--radius); font-size: 0.87rem; font-weight: 500; margin-bottom: 1.5rem; animation: slideDown 0.25s ease; }
.toast-success { background: var(--success-bg); border: 1px solid var(--success); color: var(--success); }
.toast-error { background: var(--error-bg); border: 1px solid var(--error); color: var(--error); }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

.alert-info { background: var(--info-bg); border: 1px solid var(--border); color: var(--info); }
.alert-info svg { flex-shrink: 0; }

.template-table-wrap { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow-x: auto; }
.template-table-wrap:focus-visible { outline: 2px solid var(--accent-focus); outline-offset: 2px; }
@media (max-width: 900px) {
  .template-table-wrap { box-shadow: inset -10px 0 8px -10px var(--text-muted); }
}
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 600px; }
.data-table thead { background: var(--bg-elevated); border-bottom: 1px solid var(--border); }
.data-table th { padding: 11px 16px; text-align: left; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.data-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.table-title-link { display: inline-flex; align-items: center; min-width: 0; min-height: 44px; overflow-wrap: break-word; word-break: break-word; font-weight: 500; color: var(--text); text-decoration: none; }
.table-title-link:hover { color: var(--accent); }
.user-email-value { display: block; min-width: 0; overflow-wrap: break-word; word-break: break-word; }
.mono-sm { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-muted); }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-muted); }
.ts-sm { font-size: 0.82rem; }
.badge { display: inline-block; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 99px; padding: 2px 10px; font-size: 0.78rem; font-family: var(--font-mono); color: var(--text-muted); }
.td-actions { display: flex; gap: 8px; justify-content: flex-end; }
.user-table-toolbar { display: flex; align-items: center; justify-content: flex-start; gap: 12px; margin-bottom: 1rem; flex-wrap: wrap; }
.member-count { color: var(--text-muted); font-size: 0.82rem; font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }
.status-filter-group { display: flex; flex-wrap: wrap; gap: 8px; margin-left: 0; }
.status-filter-btn { min-width: 44px; min-height: 44px; border: 1px solid var(--accent); background: var(--bg-card); color: var(--accent); padding: 0.75rem 1rem; border-radius: 999px; font-size: 0.86rem; font-weight: 600; cursor: pointer; transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition); }
.status-filter-btn:hover { background: var(--accent-subtle); border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.status-filter-btn:focus-visible { background: var(--accent-subtle); border-color: var(--accent); color: var(--accent); outline: 2px solid var(--accent-focus); outline-offset: 2px; }
.status-filter-btn.active { background: var(--accent); border-color: var(--accent); color: white; }
@media (max-width: 780px) {
  .user-table-toolbar { justify-content: flex-start; }
  .status-filter-group { width: 100%; justify-content: flex-start; }
  .status-filter-btn { flex: 1 1 auto; min-width: 120px; }
}
#statusFilterEmptyState { margin-bottom: 1.25rem; }
#statusFilterEmptyState .empty-state { margin: 0; }
.form-page-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 2rem; max-width: 680px; }
.edit-blueprint-sections { display: grid; gap: 24px; }
.edit-blueprint-form { width: 100%; max-width: 680px; }
.rename-template-card { margin-bottom: 24px; }
.edit-blueprint-section { background: var(--accent-subtle); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.edit-blueprint-section > .card-title { margin: 0 0 0.75rem; }
/* Current metadata uses the primary-action color for consistent emphasis. */
.blueprint-current-value { color: var(--accent); margin: 0 0 1rem; font-size: 0.82rem; }
.blueprint-form-description { color: var(--accent); }
.edit-blueprint-actions { display: flex; margin-top: 24px; }

.dropzone { border: 2px dashed var(--border); border-radius: var(--radius-lg); padding: 2rem; text-align: center; cursor: pointer; transition: all var(--transition); background: var(--bg); position: relative; }
.dropzone:hover, .dropzone.dz-over { border-color: var(--accent); background: var(--accent-subtle); }
.dz-icon { width: 56px; height: 56px; background: var(--bg-elevated); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; margin: 0 auto 1rem; color: var(--text-muted); }
.dz-label { font-size: 0.95rem; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.dz-sub { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; }
.dz-limit { font-size: 0.75rem; color: var(--text-muted); }
.dz-browse { background: none; border: none; cursor: pointer; color: var(--accent); font-size: inherit; font-family: inherit; text-decoration: underline; padding: 0; }
.dz-browse:hover { color: var(--accent-hover); }
.dz-selected { display: flex; align-items: center; gap: 14px; }
.dz-file-icon { width: 42px; height: 42px; background: var(--accent-subtle); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: var(--accent); flex-shrink: 0; }
.dz-file-info { flex: 1; display: flex; flex-direction: column; gap: 2px; text-align: left; }
.dz-file-name { font-size: 0.9rem; font-weight: 500; color: var(--text); }
.dz-file-size { font-size: 0.78rem; color: var(--text-muted); font-family: var(--font-mono); }
.dz-remove { min-width: 44px; min-height: 44px; background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 6px; display: flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); transition: all var(--transition); }
.dz-remove:hover { color: var(--error); background: var(--error-bg); }
.info-box { display: flex; align-items: flex-start; gap: 10px; background: var(--info-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; font-size: 0.85rem; color: var(--info); line-height: 1.6; }
.info-box svg { flex-shrink: 0; margin-top: 1px; color: var(--accent); }
.current-file-box { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; color: var(--text-muted); font-size: 0.88rem; }
.two-col { display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; align-items: start; }
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.card-danger { border-color: var(--error); }
.card-header { padding: 1.25rem 1.25rem 0.75rem; border-bottom: 1px solid var(--border); }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 0.92rem; font-weight: 600; margin-bottom: 4px; }
.card-subtitle { font-size: 0.82rem; color: var(--text-muted); }
.danger-title { color: var(--red); }
.card-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); background: var(--bg-elevated); }
.card-empty { padding: 2.5rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text-muted); }
.card-empty p { font-size: 0.87rem; color: var(--text-muted); }
.fields-list { padding: 0.75rem 1.25rem; display: flex; flex-direction: column; gap: 10px; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: 10px; min-width: 0; width: 100%; box-sizing: border-box; }
.field-placeholder, .placeholder-column { min-width: 0; width: 100%; }
.placeholder-tag { display: block; width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; overflow-x: auto; overflow-y: hidden; font-family: var(--font-mono); font-size: 0.78rem; color: #FF7034; background: var(--accent-subtle); border: 1px solid var(--border); padding: 5px 10px; border-radius: var(--radius-sm); white-space: nowrap; text-overflow: clip; }
.placeholder-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; margin-top: 6px; font-size: 0.78rem; }
.placeholder-details summary { color: var(--accent); font: inherit; cursor: pointer; }
.placeholder-details summary { text-decoration: underline; text-underline-offset: 2px; }
.placeholder-full-expression { display: block; margin-top: 6px; color: #FF7034; white-space: normal; overflow-wrap: anywhere; font-family: var(--font-mono); }
.field-arrow { display: flex; justify-content: center; color: var(--text-muted); }
.field-label-input { min-width: 0; }
.field-label-input input { width: 100%; min-width: 0; min-height: 42px; box-sizing: border-box; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 10px; color: var(--text); font-family: var(--font); font-size: 0.87rem; outline: none; transition: border-color var(--transition), box-shadow var(--transition); }
.field-arrow svg { transform: rotate(90deg); }
@media (min-width: 768px) {
  .field-row { grid-template-columns: minmax(0, 2.2fr) 24px minmax(220px, 1fr); align-items: end; gap: 16px; }
  .field-arrow { align-self: center; }
  .field-arrow svg { transform: none; }
}
.field-label-input input:focus { border-color: var(--accent); outline: 2px solid var(--accent-focus); outline-offset: 2px; box-shadow: 0 0 0 4px var(--accent-glow); }
.info-rows { padding: 0.75rem 1.25rem; display: flex; flex-direction: column; }
.info-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.info-row:last-child { border-bottom: none; }
.ir-label { color: var(--text-muted); }
.ir-value { font-weight: 500; font-family: var(--font-mono); font-size: 0.82rem; }
.btn-danger { background: var(--error-bg); color: var(--error); border-color: var(--error); }
.btn-danger:hover { background: var(--error-bg); border-color: var(--error); color: var(--error); }
@media (max-width: 960px) { .two-col { grid-template-columns: 1fr; } }

/* ══ PHASE 3 — GENERATE & PREVIEW ══════════════════════════ */
.template-preview { font-family: var(--font); font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; }
.placeholder-highlight { color: var(--accent); background-color: var(--accent-subtle); padding: 2px 6px; border-radius: 4px; font-weight: 500; font-family: var(--font-mono); }
.conditional-tag { color: #d97706; background-color: #fef3c7; padding: 2px 6px; border-radius: 4px; font-weight: 600; font-family: var(--font-mono); border: 1px dashed #f59e0b; }
.preview-container { max-height: 80vh; overflow-y: auto; border: 1px solid #e5e7eb; border-radius: 8px; padding: 20px; background: #ffffff; box-shadow: 0 1px 3px rgba(0,0,0,0.1); margin: 1rem 1.25rem 1.25rem; }
.preview-loading { color: var(--text-muted); font-size: 0.9rem; padding: 1rem 0; }
.preview-error-state { padding: 1rem; background: #fee2e2; border: 1px solid #fca5a5; border-radius: 6px; color: #991b1b; }
.preview-error-state p { margin-top: 0.25rem; color: #991b1b; }
@media (max-width: 768px) { .preview-container { max-height: 50vh; margin-bottom: 20px; } }

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; }

.gen-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) 320px; gap: 1.5rem; align-items: start; }
.gen-main-column { display: flex; flex-direction: column; gap: 1.5rem; min-width: 0; }
.gen-form-panel, .gen-preview-panel { min-width: 0; }
.gen-fields { padding: 1.25rem; display: flex; flex-direction: column; gap: 16px; }
.gen-field-group label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.field-key { font-family: var(--font-mono); font-size: 0.72rem; color: var(--accent); background: var(--accent-subtle); border: 1px solid var(--border); padding: 1px 6px; border-radius: 4px; flex-shrink: 0; }
.form-intro { padding: 0.5rem 1.25rem 0; color: var(--text-muted); font-size: 0.9rem; }
.gen-form-footer { display: flex; gap: 12px; align-items: center; padding: 1rem 1.25rem; border-top: 1px solid var(--border); background: var(--bg-elevated); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.btn-generate { min-width: 180px; justify-content: center; }
.btn.is-loading { opacity: 0.95; cursor: progress; }
.btn.is-loading .btn-label { opacity: 0.95; }
.how-step { display: flex; align-items: flex-start; gap: 12px; font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }
.how-num { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-subtle); border: 1px solid var(--border); color: var(--accent); font-size: 0.72rem; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }

.preview-main { display: flex; flex-direction: column; overflow: hidden; }
.preview-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.5rem; flex-shrink: 0; }
.preview-actions { display: flex; gap: 10px; align-items: center; }
.preview-shell { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr); gap: 1.25rem; flex: 1; min-height: 0; }
.success-card { background: linear-gradient(140deg, var(--success-bg), var(--bg-card)); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.success-card h2 { font-size: 1.4rem; letter-spacing: -0.02em; margin-bottom: 0.2rem; }
.success-card p { color: var(--text-muted); font-size: 0.95rem; }
.success-stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stat-pill { display: flex; flex-direction: column; padding: 10px 12px; border-radius: var(--radius); background: var(--bg-card); border: 1px solid var(--border); min-width: 140px; }
.stat-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.success-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.placeholder-list { display: flex; flex-wrap: wrap; gap: 8px; }
.placeholder-chip { display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 999px; background: var(--accent-subtle); border: 1px solid var(--border); color: var(--accent); font-size: 0.78rem; font-weight: 600; font-family: var(--font-mono); }
.preview-layout { display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; align-items: start; flex: 1; min-height: 0; }
.preview-doc-panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column; }
.preview-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--bg-elevated); flex-shrink: 0; }
.preview-toolbar-label { display: flex; align-items: center; gap: 7px; font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.preview-filename { color: var(--text-muted); font-size: 0.75rem; }
.preview-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 5rem 2rem; color: var(--text-muted); font-size: 0.9rem; }
.preview-hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1.25rem; padding: 1.25rem 1.5rem; border: 1px solid var(--border); border-radius: var(--radius-lg); background: linear-gradient(135deg, var(--accent-subtle), var(--bg-card)); }
.preview-eyebrow { margin: 0 0 0.35rem; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); }
.preview-template-title { margin: 0; font-size: 1.45rem; letter-spacing: -0.02em; }
.preview-hero-meta { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.stat-pill-strong { min-width: 140px; background: rgba(255,255,255,0.95); }
.preview-disclaimer { margin: 1rem 1.25rem 0; padding: 0.9rem 1rem; border: 1px solid var(--warning); border-radius: 8px; background: var(--warning-bg); color: var(--warning); font-size: 0.9rem; line-height: 1.5; }
.preview-spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; }
.preview-error { flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 4rem 2rem; text-align: center; color: var(--text-muted); font-size: 0.88rem; }
.preview-error p { color: var(--text-muted); }
.preview-error a { color: var(--accent); }

/* Legacy docx-container (only used outside preview-page) */
.docx-container { display: none; overflow-y: auto; max-height: calc(100vh - 280px); padding: 1.5rem; background: #f5f5f5; }
.docx-container .docx-preview-content { max-width: none !important; }
.docx-container section.docx { box-shadow: 0 2px 12px rgba(0,0,0,0.15) !important; margin: 0 auto 1.5rem !important; }

/* On preview-page, docxContainer is the preview-content inner div; inherit scoped styles */
.preview-page #docxContainer { display: block; }

.info-row-col { flex-direction: column; align-items: flex-start; gap: 4px; }
.ir-filled-val { font-size: 0.87rem; color: var(--text); word-break: break-word; }

/* ═══════════════════════════════════════════════════════════════
   NEW: PREVIEW PAGE (Prominent, Clean, Responsive)
   ═══════════════════════════════════════════════════════════════ */

.preview-page .preview-main {
  padding: 2rem;
  flex: 1;
  overflow-y: auto;
}

.preview-page .preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
}

.preview-page .header-left {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Main Layout: 2 Columns on Desktop, Stacked on Mobile */
.preview-page .preview-shell {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* Primary Document Preview (Left / Center) */
.preview-page .preview-doc-panel {
  flex: 1;
  min-width: 0;
}

/* Sidebar Panel (Title & Details) */
.preview-page .preview-side-panel {
  width: 100%;
}

@media (min-width: 1024px) {
  .preview-page .preview-shell {
    flex-direction: row;
    align-items: flex-start;
  }
  
  .preview-page .preview-side-panel {
    width: 320px;
    flex-shrink: 0;
  }
}

/* Template Details Card (Right Sidebar) */
.template-details-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  background: var(--bg-card);
}

.template-details-card .card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.template-details-card .card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.template-details-card .info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.template-details-card .info-row:last-child {
  border-bottom: none;
}

.template-details-card .download-section {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

/* The "Paper" Preview Container */
.preview-page .preview-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2.5rem;
  background: linear-gradient(135deg, var(--bg-elevated), var(--surface-muted));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 600px;
}

.preview-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 1000px;
  overflow: hidden;
  position: relative;
}

/* The actual document content area (The "Paper") */
.preview-page .preview-document.paper-container {
  padding: 60px 80px;
  min-height: 800px;
  background: #ffffff;
}

/* Content (HTML or DOCX) fills the paper */
.preview-page .preview-content,
.preview-page .preview-html-content,
.preview-page #docxContainer {
  font-family: 'Times New Roman', Times, serif;
  font-size: 12pt;
  line-height: 1.6;
  color: #111827;
  width: 100%;
  overflow-x: auto;
  overflow-wrap: anywhere;
}

.preview-page .docx-preview-content {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.preview-page .docx-preview-content section.docx {
  max-width: 100%;
  margin-inline: auto;
}

/* Loading & Error States */
.preview-page .preview-loading,
.preview-page .preview-error {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  z-index: 10;
}

.preview-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 0.75rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  .preview-page .preview-main { padding: 1.25rem; }
  .preview-page .preview-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .preview-page .preview-actions { width: 100%; flex-wrap: wrap; }
  .preview-page .preview-actions .btn { flex: 1 1 100%; justify-content: center; }
  .preview-page .preview-wrapper { padding: 1rem; }
  .preview-page .preview-document.paper-container { padding: 30px 20px; min-height: 0; }
  .preview-page .preview-side-panel { order: -1; }
}

@media (min-width: 769px) and (max-width: 1023px) {
  .preview-page .preview-document.paper-container { padding: 40px 50px; }
  .preview-page .preview-box { max-width: 900px; }
}

/* Remove old cluttered styles (overwrite if they still exist) */
.preview-page .preview-toolbar,
.preview-page .preview-disclaimer,
.preview-page .preview-hero {
  display: none !important;
}

/* ── Responsive System: Consolidated & Enhanced ─────────────── */

/* Small laptops / Tablets (max-width: 992px) */
@media (max-width: 992px) {
  .app-shell { flex-direction: column; padding: 0 1rem; }
  .sidebar { width: 100%; flex-direction: row; padding: 0.75rem 1rem; border-right: none; border-bottom: 1px solid var(--border); overflow-x: auto; gap: 0.25rem; background: var(--surface-sidebar); }
  .sidebar-nav { flex-direction: row; padding: 0; gap: 4px; }
  .sidebar-link { padding: 8px 14px; white-space: nowrap; font-size: 0.82rem; }
  .sidebar-link span { display: inline; }
  .sidebar-link svg + * { display: inline; }
  .sidebar-bottom { display: none; }
  .main-content { padding: 1.5rem 0.5rem; width: 100%; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .two-col, .gen-layout, .preview-layout { grid-template-columns: 1fr; }
  .preview-side-panel { order: -1; }
  .content-grid { grid-template-columns: 1fr; }
  .auth-left { display: none; }
  .auth-right { width: 100%; border-left: none; padding: 2rem 1.5rem; }
  .auth-login-page .auth-split { flex-direction: column; }
  .auth-login-page .auth-left { display: flex; flex: 0 0 auto; width: 100%; min-height: 0; padding: 1.5rem; }
  .auth-login-page .auth-left-inner { max-width: 640px; }
  .auth-login-page .auth-suite-title { font-size: clamp(1.65rem, 5vw, 2.2rem); }
  .auth-login-page .auth-suite-copy p { font-size: 0.88rem; line-height: 1.6; }
  .auth-login-page .auth-right { flex: 0 0 auto; width: 100%; padding: 1.5rem; }
}

/* Tablets & Large Phones (max-width: 820px) */
@media (max-width: 820px) {
  body { font-size: 14px; }
  .navbar { height: 64px; padding: 0 1rem; }
  .navbar-right .nav-user-email { display: none; }
  .nav-user { gap: 8px; }
  .app-body { overflow: auto; min-height: 100vh; }
  .app-shell { display: block; padding: 0; overflow: visible; }
  .sidebar { position: static; width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border); box-shadow: none; z-index: auto; background: var(--surface-sidebar); padding: 0.35rem 0.5rem; flex-direction: row; align-items: center; overflow: hidden; }
  .sidebar-nav { width: 100%; min-width: 0; flex-direction: row; gap: 4px; padding: 0; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
  .sidebar-link { flex: 0 0 auto; width: auto; min-height: 44px; padding: 8px 12px; white-space: nowrap; }
  .sidebar-nav .sidebar-link span { display: inline; }
  .btn, .btn-sm { min-height: 44px; }
  .main-content { padding: 1rem 0.75rem; }
  .page-subtitle { font-size: 0.85rem; }
  .auth-right { padding: 2rem 1.25rem; }
  .auth-card { max-width: 100%; }
  .auth-tagline h1 { font-size: 1.8rem; }
  .form-row { grid-template-columns: 1fr; }
  .gen-fields { padding: 0.75rem; gap: 12px; }
  .gen-field-group label { font-size: 0.85rem; flex-wrap: wrap; gap: 4px; }
  .gen-field-group input, .gen-field-group select, .gen-field-group textarea, .text-input, .date-input { font-size: 16px !important; padding: 10px 12px; min-height: 44px; width: 100%; }
  .gen-form-footer { flex-direction: column; align-items: stretch; padding: 1rem; }
  .gen-form-footer .btn, .gen-form-footer .btn-generate { width: 100%; justify-content: center; min-height: 48px; }
  .gen-form-footer > div { flex-direction: column; gap: 0.5rem; }
  .gen-info-panel { display: flex; flex-direction: column; gap: 1rem; }
  .gen-info-panel .card { width: 100%; }
  .card-header { padding: 1rem 0.75rem 0.5rem; }
  .card-title { font-size: 0.95rem; }
  .card-footer { padding: 0.75rem; }
  .info-rows { padding: 0.5rem 0.75rem; }
  .info-row { flex-direction: column; align-items: flex-start; gap: 2px; padding: 6px 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 1rem; }
  .template-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .template-card { padding: 1rem; }
  .preview-container { max-height: 50vh; padding: 12px; margin: 0.75rem; }
  .dropzone { padding: 1.5rem 1rem; }
  .success-card { padding: 1.25rem; }
  .success-stats { flex-direction: column; }
  .stat-pill { min-width: 0; width: 100%; }
  .preview-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .preview-actions { width: 100%; flex-wrap: wrap; }
  .preview-actions .btn { flex: 1 1 100%; justify-content: center; }
  .download-success-card { top: 0.5rem; width: calc(100% - 1rem); margin-inline: 0.5rem; flex-wrap: wrap; }
  .download-success-card .btn { width: 100%; justify-content: center; }
  .preview-toolbar { flex-direction: column; align-items: flex-start; gap: 6px; }
  .docx-container { max-height: 60vh; padding: 0.75rem; }
  .template-table-wrap { border-radius: var(--radius); }
  .data-table { min-width: 480px; font-size: 0.82rem; }
  .data-table th, .data-table td { padding: 8px 10px; }
  .td-actions { gap: 4px; flex-wrap: wrap; }
  .user-table-toolbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .role-filter-wrap { width: 100%; margin-left: 0; justify-content: flex-start; }
  .role-filter-select { width: 100%; min-width: 0; }
  .sidebar-link { padding: 6px 12px; font-size: 0.78rem; }
  .sidebar-link svg { width: 16px; height: 16px; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .navbar-logo { width: 140px; }
}

@media (max-width: 767px) {
  .navbar-logo { width: 106px; }
}

/* Small Phones (max-width: 576px) */
@media (max-width: 576px) {
  .navbar { padding: 0 0.5rem; gap: 0.4rem; }
  .navbar-left { gap: 6px; }
  .navbar-logo { width: clamp(56px, 18.77vw, 74px); }
  .navbar-right { gap: 6px; }
  .nav-user { gap: 6px; }
  .nav-user-avatar { width: 26px; height: 26px; }
  .role-badge { font-size: 0.58rem; padding: 2px 5px; }
  .navbar .nav-logout-form .btn { font-size: 0.74rem; padding: 5px 6px; }
  .stats-grid, .template-grid { grid-template-columns: 1fr; }
  .auth-right { padding: 1.5rem 1rem; }
  .auth-card-header h2 { font-size: 1.4rem; }
  .user-table-toolbar { gap: 8px; }
  .member-count { width: 100%; text-align: left; }
  .role-filter-label { font-size: 0.72rem; }
  .field-type-badge, .field-key { font-size: 0.6rem; padding: 1px 4px; }
  .btn { font-size: 0.85rem; padding: 0.6rem 1rem; }
  .breadcrumb-back { font-size: 0.75rem; }
  .generate-template-name { font-size: 1.15rem; }
  .alert, .toast { font-size: 0.8rem; padding: 10px 12px; }
  .preview-page-card { padding: 1rem !important; }
  .preview-content { font-size: 13px; line-height: 1.6; }
  .preview-content .placeholder-highlight, .preview-content .conditional-tag { padding: 1px 4px; font-size: 0.8em; }
  .sidebar { padding: 0.5rem 0.5rem; gap: 2px; }
  .sidebar-link { font-size: 0.7rem; padding: 4px 8px; }
  .sidebar-link span { font-size: 0.65rem; }
  .navbar { height: 64px; }
  .role-badge { font-size: 0.62rem; padding: 2px 6px; }
  .main-content { padding: 0.75rem 0.5rem; }
  .gen-fields { padding: 0.5rem; gap: 10px; }
  .gen-field-group label { font-size: 0.8rem; }
  .gen-form-footer .btn { font-size: 0.85rem; min-height: 44px; }
  .card-header { padding: 0.75rem 0.5rem 0.25rem; }
  .card-title { font-size: 0.85rem; }
  .card-subtitle { font-size: 0.7rem; }
}

/* Extreme Small Screens (max-width: 400px) */
@media (max-width: 400px) {
  .sidebar-link { padding: 4px 6px; font-size: 0.65rem; }
  .sidebar-link span { display: none; }
  .sidebar-link svg { width: 18px; height: 18px; }
  .data-table { min-width: 360px; font-size: 0.75rem; }
  .data-table th, .data-table td { padding: 6px 8px; }
  .btn { font-size: 0.8rem; padding: 0.5rem 0.75rem; }
  .stat-value { font-size: 1.1rem; }
}

/* ═══════════════════════════════════════════════════════════════
   DOCFORGE - UPGRADED DOCUMENT PREVIEW
   Final scoped rules for the static, multipage reading surface.
   These rules intentionally follow the legacy preview rules above so
   the active document-preview page has one predictable visual contract.
   ═══════════════════════════════════════════════════════════════ */

.preview-page .preview-main {
  padding: 1rem;
  flex: 1;
  min-height: auto;
  overflow: visible;
}

/* Let the preview grow with the uploaded document so the browser owns page scrolling. */
.preview-page { min-height: 100vh; overflow-x: hidden; }

@media (min-width: 768px) {
  .main-content {
    padding: 2rem 2.5rem;
    max-width: 1600px;
    margin: 0 auto;
  }
}

.preview-page .main-content {
  min-width: 0;
  min-height: 0;
}

.preview-page .preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.preview-page .header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.preview-page .preview-title {
  margin: 0;
  color: var(--accent);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.3;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.preview-page .preview-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.preview-page .preview-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

.preview-page .preview-toolbar {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  width: min(100%, 1000px);
  margin: 0 auto;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--bg-elevated);
}

.preview-page .preview-toolbar-label {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 7px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.preview-page .preview-filename {
  max-width: 55%;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-page .preview-disclaimer {
  display: block !important;
  width: min(100%, 1000px);
  margin: 0 auto;
  padding: 0.9rem 1rem;
  border: 1px solid var(--warning);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  box-shadow: 0 3px 10px rgba(146, 64, 14, 0.08);
  color: #78350f;
  font-size: 0.9rem;
  line-height: 1.5;
}

.preview-page .preview-wrapper {
  display: block;
  width: min(100%, 1000px);
  max-width: 1000px;
  min-height: 600px;
  margin: 1.5rem auto 0;
  padding: 2.5rem;
  overflow-x: auto;
  overflow-y: visible;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--bg-elevated), var(--surface-muted));
  box-shadow: var(--shadow-sm);
}

.preview-page .preview-box {
  position: relative;
  width: 100%;
  max-width: 1000px;
  min-height: 0;
  overflow: visible;
  overflow-x: hidden;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  box-shadow: var(--shadow-lg);
}

.preview-page .preview-document.paper-container {
  min-height: 600px;
  width: 100%;
  max-width: 100%;
  padding: 60px 80px;
  overflow-x: hidden;
  background: #fff;
}

.preview-page .preview-content,
.preview-page .preview-html-content,
.preview-page #docxContainer {
  width: 100%;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: #111827;
  font-family: 'Times New Roman', Times, serif;
  font-size: 12pt;
  line-height: 1.6;
}

/* Mammoth converts Word paragraphs to HTML paragraphs. Explicit margins keep
   those paragraphs visually separate instead of collapsing the source layout
   into a dense stream of lines. Empty paragraphs retain one line of height. */
.preview-page .template-preview > p,
.preview-page .preview-html-content > p {
  min-height: 1.6em;
  margin: 0 0 1rem;
}

.preview-page .template-preview > p:last-child,
.preview-page .preview-html-content > p:last-child {
  margin-bottom: 0;
}

.preview-page .template-preview h1,
.preview-page .template-preview h2,
.preview-page .template-preview h3,
.preview-page .preview-html-content h1,
.preview-page .preview-html-content h2,
.preview-page .preview-html-content h3 {
  margin: 1.75rem 0 0.9rem;
  line-height: 1.3;
}

.preview-page .template-preview ul,
.preview-page .template-preview ol,
.preview-page .preview-html-content ul,
.preview-page .preview-html-content ol {
  margin: 0 0 1rem 1.5rem;
  padding-left: 1rem;
}

.preview-page .template-preview table,
.preview-page .preview-html-content table {
  width: 100%;
  margin: 1.25rem 0 1.5rem;
  border-collapse: collapse;
}

.preview-page .template-preview td,
.preview-page .template-preview th,
.preview-page .preview-html-content td,
.preview-page .preview-html-content th {
  padding: 0.65rem 0.8rem;
  vertical-align: top;
}

.preview-page .docx-preview-content {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.preview-page .preview-loading,
.preview-page .preview-error {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(255, 255, 255, 0.95);
  text-align: center;
}

@media (max-width: 768px) {
  .preview-page .preview-main { padding: 1rem; overflow: visible !important; height: auto; }
  .preview-page .preview-header { flex-direction: column; gap: 0.75rem; }
  .preview-page .preview-actions { width: 100%; flex-wrap: wrap; }
  .preview-page .preview-actions .btn { flex: 1 1 100%; justify-content: center; }
  .preview-page .preview-toolbar { align-items: flex-start; flex-direction: column; gap: 6px; }
  .preview-page .preview-filename { max-width: 100%; white-space: normal; }
  .preview-page .preview-wrapper { width: 100%; min-height: 0; margin-top: 1rem; padding: 1rem; }
  .preview-page .preview-box { overflow: visible; }
  .preview-page .preview-document.paper-container { width: 100%; max-width: 100%; min-height: 0; padding: 20px; overflow-x: hidden !important; }
  .preview-page .preview-disclaimer { font-size: 0.82rem; }
  .preview-page .template-preview > p,
  .preview-page .preview-html-content > p { margin-bottom: 0.85rem; }
  .preview-page .template-preview table,
  .preview-page .preview-html-content table { display: block; overflow-x: auto; }
}

@media (min-width: 1024px) {
  .preview-page .preview-wrapper { padding: 4rem; overflow: visible; }
  .preview-page .preview-box { overflow: visible; }
}

/* Touch devices should use one natural page scroll instead of nested scrolling. */
@media (min-width: 769px) and (max-width: 1023px) {
  .preview-page { min-height: 100vh; overflow-x: hidden; }
  .preview-page .preview-main { overflow: visible; height: auto; }
  .preview-page .preview-box { overflow: visible; }
}

/* ── Admin & Input Styles ──────────────────────────────────── */
.text-input { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; color: var(--text); font-family: var(--font); font-size: 0.92rem; outline: none; transition: border-color var(--transition), box-shadow var(--transition); }
.text-input::placeholder { color: var(--text-muted); }
.text-input:focus { border-color: var(--accent); outline: 2px solid var(--accent-focus); outline-offset: 2px; box-shadow: 0 0 0 4px var(--accent-glow); }

.date-input { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; color: var(--text); font-family: var(--font); font-size: 0.92rem; outline: none; transition: border-color var(--transition), box-shadow var(--transition); color-scheme: light; }
.date-input:focus { border-color: var(--accent); outline: 2px solid var(--accent-focus); outline-offset: 2px; box-shadow: 0 0 0 4px var(--accent-glow); }

.field-type-badge { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; background: var(--success-bg); color: var(--success); border: 1px solid var(--success); padding: 1px 6px; border-radius: 99px; margin-left: 4px; }
.field-type-badge[data-badge="email"], .field-type-badge[data-type="email"] { background: var(--accent-subtle); color: var(--accent); border-color: var(--border); }
.field-type-badge[data-badge="phone"], .field-type-badge[data-type="phone"] { background: var(--accent-subtle); color: var(--accent); border-color: var(--border); }
.field-type-badge[data-badge="number"], .field-type-badge[data-type="number"] { background: var(--warning-bg); color: var(--warning); border-color: var(--warning); }
.field-type-badge[data-badge="url"], .field-type-badge[data-type="url"] { background: var(--accent-subtle); color: var(--accent); border-color: var(--border); }

/* ── Admin Styles ──────────────────────────────────────────── */
.user-avatar { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--accent-subtle); color: var(--accent); font-size: 0.75rem; font-weight: 700; flex-shrink: 0; }
.badge-active { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.badge-pending { background: var(--warning-bg); color: var(--warning); border-color: var(--warning); }
.badge-expired { background: var(--error-bg); color: var(--error); border-color: var(--error); }
.badge-disabled { background: var(--error-bg); color: var(--error); border-color: var(--error); }
.badge-slate { background: var(--surface-muted); color: var(--text-muted); border-color: var(--border); }

#userSearch {
  min-height: 44px;
  border: 1px solid var(--border);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#addUserForm #firstName,
#addUserForm #lastName,
#addUserForm #email {
  min-height: 44px;
}

#userSearch:focus,
#userSearch:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
}

#userSearch::placeholder {
  color: var(--text-muted);
}

.template-search-toolbar {
  display: flex;
  width: 100%;
  margin: 0 0 1.25rem;
}

.template-search-input {
  width: 100%;
  min-width: 0;
  padding: 0.65rem 0.8rem;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
}

.template-search-input:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
}

[data-template-search-item][hidden] {
  display: none !important;
}

[data-template-search-empty][hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.template-search-empty {
  margin-top: 1rem;
}

@media (min-width: 769px) {
  .template-search-input {
    width: min(100%, 360px);
  }
}

/* ═══════════════════════════════════════════════════════════════
   AUTH & LOGIN (Enhanced Responsive & Accessibility)
   ═══════════════════════════════════════════════════════════════ */

/* Forgot Password Link - Pure CSS Hover & Focus (No inline JS) */
.forgot-password-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.82rem;
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}

.forgot-password-link:hover,
.forgot-password-link:focus-visible {
  color: var(--accent);
}

.forgot-password-link:focus-visible {
  outline: 2px solid var(--accent-focus);
  outline-offset: 2px;
  text-decoration: underline;
}

/* Form Footer Actions */
.form-footer-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: -8px; /* Pulls closer to the password field */
}

/* ── Mobile First Adjustments ── */
@media (max-width: 768px) {
  /* Branding panel is hidden on mobile to focus on form */
  .auth-left {
    display: none;
  }

  /* Right panel takes full width */
  .auth-right {
    width: 100%;
    border-left: none;
    padding: 2rem 1.5rem;
  }
}

@media (max-width: 400px) {
  .auth-right {
    padding: 1.5rem 1rem;
  }
}

/* ── Dashboard workspace ───────────────────────────────────── */
.dashboard-body {
  background: #f1f2f1;
}

.dashboard-body .app-shell {
  flex-direction: row;
  gap: 12px;
  padding: 0 12px 0 0;
  min-height: calc(100vh - 80px);
  background: #f1f2f1;
}

.dashboard-body .sidebar {
  width: 220px;
  flex: 0 0 220px;
  flex-direction: column;
  align-items: stretch;
  padding: 1.5rem 0;
  border: 0;
  border-radius: 0;
  background: var(--surface-sidebar);
  box-shadow: 7px 0 22px rgba(38, 75, 58, 0.09);
  position: relative;
  z-index: 1;
}

.dashboard-body .sidebar-nav {
  flex-direction: column;
}

.dashboard-body .sidebar-link {
  white-space: normal;
}

.dashboard-body .sidebar-link.active {
  background: var(--accent);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(37, 86, 65, 0.2);
}

.dashboard-body .main-content {
  max-width: none;
  margin: 0;
  padding: clamp(1.75rem, 3vw, 2.75rem) clamp(1.5rem, 3.5vw, 3.5rem);
  border-radius: 18px 0 0 0;
  background: #f1f2f1;
  box-shadow: none;
}

.dashboard-body .page-title,
.dashboard-body .section-title {
  color: #244c3e;
}

.dashboard-body .page-title {
  color: var(--accent);
}

.dashboard-body .dashboard-name {
  font-family: Georgia, 'Times New Roman', serif;
  text-transform: none;
}

.dashboard-body .section-title {
  font-size: 1.12rem;
}

.dashboard-body .page-subtitle {
  color: #61766a;
}

.dashboard-body .stat-card {
  border: 0;
  background: #CBD3CF;
  box-shadow: 0 5px 16px rgba(38, 75, 58, 0.1);
  transition: transform var(--transition), box-shadow var(--transition);
}

.dashboard-body .stat-value,
.dashboard-body .stat-label {
  color: #688273;
}

.dashboard-body .stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 9px 22px rgba(38, 75, 58, 0.15);
}

.dashboard-body .stat-icon {
  background: #fff;
  color: #688273;
}

.dashboard-body .template-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  min-width: 0;
  gap: 18px;
}

.dashboard-body .template-card {
  min-width: 0;
  border: 0;
  background: #fff;
  box-shadow: 0 5px 16px rgba(38, 75, 58, 0.1);
}

.dashboard-body .template-card:hover {
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(38, 75, 58, 0.16);
}

.dashboard-body .template-card:focus-within {
  outline: 2px solid #4c8068;
  outline-offset: 3px;
}

.dashboard-body .tc-icon {
  background: #e5f0e9;
  color: #315f4d;
}

.dashboard-body .template-search-input {
  border-color: transparent;
  background: #fff;
  box-shadow: 0 4px 14px rgba(38, 75, 58, 0.1);
}

@media (min-width: 769px) and (max-width: 1023px) {
  .dashboard-body .sidebar {
    width: 196px;
    flex-basis: 196px;
  }

  .dashboard-body .main-content {
    padding: 1.75rem clamp(1.25rem, 2.5vw, 2rem);
  }

  .dashboard-body .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-body .page-header {
    flex-direction: row;
    align-items: center;
  }
}

@media (max-width: 820px) {
  .dashboard-body .app-shell {
    display: block;
    min-height: calc(100vh - 64px);
    padding: 0 0.5rem 0.5rem;
  }

  .dashboard-body .sidebar {
    position: static;
    top: auto;
    height: auto;
    width: 100%;
    flex: 0 0 auto;
    align-items: center;
    padding: 0.35rem 0.5rem;
    border-radius: 0;
    background: var(--surface-sidebar);
    box-shadow: none;
  }

  .dashboard-body .sidebar-nav {
    flex-direction: row;
  }

  .dashboard-body .sidebar-link {
    flex: 0 0 auto;
    width: auto;
    min-height: 44px;
    padding: 8px 12px;
    font-size: 0.88rem;
    white-space: nowrap;
  }

  .dashboard-body .sidebar-link span {
    display: inline;
  }

  .dashboard-body .main-content {
    padding: 1rem clamp(1rem, 4vw, 2rem);
    border-radius: 16px;
  }

  .dashboard-body .page-header {
    margin-bottom: 1.5rem;
    align-items: flex-start;
  }

  .dashboard-body .stats-grid {
    margin-bottom: 1.75rem;
  }
}

@media (max-width: 576px) {
  .navbar {
    height: 64px;
    padding-inline: 0.5rem;
  }

  .dashboard-body .app-shell {
    min-height: calc(100vh - 64px);
  }

  .dashboard-body .main-content {
    padding: 0.875rem;
  }

  .dashboard-body .page-header {
    gap: 1rem;
  }

  .dashboard-body .page-header .btn {
    width: 100%;
    justify-content: center;
  }

  .dashboard-body .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .dashboard-body .template-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .dashboard-body .template-search-toolbar {
    margin-bottom: 1.25rem;
  }

  .dashboard-body .tc-footer {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .responsive-card-table {
    min-width: 0;
  }
}
