/* ── Variables ──────────────────────────────────────────── */
:root {
  --sidebar-bg:    #0e0e0e;
  --sidebar-text:  #929298;
  --sidebar-hover: #1a1a1a;
  --active-color:  #d4924a;
  --accent:        #d4924a;
  --accent-dark:   #b87535;
  --bg:            #111111;
  --surface:       #1c1c1c;
  --surface-2:     #222222;
  --border:        #2a2a2a;
  --text:          #e2e2e2;
  --text-muted:    #767680;
  --success:       #4a9972;
  --success-bg:    #0d1a12;
  --error-color:   #e05555;
  --radius:        8px;
  --radius-sm:     5px;
  --shadow:        0 1px 4px rgba(0,0,0,.5);
  --shadow-md:     0 4px 20px rgba(0,0,0,.6);
  --sidebar-w:     220px;
  --font-body:     'Georgia', 'Times New Roman', serif;
  --font-ui:       -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: var(--font-ui); background: var(--bg); color: var(--text);
       line-height: 1.6; min-height: 100vh; }

/* ── Layout ─────────────────────────────────────────────── */
.layout   { display: flex; min-height: 100vh; }
.main     { flex: 1; padding: 2rem 2.5rem; overflow-x: hidden; }
.two-col  { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 1.5rem; }
.col-input  { display: flex; flex-direction: column; gap: 1rem; }
.col-output { display: flex; flex-direction: column; gap: .75rem; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.3rem 1.2rem .9rem;
  color: #fff; font-weight: 700; font-size: .9rem;
  border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 1.1rem; opacity: .8; }
.brand-local-badge {
  font-size: .6rem; font-weight: 600; color: var(--success);
  background: var(--success-bg); border: 1px solid #1e3d28;
  padding: 1px 6px; border-radius: 3px; letter-spacing: .05em;
  text-transform: uppercase; margin-left: auto; flex-shrink: 0;
}
.nav-section { flex: 1; padding: .5rem 0; }
.nav-link {
  display: flex; align-items: center;
  padding: .55rem 1.2rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .85rem;
  transition: background .12s, color .12s;
  border-left: 2px solid transparent;
}
.nav-link:hover  { background: var(--sidebar-hover); color: #ccc; }
.nav-link.active { background: var(--sidebar-hover); color: #fff;
                   border-left-color: var(--active-color); }
.nav-sep {
  height: 1px; background: var(--border);
  margin: .5rem 1.2rem;
}
.nav-section-label {
  font-size: .62rem; color: #464650; text-transform: uppercase;
  letter-spacing: .09em; padding: .3rem 1.2rem .4rem; font-weight: 700;
}
.sidebar-footer  { padding: .5rem 0 1rem; border-top: 1px solid var(--border); }

/* ── Sync button ─────────────────────────────────────────── */
.sync-btn {
  display: flex; align-items: center; gap: 8px; width: calc(100% - 2.4rem);
  margin: .6rem 1.2rem 0; padding: 9px 14px;
  background: #1a2e20; color: var(--success);
  border: 1px solid #1e3d28; border-radius: var(--radius-sm);
  cursor: pointer; font-size: .82rem; font-weight: 600;
  transition: background .15s;
}
.sync-btn:hover { background: #1e3828; }
.sync-btn:disabled { opacity: .5; cursor: not-allowed; }
.sync-status {
  font-size: .72rem; color: #555; margin: .4rem 1.2rem 0;
  min-height: 14px;
}
.sync-status.ok  { color: var(--success); }
.sync-status.err { color: var(--error-color); }

/* ── Model selector ──────────────────────────────────────── */
.model-selector { padding: .75rem 1rem 0; border-top: 1px solid var(--border); }
.model-selector-label {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .07em;
  color: #464650; margin-bottom: .35rem; font-weight: 700;
}
.model-dropdown { position: relative; }
.model-current {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: .45rem .7rem; cursor: pointer; font-size: .82rem;
  font-weight: 600; transition: background .15s, border-color .15s;
}
.model-current:hover  { background: var(--surface-2); border-color: var(--active-color); }
.model-chevron        { font-size: .65rem; opacity: .5; }
.model-menu {
  position: absolute; bottom: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; box-shadow: 0 -4px 16px rgba(0,0,0,.5); z-index: 50;
}
.model-option {
  width: 100%; display: flex; flex-direction: column; gap: .1rem;
  padding: .55rem .75rem; background: none; border: none;
  cursor: pointer; text-align: left; transition: background .12s;
  border-bottom: 1px solid var(--border);
}
.model-option:last-child { border-bottom: none; }
.model-option:hover { background: #2a2a2a; }
.model-option.active { background: #2a2218; }
.model-opt-name { color: var(--text); font-size: .82rem; font-weight: 600; }
.model-opt-desc { color: var(--text-muted); font-size: .72rem; }
.model-cost-hint {
  font-size: .7rem; color: #464650; margin-top: .4rem;
  min-height: .9rem; padding-bottom: .6rem; transition: color .2s;
}
.model-cost-hint.opus   { color: #c4a0ff; }
.model-cost-hint.sonnet { color: var(--accent); }
.model-cost-hint.haiku  { color: var(--success); }

/* ── Mobile header ───────────────────────────────────────── */
.mobile-header {
  display: none; position: sticky; top: 0; z-index: 100;
  background: var(--sidebar-bg); color: #fff;
  padding: .8rem 1rem; align-items: center; gap: 1rem; font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.menu-btn { background: none; border: none; color: #fff; font-size: 1.3rem; cursor: pointer; }

/* ── Page header ─────────────────────────────────────────── */
.page-header    { margin-bottom: 1.8rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.subtitle       { color: var(--text-muted); margin-top: .3rem; font-size: .9rem; }
.page-desc      { color: var(--text-muted); margin-top: .35rem; font-size: .9rem; }
.section-title  { font-size: 1rem; font-weight: 700; margin: 1.8rem 0 .8rem; color: var(--text); }
.synopsis-preview { color: var(--text-muted); font-size: .88rem; margin-top: .4rem;
                    font-family: var(--font-body); font-style: italic; }

/* ── Stats grid ──────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .8rem; margin-bottom: 1.8rem;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.2rem;
}
.stat-value { font-size: 1.8rem; font-weight: 800; color: var(--accent); line-height: 1; }
.stat-number { font-size: 1.8rem; font-weight: 800; color: var(--accent); line-height: 1; }
.stat-label { font-size: .73rem; text-transform: uppercase; letter-spacing: .05em;
               color: var(--text-muted); margin-top: .3rem; }
.stat-sub   { font-size: .8rem; color: var(--text-muted); margin-top: .4rem; }
.cost-card  .stat-value { font-size: 1.4rem; color: var(--success); }

/* ── Progress bar ────────────────────────────────────────── */
.progress-bar-wrap { height: 6px; background: #252525; border-radius: 3px; margin: .5rem 0; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s ease; }
.progress-bar-wrap.big { height: 14px; border-radius: 7px; margin: .8rem 0; }

/* ── Module grid ─────────────────────────────────────────── */
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem; }
.module-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.15rem;
  text-decoration: none; color: var(--text);
  transition: border-color .15s, background .12s;
  display: flex; flex-direction: column; gap: .25rem;
  position: relative;
}
.module-card:hover { border-color: var(--accent); background: #1e1e1e; }
.module-card h3 { font-size: .92rem; font-weight: 600; color: var(--text); letter-spacing: -.005em; }
.module-card strong { font-size: .92rem; }
.module-card p { font-size: .78rem; color: var(--text-muted); margin: 0; line-height: 1.4; }

/* Hero / acción primaria del dashboard */
.hero-action {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem;
  background: linear-gradient(135deg, #1f1410 0%, #181412 100%);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 1.4rem 1.6rem;
  text-decoration: none; color: var(--text);
  margin-bottom: 1.75rem;
  transition: border-color .15s, transform .12s;
}
.hero-action:hover { border-left-color: var(--accent); transform: translateY(-1px); }
.hero-action h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 .2rem; }
.hero-action p  { font-size: .85rem; color: var(--text-muted); margin: 0; }
.hero-action .hero-cta {
  background: var(--accent); color: #1a0f08;
  padding: .55rem 1rem; border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 600; white-space: nowrap;
}

/* Etiqueta de sección dentro del main */
.section-label {
  font-size: .7rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .08em;
  margin: 1.75rem 0 .65rem;
}

/* ── Forms (generic) ─────────────────────────────────────── */
.field-label {
  display: block; font-size: .8rem; font-weight: 600;
  color: var(--text-muted); margin-bottom: .35rem;
  text-transform: uppercase; letter-spacing: .04em;
}
.field-input, .field-textarea {
  width: 100%; padding: .6rem .75rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font-ui); font-size: .92rem; color: var(--text);
  background: var(--surface-2); transition: border-color .15s;
  outline: none;
}
.field-input:focus, .field-textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 2px rgba(212,146,74,.12);
}
.field-textarea { resize: vertical; min-height: 120px; line-height: 1.65; }
.field-textarea.tall  { min-height: 280px; font-family: var(--font-body); font-size: .95rem; }
.field-error { border-color: var(--error-color) !important; }
.field-row   { display: flex; gap: .75rem; align-items: flex-start; }
.field-group { flex: 1; display: flex; flex-direction: column; }
.field-group-wide { flex: 2; }
.form-section { display: flex; flex-direction: column; gap: .8rem; }
.form-actions { display: flex; gap: .5rem; margin-top: .25rem; }
.form-actions-right { display: flex; justify-content: flex-end; margin-top: .5rem; }

/* ── Local form controls (form-control / form-group) ─────── */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block; font-size: .79rem; font-weight: 600;
  color: var(--text-muted); margin-bottom: .4rem;
  text-transform: uppercase; letter-spacing: .04em;
}
.form-control {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: .92rem;
  line-height: 1.65;
  outline: none;
  transition: border-color .15s;
  resize: vertical;
  display: block;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(212,146,74,.1);
}
select.form-control { resize: none; cursor: pointer; height: auto; padding: 9px 14px; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn, .btn-primary, .btn-secondary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .55rem 1.2rem; border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 600; cursor: pointer;
  border: 1px solid transparent; transition: all .15s; line-height: 1;
  text-decoration: none; white-space: nowrap; font-family: var(--font-ui);
}
.btn:disabled, .btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary  { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-secondary { background: #252218; color: var(--accent); border-color: #3a3020; }
.btn-secondary:hover { background: #2e2a1e; }
.btn-ghost    { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-full     { width: 100%; }
.btn-sm       { padding: .35rem .7rem; font-size: .8rem; }
.btn-delete   {
  background: none; border: none; color: #555; cursor: pointer;
  font-size: .85rem; padding: .1rem .3rem; border-radius: 4px; transition: color .15s;
}
.btn-delete:hover { color: var(--error-color); }

/* ── Output / response area ──────────────────────────────── */
.output-area { margin-top: 1.5rem; }
.response-text {
  background: var(--surface);
  border-left: 3px solid var(--success);
  padding: 22px 26px;
  border-radius: 0 var(--radius) var(--radius) 0;
  line-height: 1.85;
  font-size: .93rem;
  color: var(--text);
  font-family: var(--font-body);
}
.response-text h2 { font-size: 1rem; margin: 1.1rem 0 .4rem; font-family: var(--font-ui);
                     font-weight: 700; color: var(--text); }
.response-text h3 { font-size: .92rem; margin: .9rem 0 .35rem; font-family: var(--font-ui);
                     font-weight: 700; color: var(--accent); }
.response-text h4 { font-size: .88rem; margin: .7rem 0 .3rem; font-family: var(--font-ui);
                     color: var(--text-muted); }
.loading-local {
  color: var(--text-muted); font-style: italic; padding: 1.5rem 0;
  animation: pulse 1.6s ease-in-out infinite;
}
.error-msg {
  background: #1e0f0f;
  border-left: 3px solid var(--error-color);
  padding: 14px 18px;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--error-color);
  font-size: .9rem;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.45} }

/* ── Result box ──────────────────────────────────────────── */
.result-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem 1.4rem;
  min-height: 100px; font-family: var(--font-body);
  font-size: .95rem; line-height: 1.8; color: var(--text);
}
.result-box h2 { font-size: 1.05rem; margin: 1rem 0 .4rem; font-family: var(--font-ui); }
.result-box h3 { font-size: .95rem; margin: .8rem 0 .3rem; font-family: var(--font-ui); color: var(--accent); }
.result-box ul, .result-box ol { padding-left: 1.3rem; margin: .3rem 0; }
.result-box li { margin: .2rem 0; }
.result-box hr { border: none; border-top: 1px solid var(--border); margin: .8rem 0; }
.result-placeholder { color: var(--text-muted); font-family: var(--font-ui);
                       font-style: italic; font-size: .9rem; }
.result-header { display: flex; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.result-title  { font-weight: 700; font-size: .9rem; }

/* ── Loader ──────────────────────────────────────────────── */
.loader { display: flex; align-items: center; gap: .4rem; padding: .5rem 0;
           color: var(--text-muted); font-size: .85rem; }
.loader-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); animation: bounce 1.2s infinite ease-in-out;
}
.loader-dot:nth-child(2) { animation-delay: .2s; }
.loader-dot:nth-child(3) { animation-delay: .4s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40%            { transform: scale(1.0); opacity: 1; }
}

/* ── Badges & alerts ─────────────────────────────────────── */
.badge     { background: #252218; color: var(--accent); font-size: .75rem;
             padding: .2rem .55rem; border-radius: 20px; font-weight: 600;
             vertical-align: middle; border: 1px solid #3a3020; }
.date-badge{ background: var(--surface-2); color: var(--text-muted); font-size: .75rem;
             padding: .15rem .45rem; border-radius: 4px; }
.cost-badge{ font-size: .78rem; color: var(--success); background: var(--success-bg);
             padding: .15rem .45rem; border-radius: 4px; }
.cost-line { font-size: .78rem; color: var(--success); margin-top: .3rem; }
.alert     { padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .88rem; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #1e3d28; }
.error-inline  { background: #1e0f0f; border-left: 3px solid var(--error-color);
                 padding: 12px 16px; border-radius: 0 var(--radius) var(--radius) 0;
                 color: var(--error-color); font-size: .88rem; margin-top: 1rem; }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border);
         margin-bottom: 1.5rem; flex-wrap: wrap; }
.tab  {
  background: none; border: none; padding: .6rem 1rem;
  font-size: .85rem; font-weight: 600; cursor: pointer; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tab:hover  { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel  { display: none; }
.tab-panel.active { display: block; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Bible cards ─────────────────────────────────────────── */
.card-list    { display: flex; flex-direction: column; gap: .75rem; }
.bible-card   { background: var(--surface); border: 1px solid var(--border);
                border-radius: var(--radius); padding: .9rem 1rem; }
.bible-card-header { display: flex; align-items: center; gap: .5rem;
                      margin-bottom: .4rem; flex-wrap: wrap; }
.bible-card-header strong { font-size: .93rem; flex: 1; }
.bible-card-desc  { font-size: .85rem; color: var(--text-muted); line-height: 1.5;
                     font-family: var(--font-body); white-space: pre-wrap; }
.empty-state { color: var(--text-muted); font-style: italic; font-size: .9rem; padding: 1rem 0; }
.card-section { background: var(--surface); border: 1px solid var(--border);
                border-radius: var(--radius); padding: 1.1rem; }
.card-section h3 { font-size: .95rem; margin-bottom: .8rem; }

/* ── Collapsible ─────────────────────────────────────────── */
.collapsible { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.collapsible-title {
  padding: .7rem 1rem; font-size: .9rem; font-weight: 600;
  cursor: pointer; background: var(--surface); list-style: none;
}
.collapsible-title:hover { background: var(--surface-2); }
.collapsible[open] .collapsible-title { border-bottom: 1px solid var(--border); }
.collapsible .form-section { padding: 1rem; }
details > summary { list-style: none; }
details > summary::marker,
details > summary::-webkit-details-marker { display: none; }

/* ── Compare ─────────────────────────────────────────────── */
.compare-preview { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1rem 0; }
.compare-box     { background: var(--surface); border: 1px solid var(--border);
                    border-radius: var(--radius); padding: .9rem; }
.compare-label   { display: block; font-size: .78rem; font-weight: 700;
                    color: var(--accent); margin-bottom: .4rem; }
.compare-box p   { font-size: .82rem; color: var(--text-muted);
                    font-family: var(--font-body); font-style: italic; }

/* ── Session ─────────────────────────────────────────────── */
.session-setup-card { background: var(--surface); border: 1px solid var(--border);
                       border-radius: var(--radius); padding: 1.5rem; max-width: 640px; }
.session-meta { display: flex; align-items: center; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.session-context-tag { background: #252218; color: var(--accent); font-size: .82rem;
                         padding: .25rem .6rem; border-radius: 20px; font-weight: 600; flex: 1; }
.session-stats   { font-size: .8rem; color: var(--text-muted); }
.session-actions { display: flex; gap: .4rem; }
.conversation    { display: flex; flex-direction: column; gap: .75rem;
                    min-height: 200px; max-height: 500px;
                    overflow-y: auto; padding: .5rem 0; }
.msg       { padding: .75rem 1rem; border-radius: var(--radius); max-width: 85%; }
.msg-user  { background: var(--accent); color: #fff; align-self: flex-end;
              font-family: var(--font-body); line-height: 1.65; }
.msg-ai    { background: var(--surface); border: 1px solid var(--border);
              align-self: flex-start; font-size: .9rem; line-height: 1.65; }
.msg-ai h2, .msg-ai h3 { font-size: .9rem; margin: .4rem 0 .2rem; }
.msg-ai strong { color: var(--accent); }
.session-input-wrap  { background: var(--surface); border: 1px solid var(--border);
                         border-radius: var(--radius); overflow: hidden; margin-top: 1rem; }
.session-input       { width: 100%; padding: .9rem 1rem; border: none; outline: none;
                         font-family: var(--font-body); font-size: 1rem; resize: none;
                         line-height: 1.65; background: var(--surface); color: var(--text); }
.session-input-actions { display: flex; align-items: center; justify-content: space-between;
                           padding: .5rem .75rem; border-top: 1px solid var(--border);
                           background: var(--surface-2); }
.word-counter   { font-size: .78rem; color: var(--text-muted); }
.session-cost-bar { font-size: .8rem; color: var(--text-muted); margin-top: .5rem; }

/* ── Progress hero ───────────────────────────────────────── */
.progress-hero { background: var(--surface); border: 1px solid var(--border);
                  border-radius: var(--radius); padding: 1.5rem 1.8rem; margin-bottom: 1.5rem; }
.progress-hero-numbers { display: flex; align-items: baseline; gap: .4rem; }
.progress-total  { font-size: 2.4rem; font-weight: 900; color: var(--accent); }
.progress-sep    { font-size: 1.4rem; color: var(--text-muted); }
.progress-target { font-size: 1.4rem; color: var(--text-muted); }
.progress-label  { font-size: .85rem; color: var(--text-muted); }
.progress-pct    { font-size: .82rem; color: var(--text-muted); }
.projection-grid { display: flex; gap: 1.5rem; margin-top: 1rem; flex-wrap: wrap; }
.proj-item       { display: flex; flex-direction: column; }
.proj-item strong{ font-size: 1.3rem; font-weight: 800; color: var(--text); }
.proj-item span  { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.proj-item.highlight strong { color: var(--accent); }

/* ── History list ────────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: .4rem; }
.history-row  { display: flex; align-items: center; gap: .6rem; font-size: .83rem; }
.history-date { width: 90px; color: var(--text-muted); flex-shrink: 0; }
.history-bar-wrap { flex: 1; height: 8px; background: #252525; border-radius: 4px; overflow: hidden; }
.history-bar  { height: 100%; background: var(--accent); border-radius: 4px; min-width: 4px; }
.history-words{ width: 55px; text-align: right; font-weight: 600; flex-shrink: 0; }
.history-note { color: var(--text-muted); font-style: italic; overflow: hidden;
                  text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }

/* ── Login ───────────────────────────────────────────────── */
.login-body   { display: flex; align-items: center; justify-content: center;
                  min-height: 100vh; background: #0a0a0a; }
.login-card   { background: var(--surface); border: 1px solid var(--border);
                border-radius: 14px; padding: 2.5rem 2rem;
                width: 100%; max-width: 360px; box-shadow: var(--shadow-md); }
.login-icon   { font-size: 2.4rem; text-align: center; margin-bottom: .5rem; }
.login-title  { text-align: center; font-size: 1.35rem; font-weight: 800; margin-bottom: .2rem; }
.login-subtitle { text-align: center; color: var(--text-muted); font-size: .88rem; margin-bottom: 1.5rem; }
.login-form   { display: flex; flex-direction: column; gap: .5rem; }

/* ── Timeline ────────────────────────────────────────────── */
.timeline       { display: flex; flex-direction: column; gap: .5rem; }
.timeline-item  {
  display: flex; align-items: flex-start; gap: .75rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .6rem .9rem;
}
.timeline-time  { font-size: .78rem; font-weight: 700; color: var(--accent);
                   white-space: nowrap; min-width: 80px; }
.timeline-event { flex: 1; font-size: .88rem; }

/* ── Búsqueda en sidebar ──────────────────────────────────── */
.sidebar-search { padding: .55rem .8rem .25rem; position: relative; }
.sidebar-search input {
  width: 100%; padding: .42rem .6rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: .82rem; outline: none;
}
.sidebar-search input:focus { border-color: var(--accent); }
.search-results {
  position: absolute; left: .8rem; right: .8rem; top: calc(100% - .15rem);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  max-height: 60vh; overflow-y: auto; z-index: 50;
}
.search-result {
  display: block; padding: .55rem .75rem; text-decoration: none;
  border-bottom: 1px solid var(--border); color: var(--text);
}
.search-result:last-child { border-bottom: none; }
.search-result:hover { background: var(--surface-2); }
.search-result-kind {
  display: inline-block; font-size: .65rem; text-transform: uppercase;
  color: var(--accent); letter-spacing: .05em; margin-bottom: .15rem;
}
.search-result-label { font-size: .82rem; font-weight: 600; }
.search-result-snippet { font-size: .75rem; color: var(--text-muted); margin-top: .15rem; }
.search-empty { padding: .8rem; font-size: .8rem; color: var(--text-muted); text-align: center; }

/* ── Modal genérico (sync, etc.) ─────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 2rem;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 720px;
  max-height: 85vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-md);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.4rem; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 1rem; font-weight: 600; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 1.6rem; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.2rem 1.4rem; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: .9rem 1.4rem; border-top: 1px solid var(--border);
  display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap;
}

/* Sync table dentro del modal */
.sync-summary { margin-bottom: 1rem; }
.sync-ok { color: var(--success); font-size: .88rem; padding: .4rem 0; }
.sync-warn { color: var(--accent); font-size: .88rem;
             padding: .55rem .8rem; background: #1f1810; border-left: 3px solid var(--accent);
             border-radius: var(--radius-sm); margin: .35rem 0; }
.sync-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.sync-table th, .sync-table td { padding: .45rem .55rem; text-align: left;
                                 border-bottom: 1px solid var(--border); }
.sync-table th { font-weight: 600; color: var(--text-muted); font-size: .72rem;
                 text-transform: uppercase; letter-spacing: .04em; }
.sync-table td.ts { font-family: var(--font-ui); font-size: .76rem;
                    color: var(--text-muted); white-space: nowrap; }
.state-local  { color: var(--success); font-size: .78rem; }
.state-remote { color: #e07555; font-size: .78rem; }
.state-eq     { color: var(--text-muted); font-size: .78rem; }
.state-warn   { color: var(--accent); font-size: .78rem; }

/* ── Utilities ───────────────────────────────────────────── */
.mt-sm  { margin-top: .6rem; }
.mt-md  { margin-top: 1.2rem; }
.divider{ border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.help-text { font-size: .83rem; color: var(--text-muted); margin-bottom: .5rem; }
.save-ok { color: var(--success); font-size: .85rem; margin-left: 10px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .sidebar { position: fixed; left: -100%; top: 0; z-index: 200;
              height: 100vh; transition: left .25s; }
  .sidebar.open { left: 0; }
  .main   { padding: 1rem; }
  .two-col{ grid-template-columns: 1fr; }
  .compare-preview { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .projection-grid { gap: 1rem; }
}
@media (max-width: 480px) {
  .stats-grid   { grid-template-columns: 1fr; }
  .module-grid  { grid-template-columns: 1fr; }
  .field-row    { flex-direction: column; }
  .progress-hero-numbers { flex-wrap: wrap; }
}

/* ── Modo API (servidor) ──────────────────────────────────────────── */
.brand-local-badge.brand-api {
  color: var(--accent);
  background: rgba(212, 146, 74, 0.1);
  border-color: rgba(212, 146, 74, 0.3);
}

.api-panel {
  padding: .8rem 1.2rem .4rem;
  display: flex; flex-direction: column; gap: .55rem;
}
.api-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem;
}
.api-label {
  font-size: .68rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.api-cost {
  font-family: var(--font-ui); font-size: .82rem;
  color: var(--accent); font-weight: 600;
}
.api-model-select {
  flex: 1; max-width: 65%;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: .3rem .45rem; border-radius: var(--radius-sm);
  font-size: .72rem; cursor: pointer;
}
.api-model-select:focus { outline: none; border-color: var(--accent); }
.api-logout {
  margin-top: .4rem; font-size: .72rem; color: var(--text-muted);
  text-decoration: none; padding: .35rem 0; text-align: center;
  border-top: 1px solid var(--border); display: block;
}
.api-logout:hover { color: var(--accent); }

/* Modal de confirmación de coste */
.cost-estimate {
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
  text-align: center;
}
.cost-estimate-amount {
  font-size: 1.8rem; font-weight: 700;
  color: var(--accent); font-family: var(--font-ui);
}
.cost-estimate-detail {
  font-size: .72rem; color: var(--text-muted);
  margin-top: .35rem; line-height: 1.4;
}
.cost-remember {
  display: flex; align-items: center; gap: .5rem;
  font-size: .8rem; color: var(--text-muted);
  cursor: pointer;
}
.cost-remember input { cursor: pointer; }

/* ── Login ───────────────────────────────────────────────────────── */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
  background: var(--bg);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2.5rem 2.2rem;
  width: 100%; max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.login-icon { display: none; }
.login-title {
  margin: 0 0 .35rem; font-size: 1.4rem; color: var(--text);
  font-weight: 600;
}
.login-subtitle {
  margin: 0 0 1.8rem; font-size: .85rem; color: var(--text-muted);
}
.login-form .field-label {
  display: block; font-size: .72rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: .4rem; font-weight: 600;
}
.login-form .field-input {
  width: 100%; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--text);
  padding: .7rem .9rem; font-size: .9rem; border-radius: var(--radius-sm);
  margin-bottom: 1rem; box-sizing: border-box;
}
.login-form .field-input:focus { outline: none; border-color: var(--accent); }
.login-form .field-input.field-error { border-color: var(--error-color); }
.login-form .btn-full { width: 100%; padding: .8rem 1.2rem; font-size: .9rem; }
