/* ── Reset ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; color: #111; background: #faf9f7; line-height: 1.5;
}
a { color: inherit; }

/* ── Layout ──────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 190px; min-width: 190px;
  background: #f2f0eb;
  border-right: 1px solid #e0ddd6;
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0;
  overflow-y: auto; z-index: 10;
}
.main { margin-left: 190px; flex: 1; }
.content { padding: 28px 32px 60px; }

/* ── Sidebar Logo ──────────────────────────────── */
.sidebar-logo { padding: 20px 16px 16px; border-bottom: 1px solid #e0ddd6; }
.sidebar-logo-mark {
  width: 28px; height: 28px; background: #111; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
}
.sidebar-logo-mark span { color: #fff; font-size: 11px; font-weight: 700; }
.sidebar-brand { font-size: 13px; font-weight: 700; color: #111; margin-top: 10px; }
.sidebar-sub { font-size: 11px; color: #888; margin-top: 2px; }

/* ── Sidebar Nav ──────────────────────────────── */
.sidebar-nav { padding: 8px; flex: 1; }
.sidebar-nav a {
  display: block; padding: 7px 10px; border-radius: 4px;
  font-size: 14px; color: #555; text-decoration: none; margin-bottom: 2px;
}
.sidebar-nav a:hover { background: #ece9e3; color: #111; }
.sidebar-nav a.active { background: #e8e5de; color: #111; font-weight: 600; }
.sidebar-footer { padding: 12px 16px; font-size: 12px; color: #ccc; border-top: 1px solid #e0ddd6; }

/* ── Page Header ──────────────────────────────── */
.page-title { font-size: 20px; font-weight: 700; color: #111; }

/* ── Breadcrumb ──────────────────────────────── */
.breadcrumb { font-size: 12px; color: #888; margin-bottom: 16px; }
.breadcrumb a { color: #888; text-decoration: none; }
.breadcrumb a:hover { color: #111; }
.breadcrumb-sep { margin: 0 6px; color: #ccc; }

/* ── Cards ──────────────────────────────────── */
.card { background: #fff; border: 1px solid #e8e4dd; border-radius: 6px; }
.card-body { padding: 20px; }
.card-section { padding: 20px; }
.card-section + .card-section { border-top: 1px solid #f2efe8; }

/* ── Buttons ──────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 7px 14px; font-size: 13px; font-weight: 500;
  border-radius: 4px; cursor: pointer; text-decoration: none;
  border: 1px solid transparent; line-height: 1.3;
}
.btn-primary { background: #222; color: #fff; border-color: #222; }
.btn-primary:hover { background: #000; color: #fff; }
.btn-secondary { background: #fff; color: #555; border-color: #d4d0c8; }
.btn-secondary:hover { background: #f8f7f4; }
.btn-danger { background: #fff; color: #991b1b; border-color: #fca5a5; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; font-weight: 600; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* ── Tables ──────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: #888; padding: 8px;
  border-bottom: 1px solid #e8e4dd; text-align: left; white-space: nowrap;
}
tbody td { font-size: 14px; padding: 15px 8px; border-bottom: 1px solid #f2efe8; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
.table-group-label td {
  font-size: 15px; font-weight: 700; color: #222;
  background: #e8e4dc; padding: 14px 16px;
  border-bottom: 2px solid #ccc9c0;
  border-top: 1px solid #d0ccc3;
  cursor: pointer; user-select: none;
}
.table-group-label td:hover { background: #e0dbd2; }
.group-toggle {
  display: inline-block;
  font-size: 11px; color: #555;
  transition: transform .2s ease;
  margin-right: 8px;
  vertical-align: middle;
}
.group-toggle.collapsed { transform: rotate(-90deg); }

/* ── Status text colors ──────────────────────── */
.status-completed { color: #2d6a4f; }
.status-pending   { color: #92400e; }
.status-ai        { color: #1e3a8a; }
.status-fetching  { color: #555555; }
.status-failed    { color: #991b1b; }

/* ── Progress bar ──────────────────────────── */
.progress-bar { height: 3px; background: #edeae3; border-radius: 2px; overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; border-radius: 2px; transition: width .3s; }
.progress-fill-completed { background: #2d6a4f; }
.progress-fill-pending   { background: #92400e; }
.progress-fill-ai        { background: #1e3a8a; }
.progress-fill-fetching  { background: #555; }

/* ── Forms ──────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: #111; margin-bottom: 6px; }
.form-label-req { color: #991b1b; margin-left: 2px; }
.form-hint { font-size: 12px; color: #bbb; margin-top: 5px; }
.form-formula {
  font-size: 12px; color: #888; margin-top: 6px;
  font-family: monospace; background: #f8f7f4;
  border: 1px solid #e8e4dd; border-radius: 4px; padding: 6px 10px;
}
input[type="text"],
input[type="date"],
input[type="number"],
input[type="email"],
select,
textarea {
  width: 100%; padding: 8px 10px; font-size: 14px; font-family: inherit;
  border: 1px solid #d4d0c8; border-radius: 4px;
  background: #fff; color: #111; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #999; }
.input-sm { padding: 5px 8px !important; font-size: 13px !important; width: auto; }

/* ── Step Bar ──────────────────────────────── */
.steps { display: flex; align-items: center; margin-bottom: 28px; }
.step { display: flex; align-items: center; gap: 6px; }
.step-dot {
  width: 20px; height: 20px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.step-dot-done   { background: #2d6a4f; color: #fff; }
.step-dot-active { background: #222; color: #fff; }
.step-dot-pending{ background: #e8e4dd; color: #888; }
.step-label { font-size: 12px; color: #888; white-space: nowrap; }
.step-label-active { color: #111; font-weight: 600; }
.step-sep { flex: 1; height: 1px; background: #e8e4dd; margin: 0 6px; min-width: 12px; }

/* ── Client Cards ──────────────────────────── */
.client-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.client-card {
  background: #fff; border: 1px solid #e8e4dd; border-radius: 6px;
  padding: 20px; text-decoration: none; color: inherit; display: block;
}
.client-card:hover { border-color: #999; }
.client-card-add {
  border-style: dashed; color: #888;
  display: flex; align-items: center; justify-content: center;
  min-height: 90px; font-size: 14px;
}
.client-card-add:hover { border-color: #555; color: #555; }
.client-card-name { font-size: 16px; font-weight: 700; color: #111; }
.client-card-meta { font-size: 12px; color: #888; margin-top: 5px; }

/* ── KPI Summary Cards ──────────────────────── */
.kpi-grid { display: grid; gap: 16px; margin-bottom: 24px; }
.kpi-card { background: #fff; border: 1px solid #e8e4dd; border-radius: 6px; padding: 16px; }
.kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: #888; margin-bottom: 8px; }
.kpi-value { font-size: 26px; font-weight: 700; color: #111; line-height: 1; }
.kpi-formula { font-size: 11px; color: #aaa; margin-top: 6px; font-family: monospace; }

/* ── Filter Tabs ──────────────────────────── */
.filter-row { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; border-bottom: 1px solid #e8e4dd; }
.filter-tab {
  padding: 8px 2px; font-size: 13px; color: #888;
  text-decoration: none; border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
}
.filter-tab:hover { color: #555; }
.filter-tab.active { color: #111; font-weight: 600; border-bottom-color: #111; }
.filter-search { margin-left: auto; margin-bottom: 4px; }
.filter-search input { padding: 5px 10px; font-size: 13px; border: 1px solid #d4d0c8; border-radius: 4px; width: 180px; }

/* ── Dcard row ──────────────────────────────── */
.row-dcard { background: #fffdf9; }
.cell-highlight { border: 1px solid #fcd34d !important; }

/* ── Spinner ──────────────────────────────── */
.spinner {
  width: 28px; height: 28px; border: 2px solid #e8e4dd;
  border-top-color: #555; border-radius: 50%;
  animation: spin .8s linear infinite; margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Section label ──────────────────────────── */
.section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: #888; margin-bottom: 12px; }

/* ── Grid helpers ──────────────────────────── */
.row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row-3col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Utilities ──────────────────────────────── */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-end     { display: flex; justify-content: flex-end; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.text-sm    { font-size: 12px; }
.text-xs    { font-size: 11px; }
.text-muted { color: #888; }
.text-light { color: #bbb; }
.text-center{ text-align: center; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.w-100  { width: 100%; }
