/* App shell — navigation, layout, and component styles for the reconciliation tool */

/* ── Nav ─────────────────────────────────────────────────────────── */
.app-nav {
  background: #fff;
  border-bottom: 1.5px solid #DDD8CF;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 48px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
}

.nav-links { display: flex; gap: 8px; }

.nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--fg);
  background: var(--surface);
}

/* ── App main ─────────────────────────────────────────────────────── */
.app-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 48px 80px;
}

/* ── Page header ──────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
  gap: 24px;
}

.back-link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 8px;
}

.back-link:hover { color: var(--fg); }

.page-title {
  font-family: 'Fraunces', serif;
  font-size: 32px;
  font-weight: 900;
  color: var(--fg);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.page-sub {
  font-size: 15px;
  color: var(--muted);
  margin-top: 6px;
}

.header-actions { display: flex; gap: 12px; align-items: center; flex-shrink: 0; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 8px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover { background: #b84d0f; border-color: #b84d0f; }

.btn-outline {
  background: transparent;
  color: var(--fg);
  border-color: #DDD8CF;
}

.btn-outline:hover { background: var(--surface); }

.btn-lg { padding: 13px 28px; font-size: 15px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--muted);
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}
.btn-icon:hover { color: var(--fg); }

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

/* ── Upload panel ─────────────────────────────────────────────────── */
.upload-panel {
  background: #fff;
  border: 1.5px solid #DDD8CF;
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 40px;
  box-shadow: 0 4px 24px rgba(26,24,20,0.06);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.panel-title {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--fg);
}

.form-group { margin-bottom: 24px; }

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

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #DDD8CF;
  border-radius: 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--fg);
  background: var(--bg);
  transition: border-color 0.15s;
  outline: none;
}

.form-input:focus { border-color: var(--accent); }

.csv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.csv-box {
  border: 1.5px solid #DDD8CF;
  border-radius: 12px;
  padding: 20px;
  background: var(--bg);
}

.csv-box-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.csv-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
}

.csv-textarea {
  width: 100%;
  height: 160px;
  padding: 12px;
  border: 1.5px solid #DDD8CF;
  border-radius: 8px;
  font-family: 'DM Mono', 'Courier New', monospace;
  font-size: 12px;
  color: var(--fg);
  background: #fff;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}

.csv-textarea:focus { border-color: var(--accent); }

.csv-upload-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.file-label { cursor: pointer; }
.file-name { font-size: 12px; color: var(--muted); }

.panel-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 20px;
  border-top: 1.5px solid #F0EDE6;
}

/* ── Demo loading panel ───────────────────────────────────────────── */
.demo-panel {
  background: #fff;
  border: 1.5px solid #DDD8CF;
  border-radius: 16px;
  padding: 48px;
  margin-bottom: 40px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(26,24,20,0.06);
}

.demo-inner { display: inline-flex; flex-direction: column; align-items: center; gap: 20px; }

.demo-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--accent-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.demo-msg { font-size: 15px; color: var(--muted); }

/* ── Spinner (inline) ─────────────────────────────────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Section ──────────────────────────────────────────────────────── */
.sessions-section,
.results-section { margin-bottom: 48px; }

.section-title {
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 16px;
}

.warn-title { color: #92400E; }

/* ── Status badges ────────────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  text-transform: capitalize;
}

.status-badge.status-lg { font-size: 13px; padding: 5px 14px; }

.status-pending   { background: #F3F4F6; color: #6B7280; }
.status-processing { background: #FEF3E2; color: #B45309; }
.status-completed { background: #E6F4EA; color: #1B7A3C; }
.status-error     { background: #FEE2E2; color: #B91C1C; }

/* ── Summary cards ────────────────────────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 40px;
}

.summary-card {
  background: #fff;
  border: 1.5px solid #DDD8CF;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

.accent-card { background: var(--accent-light); border-color: var(--accent); }
.warn-card   { background: #FEF3C7; border-color: #F59E0B; }

.summary-val {
  font-family: 'Fraunces', serif;
  font-size: 36px;
  font-weight: 900;
  color: var(--fg);
  line-height: 1;
  margin-bottom: 6px;
}

.summary-val.accent { color: var(--accent); }
.summary-val.warn   { color: #92400E; }

.summary-label { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ── Tables ───────────────────────────────────────────────────────── */
.sessions-table,
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: #fff;
  border: 1.5px solid #DDD8CF;
  border-radius: 12px;
  overflow: hidden;
}

.sessions-table th,
.results-table th {
  background: var(--surface);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1.5px solid #DDD8CF;
}

.sessions-table td,
.results-table td {
  padding: 13px 16px;
  border-bottom: 1px solid #F0EDE6;
  color: var(--fg);
  vertical-align: middle;
}

.sessions-table tr:last-child td,
.results-table tr:last-child td { border-bottom: none; }

.sessions-table tr:hover td,
.results-table .matched-row:hover td { background: var(--bg); }

.results-table .exception-row td { background: #FFFBEB; }
.results-table .exception-row:hover td { background: #FEF3C7; }

.td-client { font-weight: 500; }
.td-num { text-align: right; font-variant-numeric: tabular-nums; }
.td-amt { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.td-desc { max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-note { font-size: 12px; color: var(--muted); max-width: 200px; }
.td-date { white-space: nowrap; color: var(--muted); font-size: 13px; }

.exception-count { color: #92400E; font-weight: 600; }

.exception-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: #FEF3C7;
  color: #92400E;
  white-space: nowrap;
}

.conf-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
}

.conf-high { background: #E6F4EA; color: #1B7A3C; }
.conf-mid  { background: #FEF3E2; color: #B45309; }

.link-view {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.link-view:hover { text-decoration: underline; }

/* ── Alerts ───────────────────────────────────────────────────────── */
.alert {
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 24px;
}

.alert-error   { background: #FEE2E2; color: #B91C1C; border: 1px solid #FECACA; }
.alert-success { background: #E6F4EA; color: #1B7A3C; border: 1px solid #BBF7D0; }
.alert-info    { background: #EEF2FF; color: #3B5BDB; border: 1px solid #C7D2FE; }

/* ── Empty state ──────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 32px;
  background: #fff;
  border: 1.5px solid #DDD8CF;
  border-radius: 16px;
}

.empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-title { font-family: 'Fraunces', serif; font-size: 22px; font-weight: 700; color: var(--fg); margin-bottom: 8px; }
.empty-sub { font-size: 15px; color: var(--muted); }

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

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .app-main { padding: 24px 24px 60px; }
  .app-nav-inner { padding: 0 24px; }
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .csv-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
}

@media (max-width: 600px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .sessions-table { font-size: 12px; }
}
