/* ─────────────────────────────────────────────────────────
   DARK CHARTER ADMIN — GLOBAL STYLES (LIGHT MODE)
───────────────────────────────────────────────────────── */

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

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--font); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* ── APP SHELL ──────────────────────────────────────────── */

.app-shell { display: flex; height: 100dvh; overflow: hidden; }

.app-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.app-main { flex: 1; overflow-y: auto; padding: var(--s8); }


/* ── SIDEBAR ────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar__brand {
  padding: var(--s5) var(--s4);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--s3);
}

.sidebar__brand-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  color: var(--accent);
  font-weight: 700;
}

.sidebar__brand-text {}

.sidebar__brand-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.sidebar__brand-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.sidebar__nav {
  flex: 1;
  padding: var(--s3) var(--s2);
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}

.sidebar__section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
  padding: var(--s3) var(--s2) var(--s1);
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 7px var(--s3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  transition: background var(--dur-fast), color var(--dur-fast);
}

.sidebar__link:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.sidebar__link--active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
}

.sidebar__link--active:hover {
  background: var(--accent-dim);
  color: var(--accent-hover);
}

.sidebar__link-icon {
  font-size: 15px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar__badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
}

.sidebar__footer {
  padding: var(--s4);
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}

.sidebar__user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  margin-bottom: var(--s2);
}

.sidebar__user-info { min-width: 0; }

.sidebar__user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__user-role {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar__logout {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  padding: 5px var(--s3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  width: 100%;
  text-align: center;
  transition: all var(--dur-fast);
  font-family: var(--font);
  font-weight: 500;
}

.sidebar__logout:hover {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-dim);
}


/* ── PAGE HEADER ────────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s6);
}

.page-header__left { display: flex; flex-direction: column; gap: 4px; }

.page-header__title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.page-header__subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.page-header__actions { display: flex; gap: var(--s2); align-items: center; }


/* ── STAT CARDS ─────────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--s4);
  margin-bottom: var(--s6);
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--s5) var(--s6);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border);
}

.stat-card--accent::before  { background: var(--accent); }
.stat-card--success::before { background: var(--success); }
.stat-card--warning::before { background: var(--warning); }
.stat-card--danger::before  { background: var(--danger); }

.stat-card__label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--s2);
}

.stat-card__value {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: var(--s1);
}

.stat-card__sub { font-size: var(--text-xs); color: var(--text-muted); }

.stat-card--warning .stat-card__value { color: var(--warning); }
.stat-card--danger  .stat-card__value { color: var(--danger); }
.stat-card--success .stat-card__value { color: var(--success); }
.stat-card--accent  .stat-card__value { color: var(--accent); }


/* ── CARD ───────────────────────────────────────────────── */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.card__title { font-size: var(--text-base); font-weight: 600; color: var(--text-primary); }
.card__subtitle { font-size: var(--text-sm); color: var(--text-muted); margin-top: 2px; }
.card__body { padding: var(--s5); }


/* ── TABLE ──────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }

.table thead tr { border-bottom: 1px solid var(--border); background: var(--bg-elevated); }

.table th {
  text-align: left;
  padding: var(--s3) var(--s4);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

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

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--bg-elevated); }

.table__cell-primary { color: var(--text-primary) !important; font-weight: 500; }
.table__cell-mono    { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-secondary); }
.table__empty        { text-align: center; padding: var(--s12) var(--s4); color: var(--text-muted); font-size: var(--text-sm); }


/* ── BADGES ─────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 100px;
  white-space: nowrap;
  line-height: 1.4;
}

.badge--default  { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); }
.badge--success  { background: var(--success-dim); color: var(--success);        border: 1px solid var(--success-border); }
.badge--danger   { background: var(--danger-dim);  color: var(--danger);         border: 1px solid var(--danger-border); }
.badge--warning  { background: var(--warning-dim); color: var(--warning);        border: 1px solid var(--warning-border); }
.badge--info     { background: var(--info-dim);    color: var(--info);           border: 1px solid var(--info-border); }
.badge--accent   { background: var(--accent-dim);  color: var(--accent);         border: 1px solid var(--accent-border); }

.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }


/* ── BUTTONS ────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  padding: 7px var(--s4);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  font-family: var(--font);
  border: 1px solid transparent;
  line-height: 1.4;
}

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

.btn--primary {
  background: var(--accent);
  color: var(--text-inverted);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}
.btn--primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn--secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}
.btn--secondary:hover:not(:disabled) { background: var(--bg-elevated); border-color: var(--bg-overlay); }

.btn--ghost { color: var(--text-secondary); }
.btn--ghost:hover:not(:disabled) { background: var(--bg-elevated); color: var(--text-primary); }

.btn--danger { background: var(--danger-dim); color: var(--danger); border-color: var(--danger-border); }
.btn--danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn--sm { padding: 4px var(--s3); font-size: var(--text-xs); }
.btn--lg { padding: 10px var(--s5); font-size: var(--text-md); }


/* ── FORMS ──────────────────────────────────────────────── */

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label { font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); }

.form-label-sub { font-size: var(--text-xs); color: var(--text-muted); }

.form-input {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-sm);
  padding: 8px var(--s3);
  outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  width: 100%;
  box-shadow: var(--shadow-xs);
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217,119,6,0.12);
}

.form-input::placeholder { color: var(--text-muted); }

.form-select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-sm);
  padding: 8px var(--s3);
  outline: none;
  width: 100%;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
}

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

.form-textarea {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--text-sm);
  padding: 8px var(--s3);
  outline: none;
  resize: vertical;
  min-height: 80px;
  width: 100%;
  box-shadow: var(--shadow-xs);
}

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

.form-error { font-size: var(--text-xs); color: var(--danger); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }

.form-actions {
  display: flex;
  gap: var(--s2);
  justify-content: flex-end;
  padding-top: var(--s4);
  border-top: 1px solid var(--border);
  margin-top: var(--s4);
}


/* ── AUTH SCREEN ────────────────────────────────────────── */

.auth-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-canvas);
  padding: var(--s4);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.auth-card__header {
  padding: var(--s6);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.auth-card__logo {
  width: 40px;
  height: 40px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  margin: 0 auto var(--s3);
  color: var(--accent);
  font-weight: 700;
}

.auth-card__title { font-size: var(--text-lg); font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.auth-card__subtitle { font-size: var(--text-sm); color: var(--text-muted); }

.auth-card__body { padding: var(--s6); display: flex; flex-direction: column; gap: var(--s4); }

.auth-error {
  background: var(--danger-dim);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  padding: var(--s3) var(--s4);
  font-size: var(--text-sm);
  color: var(--danger);
}


/* ── AUDIT LOG ──────────────────────────────────────────── */

.audit-item {
  display: flex;
  gap: var(--s4);
  padding: 11px var(--s5);
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
  transition: background var(--dur-fast);
}

.audit-item:last-child { border-bottom: none; }
.audit-item:hover { background: var(--bg-elevated); }

.audit-item__time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  padding-top: 2px;
  min-width: 150px;
}

.audit-item__action { flex: 1; min-width: 0; }
.audit-item__label  { font-size: var(--text-sm); font-weight: 500; color: var(--text-primary); margin-bottom: 2px; }
.audit-item__meta   { font-size: var(--text-xs); color: var(--text-muted); }


/* ── EMPTY STATE ────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: var(--s12) var(--s8);
  color: var(--text-muted);
}

.empty-state__title { font-size: var(--text-md); font-weight: 600; color: var(--text-secondary); margin-bottom: var(--s2); }
.empty-state__body  { font-size: var(--text-sm); margin-bottom: var(--s5); }

.empty-state-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--s12);
  text-align: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.empty-state-page__icon {
  font-size: 32px;
  margin-bottom: var(--s4);
  color: var(--text-muted);
}

.empty-state-page__title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--s2);
}

.empty-state-page__body {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 360px;
  line-height: 1.6;
}


/* ── DIVIDER ────────────────────────────────────────────── */

.section-divider { height: 1px; background: var(--border); margin: var(--s6) 0; }


/* ── SCROLLBAR ──────────────────────────────────────────── */

* { scrollbar-width: thin; scrollbar-color: var(--bg-overlay) transparent; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-overlay); border-radius: 3px; }


/* ── UTILITIES ──────────────────────────────────────────── */

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-accent    { color: var(--accent); }
.text-danger    { color: var(--danger); }
.text-success   { color: var(--success); }
.text-warning   { color: var(--warning); }
.font-mono      { font-family: var(--font-mono); font-size: var(--text-xs); }

.flex            { display: flex; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2           { gap: var(--s2); }
.gap-4           { gap: var(--s4); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s6); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s6); }
