@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #f4f6f9;
  --surface:     #ffffff;
  --border:      #e2e8f0;
  --border-soft: #edf0f5;

  --text:        #0f172a;
  --text-2:      #475569;
  --text-3:      #94a3b8;

  --green:       #16a34a;
  --green-dark:  #15803d;
  --green-light: #dcfce7;
  --green-mid:   #bbf7d0;
  --green-dim:   rgba(22,163,74,0.08);

  --amber:       #d97706;
  --amber-light: #fef3c7;
  --red:         #dc2626;
  --red-light:   #fee2e2;
  --red-dim:     rgba(220,38,38,0.08);
  --blue:        #2563eb;
  --blue-light:  #dbeafe;
  --blue-dim:    rgba(37,99,235,0.08);

  /* Dark sidebar */
  --sidebar-bg:         #0d1f14;
  --sidebar-border:     rgba(255,255,255,0.08);
  --sidebar-text:       rgba(255,255,255,0.68);
  --sidebar-active-bg:  #16a34a;

  --sidebar-w:   240px;
  --topbar-h:    60px;
  --radius:      10px;
  --radius-sm:   6px;
  --shadow:      0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
  --shadow-md:   0 4px 6px rgba(0,0,0,.05), 0 10px 24px rgba(0,0,0,.06);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Inputs ── */
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
  padding: .6rem .85rem;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-dim);
}
label {
  font-size: 13px; font-weight: 500;
  color: var(--text-2); display: block; margin-bottom: .35rem;
}

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; font-family: inherit;
  border: none; cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .1s;
  white-space: nowrap; flex-shrink: 0;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--green); color: #fff; }
.btn-primary:hover:not(:disabled)   { background: var(--green-dark); box-shadow: 0 2px 8px rgba(22,163,74,.3); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); border-color: #cbd5e1; }
.btn-ghost     { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled)     { background: var(--bg); color: var(--text); }
.btn-danger    { background: var(--red-dim); color: var(--red); border: 1px solid rgba(220,38,38,.15); }
.btn-danger:hover:not(:disabled)    { background: var(--red-light); }

.btn-sm   { padding: .35rem .75rem; font-size: 12.5px; }
.btn-lg   { padding: .75rem 1.5rem; font-size: 15px; font-weight: 600; }
.btn-full { width: 100%; }

/* ── Spinner ── */
.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block; flex-shrink: 0;
}
.spinner-dark { border-color: rgba(0,0,0,.12); border-top-color: var(--text-2); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: .18rem .55rem;
  border-radius: 99px;
  font-size: 11.5px; font-weight: 600;
}
.badge-green { background: var(--green-light); color: var(--green-dark); }
.badge-amber { background: var(--amber-light); color: var(--amber); }
.badge-red   { background: var(--red-light);   color: var(--red); }
.badge-blue  { background: var(--blue-light);  color: var(--blue); }
.badge-gray  { background: #f1f5f9;            color: #64748b; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; padding: .65rem 1rem;
  color: var(--text-3); font-weight: 600;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  background: #f8fafc; white-space: nowrap;
}
table[style*="table-layout:fixed"] th { white-space: normal; }
td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
  overflow: hidden; text-overflow: ellipsis;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }
.num-cell { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }

/* ════════════════════════════════════════
   APP LAYOUT  —  sidebar + main
   ════════════════════════════════════════ */
.app-layout {
  display: block;
  min-height: 100vh;
}

/* ── Sidebar (dark) ── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex; align-items: center; gap: .6rem;
  flex-shrink: 0;
}
.sidebar-logo-icon { font-size: 1.3rem; }
.sidebar-logo-text { font-size: 1rem; font-weight: 700; color: #ffffff; }
.sidebar-logo-sub  { font-size: .7rem; color: rgba(255,255,255,0.45); font-weight: 400; display: block; }

.sidebar-nav {
  flex: 1;
  padding: .75rem .65rem;
  display: flex; flex-direction: column; gap: 2px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px; font-weight: 700;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase; letter-spacing: .08em;
  padding: .75rem .6rem .25rem;
}

.nav-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.65);
  font-size: 13.5px; font-weight: 450;
  cursor: pointer; text-decoration: none;
  transition: background .12s, color .12s;
}
.nav-item:hover  { background: rgba(255,255,255,0.07); color: #ffffff; }
.nav-item.active { background: var(--sidebar-active-bg); color: #ffffff; font-weight: 600; }

.nav-icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  stroke-width: 2;
}

.sidebar-footer {
  padding: .75rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}
.user-chip {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem .5rem;
  border-radius: var(--radius-sm);
  min-width: 0;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--green-light); color: var(--green-dark);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-chip { cursor: pointer; }
.user-chip:hover { background: rgba(255,255,255,0.07); }
.user-info { min-width: 0; flex: 1; }
.user-name  { font-size: 13px; font-weight: 600; color: #ffffff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; color: rgba(255,255,255,0.45); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Profile panel ── */
.profile-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.45); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.profile-overlay.open { opacity: 1; pointer-events: all; }
.profile-panel {
  background: #fff; border-radius: 18px; width: 420px; max-width: calc(100vw - 2rem);
  box-shadow: 0 24px 80px rgba(0,0,0,.2); overflow: hidden;
  transform: translateY(16px); transition: transform .2s;
}
.profile-overlay.open .profile-panel { transform: none; }
.profile-panel-head {
  background: #0d1f14; padding: 1.5rem 1.5rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
}
.profile-big-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: #16a34a; color: #fff;
  font-size: 20px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.profile-head-name  { font-size: 15px; font-weight: 700; color: #fff; }
.profile-head-email { font-size: 12px; color: rgba(255,255,255,.5); margin-top: .15rem; }
.profile-close {
  margin-left: auto; background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,.5); font-size: 1.3rem; line-height: 1; padding: 0 .25rem;
  transition: color .12s;
}
.profile-close:hover { color: #fff; }
.profile-body { padding: 1.5rem; }
.pf-group { margin-bottom: 1rem; }
.pf-group label { display: block; font-size: 11px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .35rem; }
.pf-group input {
  width: 100%; padding: .6rem .85rem; font-size: 14px; font-family: inherit;
  border: 1.5px solid #e2e8f0; border-radius: 8px; background: #f8fafc;
  color: #0f172a; outline: none; transition: border-color .15s, box-shadow .15s;
}
.pf-group input:focus { border-color: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,.1); }
.pf-group input:disabled { color: #94a3b8; background: #f1f5f9; cursor: default; }
.pf-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; }
.profile-actions { display: flex; gap: .75rem; margin-top: 1.25rem; }
.pf-save {
  flex: 1; padding: .65rem; font-size: 14px; font-weight: 700;
  background: #16a34a; color: #fff; border: none; border-radius: 9px;
  cursor: pointer; transition: background .15s; font-family: inherit;
}
.pf-save:hover { background: #15803d; }
.pf-save:disabled { opacity: .6; cursor: not-allowed; }
.pf-chpw {
  flex: 1; padding: .65rem; font-size: 14px; font-weight: 600;
  background: none; color: #475569; border: 1.5px solid #e2e8f0;
  border-radius: 9px; cursor: pointer; transition: border-color .15s; font-family: inherit;
}
.pf-chpw:hover { border-color: #94a3b8; }
.profile-divider { border: none; border-top: 1px solid #f1f5f9; margin: 1.25rem 0; }
.pf-logout {
  width: 100%; padding: .6rem; font-size: 14px; font-weight: 600;
  background: none; color: #dc2626; border: 1.5px solid #fecaca;
  border-radius: 9px; cursor: pointer; transition: background .15s; font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: .5rem;
}
.pf-logout:hover { background: #fff1f2; }
.pf-msg { font-size: 12px; text-align: center; margin-top: .75rem; min-height: 16px; color: #16a34a; font-weight: 600; }

/* ── Main content ── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 0 2rem;
  height: var(--topbar-h);
  background: rgba(255,255,255,.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  flex-shrink: 0;
}
.topbar-left { display: flex; flex-direction: column; justify-content: center; min-width: 0; flex: 1; }
.topbar-title { font-size: .9rem; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub   { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }

/* ── Page body ── */
.page-body {
  padding: 1.75rem 2rem;
  flex: 1;
}

/* ════════════════════════════════════════
   STEP INDICATOR  (analyze page)
   ════════════════════════════════════════ */
.step-bar {
  display: flex; align-items: center;
  gap: 0;
  padding: 0 2rem;
  height: 44px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.step-item {
  display: flex; align-items: center; gap: .45rem;
  font-size: 12.5px; font-weight: 500;
  color: var(--text-3);
  white-space: nowrap;
  flex-shrink: 0;
}
.step-item.active { color: var(--green-dark); font-weight: 600; }
.step-item.done   { color: var(--green); }
.step-num {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--border); color: var(--text-3);
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.step-item.active .step-num { background: var(--green); color: #fff; }
.step-item.done   .step-num { background: var(--green-light); color: var(--green-dark); }
.step-sep {
  width: 28px; height: 1px; background: var(--border);
  margin: 0 .4rem; flex-shrink: 0;
}

/* ════════════════════════════════════════
   DASHBOARD METRICS  (4 cards in a row)
   ════════════════════════════════════════ */
.metrics-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.4rem;
  display: flex;
  align-items: center;
  gap: .9rem;
}
.metric-icon {
  width: 42px; height: 42px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.metric-icon-green { background: var(--green-light); color: var(--green-dark); }
.metric-icon-blue  { background: var(--blue-light);  color: var(--blue); }
.metric-icon-amber { background: var(--amber-light); color: var(--amber); }
.metric-icon-red   { background: var(--red-light);   color: var(--red); }
.metric-body       { min-width: 0; }
.metric-label { font-size: 10.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.metric-value { font-size: 1.6rem; font-weight: 700; color: var(--text); line-height: 1.1; margin: .2rem 0 .15rem; }
.metric-green { color: var(--green-dark); }
.metric-sub   { font-size: 11.5px; color: var(--text-3); }

/* stat-trend */
.stat-trend {
  display: inline-flex; align-items: center; gap: .2rem;
  font-size: 11px; font-weight: 600;
  padding: .1rem .4rem; border-radius: 99px;
}
.stat-trend-up   { background: var(--red-light);   color: var(--red); }
.stat-trend-down { background: var(--green-light);  color: var(--green-dark); }
.stat-trend-flat { background: #f1f5f9;             color: #64748b; }

/* ════════════════════════════════════════
   CHART CONTAINERS  (dashboard)
   ════════════════════════════════════════ */
.dashboard-3col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
  display: flex; flex-direction: column;
}
.chart-card-title {
  font-size: 13.5px; font-weight: 600; color: var(--text);
  margin-bottom: .2rem;
}
.chart-card-sub {
  font-size: 11.5px; color: var(--text-3);
  margin-bottom: 1rem;
}
.chart-container {
  position: relative;
  flex: 1;
  min-height: 180px;
}
.chart-empty {
  display: flex; align-items: center; justify-content: center;
  height: 180px; color: var(--text-3); font-size: 13px;
  flex-direction: column; gap: .5rem; text-align: center;
}

/* nav-badge */
.nav-badge {
  margin-left: auto;
  background: rgba(220,38,38,0.85);
  color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 99px;
  padding: .05rem .4rem;
  min-width: 16px; text-align: center;
}

/* ════════════════════════════════════════
   STAT CARDS  (project / analyze pages)
   ════════════════════════════════════════ */
.stats-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stats-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stats-grid-2 { grid-template-columns: repeat(2, 1fr); }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
}
.stat-label       { font-size: 10.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.stat-value       { font-size: 1.75rem; font-weight: 700; color: var(--text); margin: .25rem 0 .1rem; line-height: 1; }
.stat-value-green { color: var(--green-dark); }
.stat-sub         { font-size: 11.5px; color: var(--text-3); }
.stat-green       { border-left: 3px solid var(--green); }

/* ════════════════════════════════════════
   SECTION HEADER
   ════════════════════════════════════════ */
.section-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.section-title { font-size: 14.5px; font-weight: 600; color: var(--text); }
.section-sub   { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ════════════════════════════════════════
   PROJECT CARDS GRID
   ════════════════════════════════════════ */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  text-decoration: none;
  display: flex; flex-direction: column; gap: .9rem;
  box-shadow: var(--shadow);
}
.project-card:hover {
  border-color: var(--green);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.project-card-top { display: flex; align-items: center; gap: .65rem; }
.project-avatar {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--green-light); color: var(--green-dark);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; letter-spacing: .02em;
}
.project-card-meta { min-width: 0; flex: 1; }
.project-card-name { font-size: 13.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-card-loc  { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-card-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: .4rem;
  padding-top: .75rem; border-top: 1px solid var(--border-soft);
}
.project-stat-label { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.project-stat-value { font-size: 14px; font-weight: 700; color: var(--text); margin-top: 1px; }
.project-stat-unit  { font-size: 10px; font-weight: 400; color: var(--text-3); }
.project-stat-green { color: var(--green-dark); }
.project-budget-row { }
.mt-half { margin-top: .25rem; }

/* project card image / color header */
.project-card-image {
  height: 5px; border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg, var(--green) 0%, #22c55e 100%);
  margin: -1.1rem -1.25rem 0;
  border-bottom: none;
}

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 4rem 2rem;
  color: var(--text-3); grid-column: 1 / -1;
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .6; }
.empty-state h3   { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: .4rem; }
.empty-state p    { font-size: 13px; max-width: 340px; margin: 0 auto 1.25rem; line-height: 1.7; }

/* ── Progress bar ── */
.progress-bar-wrap { width: 100%; background: var(--border); border-radius: 99px; height: 5px; }
.progress-bar      { height: 100%; border-radius: 99px; background: var(--green); transition: width .4s ease; }
.progress-bar.over { background: var(--red); }

/* ── Bar chart ── */
.chart-row   { display: flex; align-items: center; gap: .75rem; margin-bottom: .55rem; font-size: 12.5px; }
.chart-label { width: 160px; min-width: 160px; text-align: right; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-bar-bg{ flex: 1; background: var(--border-soft); border-radius: 4px; height: 18px; overflow: hidden; border: 1px solid var(--border); }
.chart-bar   { height: 100%; background: var(--green); border-radius: 3px; transition: width .5s ease; min-width: 2px; }
.chart-val   { width: 100px; min-width: 100px; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ── Drop Zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center; cursor: pointer;
  transition: border-color .2s, background .2s;
  background: #fafbfc;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--green); background: var(--green-light); }
.drop-icon { font-size: 2.25rem; margin-bottom: .65rem; }
.drop-text { font-size: 14.5px; font-weight: 600; color: var(--text-2); }
.drop-sub  { font-size: 12px; color: var(--text-3); margin-top: .3rem; }

.file-selected {
  display: flex; align-items: center; gap: .65rem;
  background: var(--green-light); border: 1px solid var(--green-mid);
  border-radius: var(--radius-sm); padding: .6rem 1rem;
  font-size: 13px; color: var(--green-dark);
}
.file-selected .remove {
  margin-left: auto; background: none; border: none;
  color: var(--green-dark); cursor: pointer; font-size: 1rem; line-height: 1;
}

/* ── Alerts ── */
.alert {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .85rem 1rem; border-radius: var(--radius-sm);
  font-size: 13px;
}
.alert-error   { background: var(--red-dim);    border: 1px solid rgba(220,38,38,.2); color: var(--red); }
.alert-success { background: var(--green-light); border: 1px solid var(--green-mid); color: var(--green-dark); }
.alert-info    { background: var(--blue-dim);   border: 1px solid rgba(37,99,235,.2); color: var(--blue); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--text); color: #fff;
  padding: .75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500;
  box-shadow: 0 4px 24px rgba(0,0,0,.18);
  z-index: 500;
  animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 440px;
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  box-sizing: border-box;
  overflow: hidden;
}
.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  margin-top: 1.25rem;
}
.modal-actions .btn { width: 100%; justify-content: center; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.modal-title  { font-size: 15px; font-weight: 600; color: var(--text); }
.modal-close  { background: none; border: none; color: var(--text-3); font-size: 1.1rem; cursor: pointer; line-height: 1; padding: .25rem; }
.modal-close:hover { color: var(--text); }
.form-field   { margin-bottom: 1rem; }

/* ── Coming soon ── */
.coming-soon-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: 10.5px; font-weight: 600;
  background: var(--amber-light); color: var(--amber);
  padding: .15rem .5rem; border-radius: 99px;
  vertical-align: middle;
}

/* ── Auth page ── */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #f0fdf4 0%, #f4f6f9 50%, #eff6ff 100%);
  padding: 1.5rem;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-md);
}
.auth-logo      { text-align: center; margin-bottom: 2rem; }
.auth-logo-icon { font-size: 2.2rem; display: block; margin-bottom: .5rem; }
.auth-logo-name { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.auth-logo-sub  { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }

.auth-tabs {
  display: flex; margin-bottom: 1.75rem;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 3px;
}
.auth-tab {
  flex: 1; text-align: center; padding: .45rem;
  border-radius: 5px; font-size: 13.5px; font-weight: 500;
  cursor: pointer; color: var(--text-3);
  transition: background .15s, color .15s;
  border: none; background: transparent; font-family: inherit;
}
.auth-tab.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 600;
}

/* ── Period toggle (carbon trends page) ── */
.period-toggle {
  display: flex; gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.period-btn {
  padding: .4rem .9rem;
  font-size: 12.5px; font-weight: 500; font-family: inherit;
  border: none; background: var(--surface); color: var(--text-2);
  cursor: pointer; transition: background .12s, color .12s;
  border-right: 1px solid var(--border);
}
.period-btn:last-child { border-right: none; }
.period-btn.active { background: var(--green); color: #fff; }
.period-btn:hover:not(.active) { background: var(--bg); }

/* ── Report cards (reports page) ── */
.report-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .75rem;
}
.report-card-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--green-light); color: var(--green-dark);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
}
.report-card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.report-card-desc  { font-size: 12.5px; color: var(--text-3); line-height: 1.6; flex: 1; }

/* ── Compliance cards ── */
.compliance-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.compliance-score-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
  text-align: center;
}
.compliance-score {
  font-size: 2.5rem; font-weight: 800;
  color: var(--green-dark);
  line-height: 1;
  margin: .5rem 0 .35rem;
}
.compliance-label { font-size: 10.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.compliance-status { font-size: 12.5px; font-weight: 600; margin-top: .35rem; }

/* ── Settings sections ── */
.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.settings-section-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.settings-section-title { font-size: 14px; font-weight: 600; color: var(--text); }
.settings-section-body  { padding: 1.25rem 1.5rem; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 0; border-bottom: 1px solid var(--border-soft);
  gap: 1rem;
}
.settings-row:last-child { border-bottom: none; }
.settings-row-label { font-size: 13.5px; font-weight: 500; color: var(--text); }
.settings-row-sub   { font-size: 12px; color: var(--text-3); margin-top: 1px; }

/* ── Integration card ── */
.integration-row {
  display: flex; align-items: center; gap: 1rem;
  padding: .85rem 0; border-bottom: 1px solid var(--border-soft);
}
.integration-row:last-child { border-bottom: none; }
.integration-logo {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.integration-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.integration-desc { font-size: 12px; color: var(--text-3); }

/* ════════════════════════════════════════
   UTILITY
   ════════════════════════════════════════ */
.flex            { display: flex; }
.flex-col        { flex-direction: column; }
.gap-1           { gap: .5rem; }
.gap-2           { gap: 1rem; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-1  { margin-top: .5rem; }
.mt-2  { margin-top: 1rem; }
.mt-3  { margin-top: 1.5rem; }
.mb-1  { margin-bottom: .5rem; }
.mb-2  { margin-bottom: 1rem; }
.mb-3  { margin-bottom: 1.75rem; }
.text-muted    { color: var(--text-3); }
.text-sm       { font-size: 12.5px; }
.text-xs       { font-size: 11.5px; }
.font-semibold { font-weight: 600; }
.w-full        { width: 100%; }

/* ════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════ */
@media (max-width: 1100px) {
  .dashboard-3col { grid-template-columns: 1fr 1fr; }
  .metrics-bar    { grid-template-columns: repeat(2, 1fr); }
  .compliance-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .compliance-grid { grid-template-columns: 1fr; }
}

/* ── Hamburger button (desktop: hidden) ── */
.hamburger-btn {
  display: none;
  align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  padding: .4rem; border-radius: var(--radius-sm);
  color: var(--text-2);
  flex-shrink: 0;
  transition: background .12s;
}
.hamburger-btn:hover { background: var(--border); }

/* ── Sidebar backdrop (mobile) ── */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 299;
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.sidebar-open { display: block; }

@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  .sidebar {
    transform: translateX(-100%);
    z-index: 300;
    transition: transform .25s ease;
    width: 240px;
  }
  .sidebar.sidebar-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .metrics-bar { grid-template-columns: 1fr 1fr; }
  .stats-grid-4, .stats-grid-3 { grid-template-columns: repeat(2, 1fr); }
  .page-body { padding: 1rem; }
  .topbar { padding: 0 1rem; }
  .dashboard-3col { grid-template-columns: 1fr; }
  .hamburger-btn { display: flex; }
}

@media (max-width: 600px) {
  .stats-grid-4, .stats-grid-3, .stats-grid-2 { grid-template-columns: 1fr; }
  .metrics-bar { grid-template-columns: 1fr; }
  .projects-grid { grid-template-columns: 1fr; }
  .report-cards { grid-template-columns: 1fr; }
}

/* ════════════════════════════════════════
   MOBILE — COMPREHENSIVE FIXES
   ════════════════════════════════════════ */

/* Prevent iOS input zoom (font-size must be ≥16px) */
@media (max-width: 900px) {
  input, select, textarea { font-size: 16px !important; }
}

/* ── Splash screen ── */
#cper-splash {
  position: fixed; inset: 0; z-index: 9999;
  background: #0d1f14;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1.5rem;
  transition: opacity .4s ease;
}
#cper-splash.fade-out { opacity: 0; pointer-events: none; }
#cper-splash img { width: 280px; height: 280px; object-fit: contain; border-radius: 36px; }
#cper-splash .splash-name {
  font-size: 36px; font-weight: 800; color: #fff;
  letter-spacing: -.5px;
}
#cper-splash .splash-sub {
  font-size: 13px; color: rgba(255,255,255,.55);
  margin-top: -.75rem; text-align: center; max-width: 200px; line-height: 1.5;
}
#cper-splash .splash-bar {
  width: 120px; height: 3px; background: rgba(255,255,255,.15);
  border-radius: 99px; overflow: hidden; margin-top: .5rem;
}
#cper-splash .splash-bar-fill {
  height: 100%; width: 0; background: #16a34a;
  border-radius: 99px;
  animation: splashLoad 1.2s ease forwards;
}
@keyframes splashLoad { to { width: 100%; } }

/* ── Sidebar logo with image ── */
.sidebar-logo-img {
  width: 72px; height: 72px; object-fit: contain;
  border-radius: 12px; flex-shrink: 0;
}

/* ── Mobile topbar logo ── */
.topbar-logo-mobile {
  display: none;
  align-items: center; gap: .5rem;
  font-weight: 800; font-size: 15px; color: var(--text);
  text-decoration: none; flex: 1; justify-content: center;
}
.topbar-logo-mobile img { width: 52px; height: 52px; object-fit: contain; border-radius: 8px; }
@media (max-width: 900px) {
  .topbar-logo-mobile { display: flex; }
}

/* ── Topbar on mobile ── */
@media (max-width: 900px) {
  .topbar {
    position: sticky; top: 0; z-index: 100;
    background: var(--surface); border-bottom: 1px solid var(--border);
  }
  .topbar-title { font-size: 14px; }
  .topbar-sub   { display: none; }
  .topbar-right { gap: .35rem; }
}

/* ── Touch-friendly tap targets ── */
@media (max-width: 900px) {
  .nav-item { min-height: 44px; }
  .btn, button { min-height: 40px; }
  .tab-btn { min-height: 38px; padding: .5rem 1rem; }
}

/* ── Tables: horizontal scroll on mobile ── */
@media (max-width: 768px) {
  .table-wrap, .card table, table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  th, td { white-space: nowrap; }
  /* allow text wrap in description/name cells */
  td:first-child, th:first-child { white-space: normal; min-width: 120px; }
}

/* ── Cards & page body ── */
@media (max-width: 480px) {
  .page-body { padding: .75rem; }
  .card { border-radius: 8px; }
  .stat-card { padding: .9rem 1rem; }
  .stat-value { font-size: 1.4rem; }
  .topbar { padding: 0 .75rem; }
}

/* ── Charts on mobile: fix height ── */
@media (max-width: 600px) {
  canvas { max-height: 220px; }
}

/* ── Two-column grid → single on small phones ── */
@media (max-width: 480px) {
  .stats-grid-4, .stats-grid-3, .stats-grid-2 { grid-template-columns: 1fr; }
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns:2fr 1fr"] { grid-template-columns: 1fr !important; }
}

/* ── Modals: full-width on mobile ── */
@media (max-width: 600px) {
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    overflow-y: auto;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0;
  }
}

/* ── Forms: full-width inputs ── */
@media (max-width: 600px) {
  .form-row { flex-direction: column; }
  .form-row > * { width: 100% !important; }
  [style*="display:grid"][style*="grid-template-columns: 1fr 1fr auto"],
  [style*="display:grid"][style*="grid-template-columns:1fr 1fr auto"] {
    grid-template-columns: 1fr !important;
  }
}

/* ── Reports download cards ── */
@media (max-width: 640px) {
  .export-card-grid { grid-template-columns: 1fr !important; }
}

/* ── Kanban / reduction action cards ── */
@media (max-width: 600px) {
  [style*="grid-template-columns: repeat(3"] { grid-template-columns: 1fr !important; }
  [style*="grid-template-columns:repeat(3"]  { grid-template-columns: 1fr !important; }
}

/* ── Supply chain charts row ── */
@media (max-width: 768px) {
  #chartsRow { grid-template-columns: 1fr !important; }
}

/* ── Sidebar user chip ── */
@media (max-width: 900px) {
  .user-email { display: none; }
}

/* ── Safe area insets for notched phones ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .sidebar-footer { padding-bottom: calc(.5rem + env(safe-area-inset-bottom)); }
  @media (max-width: 900px) {
    .main-content { padding-bottom: env(safe-area-inset-bottom); }
  }
}

/* ════════════════════════════════════════
   DARK MODE
   ════════════════════════════════════════ */
[data-theme="dark"] {
  --bg:          #0f172a;
  --surface:     #1e293b;
  --border:      #334155;
  --border-soft: #1e293b;
  --text:        #f1f5f9;
  --text-2:      #cbd5e1;
  --text-3:      #64748b;
  --green-light: rgba(22,163,74,.2);
  --green-mid:   rgba(22,163,74,.3);
  --green-dim:   rgba(22,163,74,.12);
  --amber-light: rgba(217,119,6,.2);
  --red-light:   rgba(220,38,38,.2);
  --blue-light:  rgba(37,99,235,.2);
  --shadow:      0 1px 3px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.25);
  --shadow-md:   0 4px 6px rgba(0,0,0,.3), 0 10px 24px rgba(0,0,0,.25);
}

[data-theme="dark"] body       { background: var(--bg); color: var(--text); }
[data-theme="dark"] .card      { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .topbar    { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .main-content { background: var(--bg); }

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea   { background: var(--bg); border-color: var(--border); color: var(--text); }

[data-theme="dark"] .stat-card  { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .chart-card { background: var(--surface); }
[data-theme="dark"] .metric-card { background: var(--surface); }
[data-theme="dark"] .modal      { background: var(--surface); }
[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,.7); }

[data-theme="dark"] table thead tr { background: var(--surface); }
[data-theme="dark"] table td, [data-theme="dark"] table th { border-color: var(--border-soft); }
[data-theme="dark"] .table-wrap    { background: var(--surface); }

[data-theme="dark"] .project-card  { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .tab-btn       { background: var(--bg); color: var(--text-2); border-color: var(--border); }
[data-theme="dark"] .tab-btn.active { background: var(--green); color: #fff; }
[data-theme="dark"] .badge         { background: var(--border); color: var(--text-2); }
[data-theme="dark"] .settings-section { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .settings-section-header { border-color: var(--border); }
[data-theme="dark"] .settings-section-body   { background: var(--surface); }
[data-theme="dark"] .btn-secondary { background: var(--border); color: var(--text); border-color: var(--border); }
