/* ── DEWA TSD Generator — Neptune DXP App Styles ─────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Variables ──────────────────────────────────────────────────────────── */
:root {
  --green:        #007560;
  --green-dark:   #005a49;
  --green-deeper: #0f4024;
  --green-light:  #e8f4f1;
  --green-pale:   #f2faf8;

  --bg:           #faf9f7;
  --surface:      #ffffff;
  --border:       #e5e3de;
  --border-soft:  #f0ede8;

  --text:         #23221f;
  --text-muted:   #6b6862;
  --text-light:   #9c9892;

  --red:          #c0392b;
  --red-light:    #fdf2f2;
  --amber:        #d97706;
  --amber-light:  #fffbeb;
  --blue:         #2563eb;
  --blue-light:   #eff6ff;
  --purple:       #7c3aed;
  --purple-light: #f5f3ff;

  --radius:       6px;
  --radius-lg:    10px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.06);
  --shadow:       0 2px 8px rgba(0,0,0,.08);
  --shadow-lg:    0 4px 20px rgba(0,0,0,.10);

  --sidebar-w:    240px;
  --header-h:     56px;
  --font-head:    'Space Grotesk', system-ui, sans-serif;
  --font-body:    'DM Sans', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', monospace;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font-body); background: var(--bg); color: var(--text); line-height: 1.5; overflow: hidden; height: 100vh; }
a { color: var(--green); text-decoration: none; }
button { cursor: pointer; font-family: var(--font-body); }
input, select, textarea { font-family: var(--font-body); }

/* ── App Shell ──────────────────────────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--green-deeper);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-logo {
  width: 34px;
  height: 34px;
  background: var(--green);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo svg { width: 20px; height: 20px; fill: #fff; }

.sidebar-brand-text { line-height: 1.2; }
.sidebar-brand-text strong { font-family: var(--font-head); font-size: 14px; color: #fff; font-weight: 600; display: block; }
.sidebar-brand-text span  { font-size: 11px; color: rgba(255,255,255,.5); }

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

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: 8px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  border-radius: 0;
  transition: background .15s, color .15s;
  font-size: 13.5px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .8; }
.nav-item:hover  { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--green); color: #fff; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 30px; height: 30px;
  background: var(--green);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.user-info strong { font-size: 12px; color: #fff; display: block; line-height: 1.3; }
.user-info span   { font-size: 11px; color: rgba(255,255,255,.45); }

/* ── Main Layout ─────────────────────────────────────────────────────────── */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

#topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-family: var(--font-head); font-size: 16px; font-weight: 600; color: var(--text); }
.topbar-sub   { font-size: 12px; color: var(--text-muted); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

#content { flex: 1; overflow-y: auto; padding: 28px; }

/* ── Views ───────────────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }
.btn-primary   { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost     { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--border-soft); color: var(--text); }
.btn-danger    { background: var(--red-light); color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-lg { padding: 10px 22px; font-size: 14px; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-title { font-family: var(--font-head); font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }

/* ── Stat Cards ──────────────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-card-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.stat-card-icon svg { width: 18px; height: 18px; }
.stat-card-icon.green  { background: var(--green-light); color: var(--green); }
.stat-card-icon.amber  { background: var(--amber-light); color: var(--amber); }
.stat-card-icon.blue   { background: var(--blue-light);  color: var(--blue);  }
.stat-card-icon.purple { background: var(--purple-light);color: var(--purple);}
.stat-value { font-family: var(--font-head); font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); }
.stat-delta { font-size: 11px; color: var(--green); margin-top: 2px; }

/* ── Data Table ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 9px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
tbody td {
  padding: 11px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--green-pale); }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green    { background: var(--green-light);   color: var(--green-deeper); }
.badge-amber    { background: var(--amber-light);   color: #92400e; }
.badge-blue     { background: var(--blue-light);    color: #1e40af; }
.badge-red      { background: var(--red-light);     color: var(--red); }
.badge-purple   { background: var(--purple-light);  color: #5b21b6; }
.badge-gray     { background: var(--border-soft);   color: var(--text-muted); }
.badge-outline  { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }

/* Module badges */
.mod-pm     { background: #d1fae5; color: #065f46; }
.mod-mm     { background: #dbeafe; color: #1e3a8a; }
.mod-fi     { background: #fce7f3; color: #9d174d; }
.mod-hr     { background: #ede9fe; color: #4c1d95; }
.mod-sd     { background: #fef3c7; color: #78350f; }
.mod-ps     { background: #fee2e2; color: #991b1b; }
.mod-qm     { background: #ecfdf5; color: #14532d; }
.mod-wm     { background: #f0f9ff; color: #0c4a6e; }
.mod-ewm    { background: #fdf4ff; color: #701a75; }

/* WRICEF badges */
.wricef-e   { background: #fef3c7; color: #92400e; }
.wricef-r   { background: #dbeafe; color: #1e3a8a; }
.wricef-i   { background: #d1fae5; color: #065f46; }
.wricef-c   { background: #ede9fe; color: #4c1d95; }
.wricef-w   { background: #fce7f3; color: #9d174d; }
.wricef-f   { background: #fee2e2; color: #991b1b; }

/* Priority */
.priority-high   { background: #fee2e2; color: var(--red); }
.priority-medium { background: var(--amber-light); color: #92400e; }
.priority-low    { background: var(--green-light); color: var(--green-deeper); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-muted); letter-spacing: .02em; }
.form-label .required { color: var(--red); margin-left: 2px; }

.form-input, .form-select, .form-textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0,117,96,.12);
}
.form-textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
.form-textarea.tall { min-height: 160px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 32px; }
.form-hint { font-size: 11px; color: var(--text-light); }
.form-error { font-size: 11px; color: var(--red); display: none; }
.form-input.error, .form-select.error, .form-textarea.error { border-color: var(--red); }
.form-input.error + .form-error, .form-select.error + .form-error, .form-textarea.error + .form-error { display: block; }

/* ── Wizard ──────────────────────────────────────────────────────────────── */
.wizard-header { margin-bottom: 28px; }

.wizard-steps {
  display: flex;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px;
  margin-bottom: 24px;
  overflow-x: auto;
}
.wizard-step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
  min-width: 0;
}
.wizard-step:hover { background: var(--bg); }
.wizard-step.active { background: var(--green); }
.wizard-step.completed { background: var(--green-pale); }
.step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
  background: var(--border);
  color: var(--text-muted);
}
.wizard-step.active   .step-num { background: rgba(255,255,255,.25); color: #fff; }
.wizard-step.completed .step-num { background: var(--green); color: #fff; }
.step-label { font-size: 12.5px; font-weight: 500; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.wizard-step.active   .step-label { color: #fff; }
.wizard-step.completed .step-label { color: var(--green-dark); }

.step-panel { display: none; }
.step-panel.active { display: block; }

.wizard-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 24px;
  margin-top: 24px;
  border-top: 1px solid var(--border);
}
.wizard-nav-left  { display: flex; gap: 8px; }
.wizard-nav-right { display: flex; gap: 8px; }

/* Section heading inside form panels */
.section-heading {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-heading .section-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .06em;
  background: var(--green-light); color: var(--green-deeper);
  padding: 2px 7px; border-radius: 20px; text-transform: uppercase;
}

/* ── Technology Cards ────────────────────────────────────────────────────── */
.tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.tech-card-label {
  position: relative;
  cursor: pointer;
}
.tech-card-label input[type=checkbox] { position: absolute; opacity: 0; width: 0; height: 0; }
.tech-card-body {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color .15s, background .15s;
}
.tech-card-label:hover .tech-card-body { border-color: var(--green); background: var(--green-pale); }
.tech-card-label input:checked ~ .tech-card-body {
  border-color: var(--green);
  background: var(--green-light);
}
.tech-card-icon { font-size: 20px; line-height: 1; margin-bottom: 2px; }
.tech-card-name { font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.3; }
.tech-card-cat  { font-size: 11px; color: var(--text-muted); }
.tech-selected-count {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-muted);
  margin-bottom: 16px;
}
.tech-selected-count strong { color: var(--green); }

/* ── Tabs (inside Step 4) ────────────────────────────────────────────────── */
.tabs { border-bottom: 1px solid var(--border); display: flex; gap: 0; margin-bottom: 24px; overflow-x: auto; }
.tab-btn {
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--green); border-bottom-color: var(--green); }
.tab-btn.hidden { display: none; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Dynamic Row Tables (Interfaces, Test Cases, etc.) ───────────────────── */
.dynamic-table { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.dynamic-table th { padding: 7px 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); background: var(--bg); border-bottom: 1px solid var(--border); text-align: left; }
.dynamic-table td { padding: 6px 8px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.dynamic-table td input, .dynamic-table td select {
  width: 100%; padding: 5px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 12.5px;
}
.dynamic-table .del-row-btn { background: none; border: none; color: var(--text-light); cursor: pointer; padding: 4px 6px; border-radius: 4px; }
.dynamic-table .del-row-btn:hover { color: var(--red); background: var(--red-light); }
.add-row-btn { font-size: 12px; color: var(--green); padding: 5px 0; background: none; border: none; cursor: pointer; display: flex; align-items: center; gap: 5px; }
.add-row-btn:hover { color: var(--green-dark); }

/* ── List View ───────────────────────────────────────────────────────────── */
.list-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-input-wrap { position: relative; flex: 1; min-width: 200px; }
.search-input-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--text-light); }
.search-input { padding: 8px 12px 8px 34px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; background: var(--surface); width: 100%; }
.search-input:focus { outline: none; border-color: var(--green); }
.filter-selects { display: flex; gap: 8px; }
.filter-select { padding: 7px 28px 7px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 12.5px; background: var(--surface); color: var(--text); appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 6px center; background-size: 14px; }

/* ── Viewer Layout ───────────────────────────────────────────────────────── */
.viewer-wrap { display: grid; grid-template-columns: 280px 1fr; gap: 20px; }
.viewer-meta-card { position: sticky; top: 0; }
.viewer-meta-card .card { padding: 0; overflow: hidden; }
.meta-section { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.meta-section:last-child { border-bottom: none; }
.meta-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-light); margin-bottom: 3px; }
.meta-value { font-size: 13px; color: var(--text); font-weight: 500; }
.viewer-actions { display: flex; flex-direction: column; gap: 8px; }
.viewer-doc-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); min-height: 600px; overflow: hidden; }
#tsd-preview { width: 100%; min-height: 700px; border: none; border-radius: var(--radius-lg); }

/* ── Quick Actions (Dashboard) ───────────────────────────────────────────── */
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 10px;
}
.action-card:hover { border-color: var(--green); box-shadow: var(--shadow); }
.action-card-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.action-card-icon.green  { background: var(--green-light); }
.action-card-icon.amber  { background: var(--amber-light); }
.action-card-icon.blue   { background: var(--blue-light);  }
.action-card-title { font-family: var(--font-head); font-size: 14px; font-weight: 600; color: var(--text); }
.action-card-desc  { font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* ── Module Distribution Bar ─────────────────────────────────────────────── */
.module-bars { display: flex; flex-direction: column; gap: 10px; }
.module-bar-row { display: flex; align-items: center; gap: 10px; }
.module-bar-label { font-size: 12px; font-weight: 600; width: 36px; }
.module-bar-track { flex: 1; height: 8px; background: var(--border-soft); border-radius: 4px; overflow: hidden; }
.module-bar-fill  { height: 100%; background: var(--green); border-radius: 4px; transition: width .4s; }
.module-bar-count { font-size: 12px; color: var(--text-muted); width: 20px; text-align: right; }

/* ── Empty State ─────────────────────────────────────────────────────────── */
.empty-state { padding: 60px 20px; text-align: center; }
.empty-state svg { width: 48px; height: 48px; color: var(--border); margin: 0 auto 16px; display: block; }
.empty-state h3 { font-family: var(--font-head); font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--text); color: #fff;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none; z-index: 1000;
  display: flex; align-items: center; gap: 8px;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.success { background: var(--green-deeper); }
#toast.error   { background: var(--red); }

/* ── Utility ─────────────────────────────────────────────────────────────── */
.row     { display: flex; gap: 16px; align-items: flex-start; }
.gap-8   { gap: 8px; }
.mt-4    { margin-top: 4px; }
.mt-8    { margin-top: 8px; }
.mt-16   { margin-top: 16px; }
.mt-24   { margin-top: 24px; }
.mb-16   { margin-bottom: 16px; }
.mb-24   { margin-bottom: 24px; }
.flex    { display: flex; }
.flex-1  { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 12px; }
.font-mono  { font-family: var(--font-mono); font-size: 12px; }
.divider    { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── Loading overlay (Supabase initial fetch) ─────────────────────────── */
#loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(250, 249, 247, 0.88);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading-text {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-body);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── AI Generation Loading Overlay ──────────────────────────────────────── */
#ai-loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 64, 36, 0.72);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}
.ai-loading-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.2);
}
.ai-spinner {
  width: 52px;
  height: 52px;
  border: 4px solid var(--green-light);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
.ai-loading-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  font-family: var(--font-heading);
}
.ai-loading-sub {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── AI Describe Panel ───────────────────────────────────────────────────── */
.ai-describe-panel {
  background: linear-gradient(135deg, #0f3d28 0%, #0a5c3e 100%);
  border-radius: 12px;
  margin-bottom: 20px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}
.ai-describe-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  cursor: default;
}
.ai-describe-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: #fff;
  flex-shrink: 0;
}
.ai-describe-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  font-family: var(--font-heading);
}
.ai-describe-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  margin-top: 2px;
}
.ai-describe-toggle {
  margin-left: auto;
  background: rgba(255,255,255,0.1);
  border: none;
  border-radius: 6px;
  color: rgba(255,255,255,0.7);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.2s;
  flex-shrink: 0;
}
.ai-describe-toggle:hover { background: rgba(255,255,255,0.2); }
.ai-describe-body {
  padding: 0 20px 20px;
}
.ai-describe-textarea {
  width: 100%;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  line-height: 1.55;
  padding: 12px 14px;
  resize: vertical;
  font-family: var(--font-body);
  transition: border-color 0.15s;
  min-height: 90px;
}
.ai-describe-textarea::placeholder { color: rgba(255,255,255,0.35); }
.ai-describe-textarea:focus {
  outline: none;
  border-color: rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.1);
}
.ai-describe-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
}
.ai-describe-hint {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  line-height: 1.4;
  flex: 1;
}
.btn-ai-fill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  color: #0f3d28;
  border: none;
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.1s;
  font-family: var(--font-heading);
  flex-shrink: 0;
}
.btn-ai-fill:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-ai-fill:active { transform: translateY(0); }
.btn-ai-fill:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-ai-fill.loading .btn-ai-fill-icon { animation: spin 0.8s linear infinite; display: inline-block; }
.btn-ai-fill-icon { font-style: normal; }

/* ── AI Example Chips ────────────────────────────────────────────────────── */
.ai-examples-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.ai-examples-label {
  font-size: 11px;
  color: rgba(255,255,255,0.5);
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.ai-example-chip {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 20px;
  color: rgba(255,255,255,0.85);
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 12px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.ai-example-chip:hover {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.35);
  color: #fff;
}

/* ── AI Tips Strip ───────────────────────────────────────────────────────── */
.ai-tips-strip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 10px 0 0;
  padding: 10px 12px;
  background: rgba(0,0,0,0.15);
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.07);
}
.ai-tip {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  line-height: 1.5;
}
.ai-tip-icon { margin-right: 4px; }
.ai-tip strong { color: rgba(255,255,255,0.8); font-weight: 600; }

/* ── Field Hints ─────────────────────────────────────────────────────────── */
.field-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 4px;
}

/* ── WRICEF Quick Reference ──────────────────────────────────────────────── */
.wricef-guide {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--green-pale);
  border: 1px solid var(--border-soft);
  border-radius: 7px;
}
.wg-item {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.wg-item strong {
  color: var(--green);
  font-weight: 700;
  margin-right: 4px;
  font-family: var(--font-mono);
}
