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

:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface2: #f3f3f3;
    --border: #e2e2e2;
    --border2: #cccccc;
    --text: #333333;
    --muted: #777777;
    --accent: #3898EC;
    --accent2: #4CAF50;
    --accent3: #60a5fa;
    --danger: #e53935;
    --warning: #fbbf24;
    --font-display: 'Syne', sans-serif;
    --font-body: 'IBM Plex Sans', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
    --radius: 8px;
    --radius-lg: 14px;
    --sidebar: 220px;
}

[data-theme="dark"] {
    --bg: #0d0f14;
    --surface: #13161e;
    --surface2: #1a1e28;
    --border: rgba(255, 255, 255, 0.07);
    --border2: rgba(255, 255, 255, 0.12);
    --text: #e8eaf0;
    --muted: #9ca3af;
    --accent: #c8f135;
    --accent2: #4ade80;
    --accent3: #60a5fa;
    --danger: #f87171;
    --warning: #fbbf24;
}

html,
body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
}

/* LAYOUT */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    padding: 0;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--border);
}

.logo-mark {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon svg {
    width: 75px;
    height: 75px;
}

.logo-name {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text);
}

.logo-sub {
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-top: 1px;
}

.sidebar-section {
    padding: 16px 12px 8px;
}

.sidebar-label {
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 8px 8px;
    font-weight: 500;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
    transition: all 0.15s;
    margin-bottom: 2px;
    user-select: none;
}

.nav-item:hover {
    background: var(--surface2);
    color: var(--text);
}

.nav-item.active {
    background: rgba(200, 241, 53, 0.1);
    color: var(--accent);
}

.nav-item svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item.active svg {
    opacity: 1;
}

.nav-badge {
    margin-left: auto;
    background: var(--surface2);
    color: var(--muted);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 20px;
    font-family: var(--font-mono);
}

.nav-item.active .nav-badge {
    background: rgba(200, 241, 53, 0.15);
    color: var(--accent);
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 12px;
    border-top: 1px solid var(--border);
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s;
}

.user-pill:hover {
    background: var(--surface2);
}

.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4ade80, #60a5fa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #0d0f14;
    flex-shrink: 0;
}

.user-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
}

.user-role {
    font-size: 10px;
    color: var(--muted);
}

/* MAIN */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* TOPBAR */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.topbar-title {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
}

.topbar-spacer {
    flex: 1;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-select {
    background: var(--surface2);
    border: 1px solid var(--border2);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 12px;
    padding: 6px 10px;
    border-radius: var(--radius);
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 24px;
    background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: border-color 0.15s;
}

.filter-select:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-family: var(--font-body);
    transition: all 0.15s;
}

.btn-primary {
    background: var(--accent);
    color: #0d0f14;
}

.btn-primary:hover {
    background: #d4f550;
}

.btn-ghost {
    background: var(--surface2);
    color: var(--muted);
    border: 1px solid var(--border2);
}

.btn-ghost:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.2);
}

/* CONTENT */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* KPI CARDS */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.2s;
    cursor: default;
}

.kpi-card:hover {
    border-color: var(--border2);
}

.kpi-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 500;
}

.kpi-value {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: 500;
    color: var(--text);
    line-height: 1;
}

.kpi-value.positive {
    color: var(--accent2);
}

.kpi-value.accent {
    color: var(--accent);
}

.kpi-delta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
}

.delta-up {
    color: var(--accent2);
}

.delta-dn {
    color: var(--danger);
}

.kpi-sub {
    font-size: 11px;
    color: var(--muted);
}

/* GRID 2-COL */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.grid-3-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}

/* PANEL */
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.panel-title {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.panel-sub {
    font-size: 11px;
    color: var(--muted);
    margin-top: 1px;
}

.panel-body {
    padding: 20px;
}

/* CHART */
.chart-wrap {
    position: relative;
    width: 100%;
    height: 200px;
}

/* TABLE */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

thead tr {
    border-bottom: 1px solid var(--border2);
}

th {
    text-align: left;
    padding: 10px 14px;
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}

th.num {
    text-align: right;
}

td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

td.num {
    text-align: right;
    font-family: var(--font-mono);
    font-size: 12px;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover td {
    background: var(--surface2);
}

.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
}

.tag-blue {
    background: rgba(96, 165, 250, 0.12);
    color: #93c5fd;
}

.tag-green {
    background: rgba(74, 222, 128, 0.12);
    color: #86efac;
}

.tag-amber {
    background: rgba(251, 191, 36, 0.12);
    color: #fcd34d;
}

.tag-red {
    background: rgba(248, 113, 113, 0.12);
    color: #fca5a5;
}

.tag-purple {
    background: rgba(167, 139, 250, 0.12);
    color: #c4b5fd;
}

.tag-gray {
    background: rgba(107, 114, 128, 0.15);
    color: #9ca3af;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.dot-green {
    background: var(--accent2);
}

.dot-red {
    background: var(--danger);
}

.dot-amber {
    background: var(--warning);
}

.pct-bar-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pct-bar {
    flex: 1;
    height: 3px;
    background: var(--surface2);
    border-radius: 2px;
    overflow: hidden;
    min-width: 60px;
}

.pct-fill {
    height: 100%;
    border-radius: 2px;
}

/* MINI LIST */
.mini-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mini-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}

.mini-row:last-child {
    border-bottom: none;
}

.mini-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mini-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.mini-right {
    text-align: right;
}

.mini-val {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 500;
}

.mini-sub2 {
    font-size: 10px;
    color: var(--muted);
}

/* TABS */
.tabs {
    display: flex;
    gap: 2px;
    background: var(--surface2);
    padding: 3px;
    border-radius: var(--radius);
}

.tab {
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 11px;
    cursor: pointer;
    color: var(--muted);
    transition: all 0.15s;
}

.tab.active {
    background: var(--surface);
    color: var(--text);
}

/* SCROLLBAR */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border2);
    border-radius: 10px;
}

.chip {
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-weight: 500;
}

.theme-toggle {
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    border: 1px solid var(--border2);
    background: var(--surface2);
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    flex-shrink: 0;
}

.theme-toggle:hover {
    color: var(--text);
    border-color: var(--muted);
}

.theme-toggle svg {
    width: 15px;
    height: 15px;
}

.icon-sun {
    display: none;
}

.icon-moon {
    display: block;
}

[data-theme="dark"] .icon-sun {
    display: block;
}

[data-theme="dark"] .icon-moon {
    display: none;
}

.config-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.config-row:last-child {
    border-bottom: none;
}

.config-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.config-desc {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}

.config-input {
    background: var(--surface2);
    border: 1px solid var(--border2);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 12px;
    padding: 6px 10px;
    border-radius: var(--radius);
    outline: none;
    min-width: 200px;
}

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

.toggle-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
}

.toggle {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--surface2);
    border: 1px solid var(--border2);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.toggle.on {
    background: var(--accent);
    border-color: var(--accent);
}

.toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--muted);
    border-radius: 50%;
    transition: left 0.2s, background 0.2s;
}

.toggle.on::after {
    left: 18px;
    background: #0d0f14;
}

/* ================================================================
   Excel Import — button, modal, states
   ================================================================ */

/* ── Import trigger button ─────────────────────────────── */
.btn-import-excel {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid #4ade80;
  border-radius: var(--radius);
  background: transparent;
  color: #4ade80;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.btn-import-excel:hover {
  background: #4ade80;
  color: #0d0f14;
}

/* ── Overlay ───────────────────────────────────────────── */
.import-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  backdrop-filter: blur(3px);
}

/* ── Modal box ─────────────────────────────────────────── */
.import-box {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  width: 460px;
  max-width: 95vw;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.import-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
}
.import-title {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.import-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.15s;
}
.import-close:hover { color: var(--text); }

.import-body  { padding: 22px; min-height: 130px; }
.import-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 22px 18px;
}

/* ── Preview ───────────────────────────────────────────── */
.import-preview { display: flex; flex-direction: column; gap: 14px; }

.import-file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 10px;
  background: rgba(74, 222, 128, 0.08);
  border: 1px solid rgba(74, 222, 128, 0.22);
}
.import-file-card strong { display: block; font-size: 13px; word-break: break-all; color: var(--text); }
.import-size { font-size: 11px; color: var(--muted); }

.import-note { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ── Loading ───────────────────────────────────────────── */
.import-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.import-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border2);
  border-top-color: #4ade80;
  border-radius: 50%;
  animation: imp-spin 0.7s linear infinite;
}
@keyframes imp-spin { to { transform: rotate(360deg); } }

/* ── Result ────────────────────────────────────────────── */
.import-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  padding: 6px 0;
}
.import-result h4 { margin: 0; font-size: 18px; color: var(--text); }

.import-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin: 8px 0;
}
.import-stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stat-val    { font-family: var(--font-mono); font-size: 30px; font-weight: 700; color: var(--text); }
.stat-lbl    { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.stat-created { color: #4ade80; }
.stat-updated { color: #6091fa; }

/* ── Error list ────────────────────────────────────────── */
.import-errors {
  width: 100%;
  text-align: left;
  font-size: 12px;
  margin-top: 4px;
}
.import-errors summary {
  cursor: pointer;
  color: #facc15;
  font-weight: 600;
  margin-bottom: 6px;
}
.import-errors ul {
  max-height: 100px;
  overflow-y: auto;
  padding-left: 16px;
  margin: 0;
  color: var(--muted);
}
.import-errors li { margin-bottom: 3px; }
