/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:      #1a3a5c;
  --brand-light:#2a527a;
  --accent:     #2563eb;
  --accent-bg:  #eff6ff;
  --success:    #16a34a;
  --warning:    #d97706;
  --error:      #dc2626;
  --surface:    #ffffff;
  --bg:         #f1f5f9;
  --border:     #e2e8f0;
  --text:       #1e293b;
  --text-2:     #475569;
  --text-3:     #94a3b8;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --radius:     8px;
  --radius-sm:  4px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

/* ── Navbar ───────────────────────────────────────────────────────────────── */
.navbar {
  background: var(--brand);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 32px;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { display: flex; align-items: center; gap: 10px; color: white; }
.nav-logo  { font-size: 22px; opacity: .9; }
.nav-title { font-size: 17px; font-weight: 700; letter-spacing: .3px; }
.nav-sub   { font-size: 12px; color: rgba(255,255,255,.55); margin-top: 1px; display: none; }
@media (min-width: 640px) { .nav-sub { display: block; } }

.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-link  {
  color: rgba(255,255,255,.75);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
}
.nav-link:hover, .nav-link.active {
  color: white;
  background: rgba(255,255,255,.12);
}
.nav-link.active { background: rgba(255,255,255,.18); }
.nav-actions { margin-left: auto; }
.btn-logout {
  background: transparent;
  border: 1px solid rgba(255,255,255,.3);
  color: rgba(255,255,255,.8);
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.1); color: white; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.main-content { max-width: 1100px; margin: 0 auto; padding: 32px 24px 64px; }
.page-header  { margin-bottom: 28px; }
.page-title   { font-size: 24px; font-weight: 700; color: var(--text); }
.page-desc    { font-size: 14px; color: var(--text-2); margin-top: 6px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  cursor: pointer; border: none; transition: all .15s;
  text-decoration: none;
}
.btn-primary  { background: var(--accent); color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; }
.btn-outline  { background: white; color: var(--accent); border: 1px solid var(--accent); }
.btn-outline:hover { background: var(--accent-bg); }
.btn-ghost    { background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm       { padding: 5px 12px; font-size: 13px; }
.btn-block    { width: 100%; }
.mt-20        { margin-top: 20px; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group    { margin-bottom: 16px; }
.form-label    { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.form-input, .form-select {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; color: var(--text); background: white;
  transition: border-color .15s;
}
.form-input:focus, .form-select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }
.alert-error { background: #fef2f2; color: var(--error); border: 1px solid #fecaca; }

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-body   { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--brand); }
.login-card   { background: white; border-radius: 12px; padding: 48px 40px; width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-logo   { font-size: 40px; text-align: center; margin-bottom: 8px; }
.login-title  { text-align: center; font-size: 26px; font-weight: 700; color: var(--brand); }
.login-sub    { text-align: center; font-size: 13px; color: var(--text-3); margin-bottom: 28px; }
.login-input  { font-size: 15px; padding: 11px 14px; }
.login-footer { text-align: center; font-size: 12px; color: var(--text-3); margin-top: 28px; }

/* ── Query Page ───────────────────────────────────────────────────────────── */
.query-container  { display: flex; flex-direction: column; gap: 20px; }
.query-box        { background: white; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.query-input      {
  width: 100%; padding: 16px 18px;
  border: none; outline: none; resize: none;
  font-size: 15px; font-family: inherit; color: var(--text);
  line-height: 1.5; border-bottom: 1px solid var(--border);
}
.query-input::placeholder { color: var(--text-3); }
.query-controls   { display: flex; align-items: center; padding: 12px 16px; gap: 12px; }
.mode-label       { font-size: 13px; color: var(--text-2); font-weight: 500; }
.mode-buttons     { display: flex; gap: 4px; }
.mode-btn         {
  padding: 5px 12px; border-radius: 20px; font-size: 13px;
  border: 1px solid var(--border); background: white;
  color: var(--text-2); cursor: pointer; transition: all .15s;
  display: flex; align-items: center; gap: 4px;
}
.mode-btn.active  { background: var(--brand); color: white; border-color: var(--brand); }
.mode-btn:hover:not(.active) { border-color: var(--accent); color: var(--accent); }
.btn-ask          { margin-left: auto; padding: 8px 24px; }

/* Result area */
.result-area    { background: white; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.loading        { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 48px 24px; }
.loading-spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text   { font-size: 14px; color: var(--text-2); }
.steps-trace    { font-size: 13px; color: var(--text-2); text-align: center; }
.step-pill      {
  display: inline-block; background: var(--bg);
  border: 1px solid var(--border); border-radius: 12px;
  padding: 2px 10px; font-size: 12px; margin: 2px;
}

.answer-box     { display: flex; gap: 14px; padding: 22px 22px 18px; border-bottom: 1px solid var(--border); }
.answer-icon    { font-size: 22px; margin-top: 2px; flex-shrink: 0; }
.answer-text    { font-size: 15px; line-height: 1.65; color: var(--text); }

.data-section   { }
.data-header    { display: flex; align-items: center; padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--border); gap: 12px; }
.row-count      { font-size: 13px; color: var(--text-2); flex: 1; }
.data-actions   { display: flex; gap: 8px; }

.sql-block      { background: #1e293b; padding: 14px 18px; overflow-x: auto; }
.sql-code       { font-family: 'Menlo', 'Monaco', 'Courier New', monospace; font-size: 13px; color: #94a3b8; white-space: pre-wrap; word-break: break-all; }

.table-wrap     { overflow-x: auto; max-height: 450px; overflow-y: auto; }
.data-table     { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th  { background: var(--brand); color: white; padding: 8px 12px; text-align: left; font-weight: 500; position: sticky; top: 0; white-space: nowrap; }
.data-table td  { padding: 7px 12px; border-bottom: 1px solid var(--border); color: var(--text); }
.data-table tr:hover td { background: var(--accent-bg); }

.error-box      { padding: 20px 22px; background: #fef2f2; color: var(--error); font-size: 14px; }
.error-box strong { display: block; margin-bottom: 4px; }

/* Example questions */
.example-questions { }
.examples-label  { font-size: 13px; color: var(--text-2); margin-bottom: 10px; font-weight: 500; }
.examples-grid   { display: flex; flex-wrap: wrap; gap: 8px; }
.example-pill    {
  padding: 6px 14px; background: white; border: 1px solid var(--border);
  border-radius: 20px; font-size: 13px; color: var(--text-2);
  cursor: pointer; transition: all .15s;
}
.example-pill:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }

/* ── Upload Page ──────────────────────────────────────────────────────────── */
.upload-container { display: flex; flex-direction: column; gap: 24px; }
.upload-card      { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.drop-zone        {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 48px 24px; text-align: center; cursor: pointer;
  transition: all .2s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent); background: var(--accent-bg);
}
.drop-icon    { font-size: 36px; margin-bottom: 12px; }
.drop-text    { font-size: 15px; font-weight: 500; color: var(--text); }
.drop-sub     { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.file-input-hidden { display: none; }
.file-selected     { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--bg); border-radius: var(--radius-sm); }
.file-icon         { font-size: 20px; }
.file-name-text    { flex: 1; font-size: 14px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.upload-progress { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.progress-bar-wrap { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin-bottom: 14px; }
.progress-bar    { height: 100%; background: var(--accent); border-radius: 4px; width: 0; transition: width .2s; }
.progress-text   { font-size: 14px; color: var(--text-2); text-align: center; }

.upload-result   { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; text-align: center; }
.result-icon     { font-size: 40px; margin-bottom: 12px; }
.result-title    { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 16px; }
.result-output   { text-align: left; background: var(--bg); border-radius: var(--radius-sm); padding: 14px; font-size: 12px; font-family: monospace; max-height: 300px; overflow-y: auto; white-space: pre-wrap; color: var(--text-2); }

.upload-guide    { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.guide-title     { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 14px; }
.guide-table     { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 14px; }
.guide-table th  { background: var(--brand); color: white; padding: 7px 12px; text-align: left; }
.guide-table td  { padding: 7px 12px; border-bottom: 1px solid var(--border); }
.guide-note      { font-size: 13px; color: var(--text-2); }

/* ── Registry Page ────────────────────────────────────────────────────────── */
.registry-container { display: flex; flex-direction: column; gap: 24px; }
.registry-section   { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.section-title      { font-size: 15px; font-weight: 600; color: var(--brand); margin-bottom: 16px; text-transform: uppercase; letter-spacing: .5px; font-size: 13px; }
.stat-cards         { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.stat-card          { background: var(--bg); border-radius: var(--radius-sm); padding: 16px; }
.stat-value         { font-size: 26px; font-weight: 700; color: var(--brand); font-variant-numeric: tabular-nums; }
.stat-label         { font-size: 13px; font-weight: 500; color: var(--text); margin-top: 4px; }
.stat-sub           { font-size: 11px; color: var(--text-3); margin-top: 2px; font-family: monospace; }
.registry-footer    { display: flex; align-items: center; justify-content: space-between; padding: 0 4px; }
.refresh-time       { font-size: 13px; color: var(--text-3); }

/* ── Utilities ────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
