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

:root {
  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface2: #f9fafb;
  --border: #e1e3e5;
  --border-light: #f0f1f2;
  --sidebar-bg: #1a1a2e;
  --sidebar-text: #a0aec0;
  --sidebar-active: #ffffff;
  --sidebar-hover: rgba(255,255,255,0.07);
  --sidebar-active-bg: rgba(255,255,255,0.12);
  --accent: #008060;
  --accent-hover: #006e52;
  --accent-light: #e8f5f1;
  --text: #1a1a2e;
  --text-secondary: #6d7175;
  --text-muted: #9ca3af;
  --green: #008060;
  --green-bg: #e8f5f1;
  --yellow: #b98900;
  --yellow-bg: #fff5e5;
  --red: #d72c0d;
  --red-bg: #fff4f4;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.09);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.18);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── App Layout (Sidebar + Content) ──────────────────────────────────────────*/
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  flex-shrink: 0;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; color: #fff; }
.logo span { color: #34d399; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  text-align: left;
  transition: all 0.15s;
  width: 100%;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); }
.nav-icon { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-bottom {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shop-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.shop-dot { width: 7px; height: 7px; background: #34d399; border-radius: 50%; flex-shrink: 0; }
.shop-name-text { font-size: 11px; color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.logout-link {
  font-size: 12px;
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  transition: all 0.15s;
  text-align: center;
}
.logout-link:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; }

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content {
  margin-left: 220px;
  flex: 1;
  min-height: 100vh;
}

.page { padding: 28px 32px; }
.page.hidden { display: none; }

/* ── Page Header ──────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn-primary {
  padding: 9px 18px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary.done { background: var(--green); }

.btn-lg { padding: 13px 28px; font-size: 15px; border-radius: 10px; }

.btn-secondary {
  padding: 9px 18px;
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { border-color: var(--text-secondary); }

.btn-text {
  background: none; border: none; color: var(--accent);
  font-size: 13px; font-weight: 500; cursor: pointer; font-family: inherit;
  padding: 4px 0;
}
.btn-text:hover { text-decoration: underline; }

/* ── Landing Page ─────────────────────────────────────────────────────────── */
body.landing {
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(135deg, #f6f6f7 0%, #eef2ff 100%);
}
.landing-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 52px 44px; max-width: 460px; width: 100%;
  box-shadow: var(--shadow-md);
}
.landing-card .logo { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; margin-bottom: 6px; color: var(--text); }
.landing-card .logo span { color: var(--accent); }
.tagline { color: var(--text-secondary); margin-bottom: 36px; font-size: 14px; }
.landing-card label { display: block; font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 8px; }
.input-row { display: flex; gap: 8px; }
.input-row input {
  flex: 1; padding: 10px 14px; background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; font-family: inherit; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,128,96,0.1); }
.input-row input::placeholder { color: var(--text-muted); }
.input-row button { padding: 10px 20px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer; }
.input-row button:hover { background: var(--accent-hover); }
.form-error { color: var(--red); font-size: 13px; margin-top: 8px; }
.features { display: flex; flex-direction: column; gap: 10px; margin-top: 32px; }
.feature { display: flex; align-items: center; gap: 12px; padding: 13px 16px; background: var(--surface2); border-radius: var(--radius-sm); border: 1px solid var(--border-light); }
.feature .icon { font-size: 16px; }
.feature p { font-size: 13px; color: var(--text-secondary); }

/* ── Welcome State ────────────────────────────────────────────────────────── */
.welcome-wrap {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 80px 32px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.welcome-icon { font-size: 48px; margin-bottom: 20px; }
.welcome-title { font-size: 24px; font-weight: 700; letter-spacing: -0.4px; margin-bottom: 10px; }
.welcome-sub { font-size: 14px; color: var(--text-secondary); max-width: 420px; margin-bottom: 28px; line-height: 1.6; }
.welcome-features { display: flex; flex-direction: column; gap: 8px; margin-top: 28px; text-align: left; }
.wf-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.wf-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.wf-dot.green { background: var(--green); }

/* ── Loading ──────────────────────────────────────────────────────────────── */
.loading-wrap {
  display: flex; flex-direction: column; align-items: center; padding: 100px 32px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.spinner-lg {
  width: 40px; height: 40px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.75s linear infinite; margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.loading-sub { font-size: 13px; color: var(--text-secondary); }

/* ── Dashboard Results ────────────────────────────────────────────────────── */
.score-cards {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.score-card-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow);
}

.score-ring-wrap { position: relative; width: 110px; height: 110px; flex-shrink: 0; }
.score-ring { width: 110px; height: 110px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--border); stroke-width: 8; }
.ring-fill { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1s ease, stroke 0.3s; }
.ring-inner { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-score { font-size: 26px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.ring-label { font-size: 10px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; }

.score-card-info { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.score-card-label { font-size: 11px; color: var(--text-secondary); font-weight: 500; }
.audit-date { font-size: 11px; color: var(--text-muted); }

.exec-grade {
  font-size: 24px; font-weight: 800;
  width: 48px; height: 48px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.grade-a { background: var(--green-bg); color: var(--green); }
.grade-b { background: #e8f4fd; color: #0071c2; }
.grade-c { background: var(--yellow-bg); color: var(--yellow); }
.grade-d { background: #fff0e6; color: #c05200; }
.grade-f { background: var(--red-bg); color: var(--red); }

.stat-cards {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.stat-val { font-size: 28px; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.stat-val.red { color: var(--red); }
.stat-val.yellow { color: var(--yellow); }
.stat-val.green { color: var(--green); }
.stat-label { font-size: 11px; color: var(--text-secondary); margin-top: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px; }

/* ── Section Cards ────────────────────────────────────────────────────────── */
.section-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title { font-size: 14px; font-weight: 600; }

.insight-list { display: flex; flex-direction: column; gap: 8px; }
.insight-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; background: var(--surface2); border-radius: var(--radius-sm); border: 1px solid var(--border-light); }
.insight-msg { font-size: 13px; color: var(--text); }
.insight-count { font-size: 12px; font-weight: 600; color: var(--red); background: var(--red-bg); padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.text-muted { font-size: 13px; color: var(--text-muted); }

/* ── Quick Items ──────────────────────────────────────────────────────────── */
.quick-items { display: flex; flex-direction: column; gap: 8px; }
.quick-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--surface2); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); cursor: pointer; transition: background 0.1s;
}
.quick-item:hover { background: #f0f1f3; }
.quick-item-info { flex: 1; min-width: 0; }
.quick-item-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick-item-type { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

/* ── Filters ──────────────────────────────────────────────────────────────── */
.filters { margin-bottom: 12px; }
.search-input {
  padding: 8px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 13px;
  font-family: inherit; width: 260px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,128,96,0.1); }
.search-input::placeholder { color: var(--text-muted); }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.items-table { width: 100%; border-collapse: collapse; }
.items-table thead th { background: var(--surface2); padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-secondary); border-bottom: 1px solid var(--border); }
.items-table tbody tr { border-bottom: 1px solid var(--border-light); transition: background 0.1s; }
.items-table tbody tr:last-child { border-bottom: none; }
.items-table tbody tr:hover { background: #fafbfc; }
.items-table td { padding: 13px 16px; vertical-align: middle; font-size: 13px; }

.score-badge { display: inline-flex; flex-direction: column; align-items: center; padding: 6px 10px; border-radius: 8px; min-width: 52px; }
.score-badge.good { background: var(--green-bg); color: var(--green); }
.score-badge.medium { background: var(--yellow-bg); color: var(--yellow); }
.score-badge.poor { background: var(--red-bg); color: var(--red); }
.score-num { font-size: 17px; font-weight: 800; line-height: 1; }
.score-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-top: 1px; }

.item-title { font-weight: 500; color: var(--text); }
.type-tag { display: inline-block; padding: 3px 9px; background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; font-size: 11px; font-weight: 500; color: var(--text-secondary); }
.meta-cell { font-size: 12px; color: var(--text-secondary); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-cell.missing { color: var(--text-muted); font-style: italic; }

.btn-optimize { padding: 6px 14px; background: var(--surface); border: 1.5px solid var(--border); color: var(--text-secondary); border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; font-family: inherit; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.btn-optimize:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

.empty-audit-state { padding: 80px; text-align: center; color: var(--text-secondary); font-size: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

/* ── Bulk Optimize ────────────────────────────────────────────────────────── */
.bulk-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 56px; text-align: center; box-shadow: var(--shadow); max-width: 600px; margin: 0 auto;
}
.bulk-icon { font-size: 48px; margin-bottom: 16px; }
.bulk-title { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 12px; }
.bulk-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.7; margin-bottom: 28px; }
.bulk-stats { display: flex; gap: 24px; justify-content: center; margin-bottom: 24px; }
.bulk-stat { font-size: 13px; color: var(--text-secondary); }
.bulk-stat span { font-weight: 700; color: var(--text); font-size: 18px; }
.bulk-progress { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 24px; }
.bulk-progress-text { font-size: 13px; color: var(--text-secondary); }
.bulk-result { margin-top: 24px; }
.bulk-result-inner { padding: 28px; border-radius: var(--radius); border: 1px solid; }
.bulk-result-inner.success { border-color: var(--green); background: var(--green-bg); }
.bulk-result-icon { font-size: 32px; margin-bottom: 8px; }
.bulk-result-title { font-size: 18px; font-weight: 700; color: var(--green); margin-bottom: 8px; }
.bulk-result-sub { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; }

/* ── History ──────────────────────────────────────────────────────────────── */
.history-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 12px; box-shadow: var(--shadow); }
.history-card.latest { border-color: var(--accent); }
.history-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.history-date { font-size: 14px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.history-meta { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }
.latest-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; background: var(--accent); color: #fff; padding: 2px 7px; border-radius: 20px; }
.history-breakdown { display: flex; gap: 16px; margin-bottom: 10px; }
.hb-item { font-size: 12px; font-weight: 500; }
.hb-item.red { color: var(--red); }
.hb-item.yellow { color: var(--yellow); }
.hb-item.green { color: var(--green); }
.history-issues { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── Issues ───────────────────────────────────────────────────────────────── */
.issue { display: inline-block; font-size: 11px; font-weight: 500; padding: 3px 9px; border-radius: 20px; }
.issue.high { background: var(--red-bg); color: var(--red); }
.issue.medium { background: var(--yellow-bg); color: var(--yellow); }
.issue.low { background: var(--accent-light); color: var(--accent); }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); backdrop-filter: blur(4px); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 680px; box-shadow: var(--shadow-lg); overflow: hidden; animation: modalIn 0.2s ease; }
@keyframes modalIn { from { transform: scale(0.96) translateY(8px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }

.modal-header { display: flex; align-items: flex-start; justify-content: space-between; padding: 22px 24px 18px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-sub { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }
.modal-close { background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; width: 30px; height: 30px; cursor: pointer; font-size: 13px; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.modal-close:hover { border-color: var(--text-secondary); color: var(--text); }

.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; max-height: 60vh; overflow-y: auto; }

.modal-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.modal-col { display: flex; flex-direction: column; gap: 6px; }

.modal-section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }
.char-count { font-weight: 500; color: var(--accent); text-transform: none; letter-spacing: 0; }

.modal-field { padding: 10px 14px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; color: var(--text); line-height: 1.5; min-height: 60px; }
.modal-field.missing { color: var(--text-muted); font-style: italic; }
.modal-field.suggested { border-color: var(--accent); background: var(--accent-light); }

.modal-divider { display: flex; align-items: center; gap: 12px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--accent); }
.modal-divider::before, .modal-divider::after { content: ''; flex: 1; height: 1px; background: var(--accent); opacity: 0.3; }

.modal-issues { display: flex; flex-wrap: wrap; gap: 6px; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface2); }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 18px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; max-width: 360px; z-index: 999; box-shadow: var(--shadow-md); animation: slideUp 0.2s ease; background: var(--surface); }
.toast.success { border: 1.5px solid var(--green); color: var(--green); }
.toast.error { border: 1.5px solid var(--red); color: var(--red); }
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
