/* ============================================================
   Likomotiva Dashboard — Global Stylesheet
   Version: 2.0.0
   ============================================================ */

/* --- Custom properties ------------------------------------ */
:root {
  /* Surface */
  --color-bg:           #f5f5f5;
  --color-surface:      #ffffff;
  --color-surface-alt:  #f0f0f0;
  --color-border:       #e3e3e3;
  --color-border-light: #ebebeb;

  /* Text */
  --color-text:         #0f172a;
  --color-text-muted:   #64748b;
  --color-text-subtle:  #94a3b8;

  /* Brand */
  --color-accent:       #181818;
  --color-accent-light: #ebebeb;
  --color-accent-hover: #111111;
  --color-accent-mid:   #333333;

  /* Status */
  --color-success:        #16a34a;
  --color-success-bg:     #f0fdf4;
  --color-success-border: #bbf7d0;

  --color-warning:        #d97706;
  --color-warning-bg:     #fffbeb;
  --color-warning-border: #fde68a;

  --color-danger:         #dc2626;
  --color-danger-bg:      #fef2f2;
  --color-danger-border:  #fecaca;

  --color-info:           #0284c7;
  --color-info-bg:        #f0f9ff;
  --color-info-border:    #bae6fd;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', Consolas, monospace;

  /* Radius */
  --radius-sm:   4px;
  --radius:      8px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-full: 9999px;

  /* Shadows — refined hierarchy */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 8px -2px rgba(0,0,0,.08), 0 2px 4px -1px rgba(0,0,0,.04);
  --shadow-md: 0 8px 16px -4px rgba(0,0,0,.09), 0 4px 8px -2px rgba(0,0,0,.04);
  --shadow-lg: 0 20px 32px -8px rgba(0,0,0,.10), 0 8px 16px -4px rgba(0,0,0,.05);

  /* Spacing */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Layout */
  --sidebar-width:     280px;
  --topbar-height:     60px;
  --content-max-width: 1200px;

  /* Transitions */
  --transition:    150ms ease;
  --transition-md: 250ms cubic-bezier(.4, 0, .2, 1);
}

/* --- Dark theme ------------------------------------------- */
[data-theme="dark"] {
  --color-bg:             #07090e;
  --color-surface:        #0c0f17;
  --color-surface-alt:    #111520;
  --color-border:         #1f2336;
  --color-border-light:   #181c2b;
  --color-text:           #f1f5f9;
  --color-text-muted:     #94a3b8;
  --color-text-subtle:    #64748b;
  --color-accent:         #e2e8f0;
  --color-accent-light:   #1e2535;
  --color-accent-hover:   #f8fafc;
  --color-accent-mid:     #cbd5e1;
  --color-success-bg:     #052e16;
  --color-success-border: #166534;
  --color-warning-bg:     #1c1500;
  --color-warning-border: #78350f;
  --color-danger-bg:      #1c0505;
  --color-danger-border:  #7f1d1d;
  --color-info-bg:        #0c1929;
  --color-info-border:    #1e3a5f;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.30);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.40), 0 1px 2px rgba(0,0,0,.30);
  --shadow:    0 4px 8px -2px rgba(0,0,0,.50), 0 2px 4px -1px rgba(0,0,0,.30);
  --shadow-md: 0 8px 16px -4px rgba(0,0,0,.50), 0 4px 8px -2px rgba(0,0,0,.30);
  --shadow-lg: 0 20px 32px -8px rgba(0,0,0,.60), 0 8px 16px -4px rgba(0,0,0,.40);
}

html[data-theme="dark"] {
  scrollbar-color: #2e3347 transparent;
}
html[data-theme="dark"]::-webkit-scrollbar-thumb { background: #2e3347; }
html[data-theme="dark"]::-webkit-scrollbar-thumb:hover { background: #3d4562; }

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  tab-size: 2;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #d4d4d4 transparent;
}
html::-webkit-scrollbar { width: 4px; }
html::-webkit-scrollbar-track { background: transparent; }
html::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 99px; }
html::-webkit-scrollbar-thumb:hover { background: #b0b0b0; }

body {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

button { cursor: pointer; font-family: inherit; }

input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

ul, ol { list-style: none; }

/* --- Typography ------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
  letter-spacing: -0.015em;
}

h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.0625rem; }
h5 { font-size: 0.9375rem; }
h6 { font-size: 0.875rem; }

p {
  color: var(--color-text-muted);
  line-height: 1.7;
}

small { font-size: 0.8125rem; }

strong {
  font-weight: 600;
  color: var(--color-text);
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-surface-alt);
  padding: 0.1em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-light);
}

/* --- Layout containers ------------------------------------ */
.container {
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

.page-wrapper {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: var(--sp-8) var(--sp-6);
  margin-left: var(--sidebar-width);
}

/* --- Cards ------------------------------------------------ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
}

.card-sm { padding: var(--sp-4); }
.card-grey,
.form-card.form-card-grey { background: var(--color-surface-alt); }
.card-lg { padding: var(--sp-8); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--color-border-light);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Interactive card — add to any clickable card */
.card-interactive {
  transition: border-color var(--transition), box-shadow var(--transition-md),
              transform var(--transition-md);
}
.card-interactive:hover {
  border-color: #c7d4e8;
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

/* --- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 9px var(--sp-5);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background var(--transition), color var(--transition),
              border-color var(--transition), box-shadow var(--transition),
              transform var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.5;
  cursor: pointer;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  pointer-events: none;
}

.btn-sm {
  padding: 6px var(--sp-3);
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 12px var(--sp-6);
  font-size: 1rem;
}

.btn-block { width: 100%; }

/* Primary */
.btn-primary {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
  box-shadow: 0 1px 3px rgba(24, 24, 24, .25);
}
.btn-primary:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
  color: #fff;
  box-shadow: 0 3px 10px rgba(24, 24, 24, .28);
}

/* Secondary */
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--color-surface-alt);
  border-color: #c8cdd8;
}

/* Danger */
.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
  box-shadow: 0 1px 3px rgba(220, 38, 38, .25);
}
.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
  box-shadow: 0 3px 10px rgba(220, 38, 38, .28);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
}

/* --- Forms ------------------------------------------------ */
.form-group { margin-bottom: var(--sp-5); }

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--sp-2);
}

.form-label .required {
  color: var(--color-danger);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  font-size: 0.9375rem;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  appearance: none;
}

.form-control::placeholder { color: var(--color-text-subtle); }

.form-control:hover:not(:disabled):not(:focus) {
  border-color: #c8cdd8;
}

.form-control:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, .1);
}

.form-control:disabled {
  background: var(--color-surface-alt);
  cursor: not-allowed;
  opacity: 0.65;
}

.form-control.is-invalid {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .08);
}

.form-control.is-valid {
  border-color: var(--color-success);
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

select.form-control {
  /* kept in DOM for form submission — visually replaced by .csel */
  background-image: none;
  padding-right: 13px;
}

/* ── Custom select ─────────────────────────────────────────────── */
.csel {
  position: relative;
  display: inline-block;
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
}

.csel--sm { font-size: 0.8125rem; }

.csel__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 9px 13px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: inherit;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.csel--sm .csel__trigger {
  padding: 6px 10px;
}

.csel__trigger:hover {
  border-color: #b0b8c8;
  box-shadow: var(--shadow-sm);
}

.csel__trigger:focus-visible {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(30,58,95,.1);
}

.csel--open .csel__trigger {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(30,58,95,.1);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.csel__label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text);
}

.csel__label--placeholder {
  color: var(--color-text-subtle);
  font-weight: 400;
}

.csel__chevron {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--color-text-muted);
  transition: transform 200ms ease;
}

.csel--open .csel__chevron {
  transform: rotate(180deg);
}

.csel__dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--color-surface);
  border: 1px solid var(--color-accent);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
  display: none;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.csel--open .csel__dropdown {
  display: block;
}

.csel__option {
  display: flex;
  align-items: center;
  padding: 9px 13px;
  font-size: inherit;
  color: var(--color-text);
  cursor: pointer;
  transition: background var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.csel--sm .csel__option {
  padding: 7px 10px;
}

.csel__option:hover {
  background: var(--color-bg);
}

.csel__option--selected {
  background: var(--color-accent-light);
  font-weight: 600;
  color: var(--color-accent);
}

.csel__option--disabled {
  color: var(--color-text-subtle);
  cursor: default;
  font-style: italic;
}

.csel__option--disabled:hover {
  background: transparent;
}

.form-control-sm {
  padding: 6px 10px;
  font-size: 0.8125rem;
}


.form-hint {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-top: var(--sp-1);
  line-height: 1.5;
}

.form-error {
  font-size: 0.8125rem;
  color: var(--color-danger);
  margin-top: var(--sp-1);
}

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

/* --- Alerts ----------------------------------------------- */
.alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  font-size: 0.875rem;
  border: 1px solid transparent;
  border-left: 4px solid transparent;
  line-height: 1.55;
  margin-bottom: var(--sp-5);
}

.alert ul {
  padding-left: var(--sp-4);
  margin-top: var(--sp-1);
}

.alert-success {
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
  border-left-color: var(--color-success);
  color: #166534;
}

.alert-warning {
  background: var(--color-warning-bg);
  border-color: var(--color-warning-border);
  border-left-color: var(--color-warning);
  color: #92400e;
}

.alert-danger, .alert-error {
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
  border-left-color: var(--color-danger);
  color: #991b1b;
}

.alert-info {
  background: var(--color-info-bg);
  border-color: var(--color-info-border);
  border-left-color: var(--color-info);
  color: #075985;
}

/* --- Badges ----------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
  border: 1px solid transparent;
  letter-spacing: 0.01em;
  line-height: 1.4;
}

.badge-success {
  background: var(--color-success-bg);
  color: #166534;
  border-color: var(--color-success-border);
}
.badge-warning {
  background: var(--color-warning-bg);
  color: #92400e;
  border-color: var(--color-warning-border);
}
.badge-danger {
  background: var(--color-danger-bg);
  color: #991b1b;
  border-color: var(--color-danger-border);
}
.badge-info {
  background: var(--color-info-bg);
  color: #075985;
  border-color: var(--color-info-border);
}
.badge-neutral {
  background: var(--color-surface-alt);
  color: var(--color-text-muted);
  border-color: var(--color-border);
}
.badge-accent {
  background: var(--color-accent-light);
  color: var(--color-accent);
  border-color: #c5d3e8;
}

/* --- Progress bars ---------------------------------------- */
.progress-wrap { width: 100%; }

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-2);
}

.progress-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
}

.progress-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--color-border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-sm { height: 4px; }
.progress-bar-lg { height: 10px; }

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-accent), var(--color-accent-mid));
  border-radius: var(--radius-full);
  transition: width 0.7s cubic-bezier(.4, 0, .2, 1);
}

.progress-fill-success { background: linear-gradient(90deg, #16a34a, #22c55e); }
.progress-fill-warning { background: linear-gradient(90deg, #d97706, #f59e0b); }
.progress-fill-danger  { background: linear-gradient(90deg, #dc2626, #ef4444); }

/* --- Tables ----------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table th {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-subtle);
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text);
  vertical-align: middle;
}

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

.table tbody tr {
  transition: background var(--transition);
}
.table tbody tr:hover { background: var(--color-surface-alt); }

/* --- Page header ------------------------------------------ */
.page-header { margin-bottom: var(--sp-8); }

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 0.9375rem;
  color: var(--color-text-muted);
  margin-top: var(--sp-1);
}

/* --- Divider ---------------------------------------------- */
.divider {
  height: 1px;
  background: var(--color-border-light);
  border: none;
  margin: var(--sp-6) 0;
}

/* --- Empty state ------------------------------------------ */
.empty-state {
  text-align: center;
  padding: var(--sp-12) var(--sp-6);
}

.empty-state-icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--sp-5);
  color: var(--color-text-subtle);
}

/* Legacy emoji-style icon */
.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: var(--sp-4);
  opacity: 0.35;
}

.empty-state-title {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--sp-2);
}

.empty-state-text {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  max-width: 380px;
  margin: 0 auto var(--sp-5);
  line-height: 1.65;
}

/* --- Stats grid ------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-8);
}

.stat-card {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  padding: var(--sp-5) var(--sp-6);
}

.stat-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: var(--sp-2);
}

.stat-value {
  font-size: 1.875rem;
  font-weight: 500;
  color: var(--color-text);
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-suffix {
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-left: 3px;
}

/* --- Utility classes -------------------------------------- */
.text-muted   { color: var(--color-text-muted); }
.text-subtle  { color: var(--color-text-subtle); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger  { color: var(--color-danger); }
.text-info    { color: var(--color-info); }
.text-accent  { color: var(--color-accent); }

.text-sm  { font-size: 0.875rem; }
.text-xs  { font-size: 0.8125rem; }
.text-lg  { font-size: 1.0625rem; }

.font-medium   { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

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

.flex            { display: flex; }
.flex-col        { display: flex; flex-direction: column; }
.items-center    { align-items: center; }
.items-start     { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.gap-2  { gap: var(--sp-2); }
.gap-3  { gap: var(--sp-3); }
.gap-4  { gap: var(--sp-4); }

.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }

.w-full  { width: 100%; }
.hidden  { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* --- Responsive ------------------------------------------- */
@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; }
  .main-content { margin-left: 0; padding: var(--sp-4); }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   Admin layout — sidebar + topbar + content area
============================================================ */
.admin-wrap {
  display: flex;
  min-height: 100vh;
}

/* ----- Sidebar -------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: #f0f0f0;
  border-right: 1px solid var(--color-border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh; /* dynamic viewport — shrinks when mobile browser chrome is visible */
  overflow-y: hidden; /* sidebar itself must not scroll; .sidebar-nav handles its own scroll */
  z-index: 200;
  transition: transform var(--transition-md);
}

.sidebar-hd {
  padding: 65px 20px 16px 26px;
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-brand-box {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -.02em;
  width: 100%;
}

.sidebar-brand-sub {
  font-size: .6875rem;
  font-weight: 400;
  color: var(--color-text);
  line-height: 1.4;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: 10px 16px 10px 26px;
  overflow-y: auto;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #d4d4d4 transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #d4d4d4; border-radius: 99px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: #b0b0b0; }

.nav-label {
  display: block;
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--color-text-subtle);
  padding: 12px 10px 5px;
  user-select: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius);
  font-size: .9375rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 4px;
}

.nav-link:hover {
  background: var(--color-bg);
  color: var(--color-text);
  text-decoration: none;
}

.nav-link.is-active {
  background: #ffffff;
  color: var(--color-accent);
  font-weight: 600;
}

.nav-link svg {
  flex-shrink: 0;
  opacity: .6;
  transition: opacity var(--transition);
}
.nav-link.is-active svg,
.nav-link:hover svg { opacity: 1; }

/* Sidebar notification pip */
.nav-pip {
  margin-left: auto;
  background: var(--color-danger);
  color: #fff;
  border-radius: var(--radius-full);
  min-width: 18px;
  height: 18px;
  font-size: .625rem;
  font-weight: 700;
  line-height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex-shrink: 0;
}

.nav-group-toggle .nav-pip { margin-left: 4px; }

/* Collapsible nav group */
.nav-group { margin-bottom: 4px; }

.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius);
  font-size: .9375rem;
  font-weight: 500;
  color: var(--color-text-muted);
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}

.nav-group-toggle:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.nav-group-toggle[aria-expanded="true"] { color: var(--color-text); }

.nav-group-toggle svg:first-child {
  flex-shrink: 0;
  opacity: .6;
  transition: opacity var(--transition);
}
.nav-group-toggle:hover svg:first-child,
.nav-group-toggle[aria-expanded="true"] svg:first-child { opacity: 1; }

.nav-group-chevron {
  margin-left: auto;
  flex-shrink: 0;
  opacity: .4;
  transition: transform var(--transition-md), opacity var(--transition);
}
.nav-group-toggle[aria-expanded="true"] .nav-group-chevron {
  transform: rotate(180deg);
  opacity: .7;
}

.nav-group-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--transition-md);
}
.nav-group-body.is-open { grid-template-rows: 1fr; }
.nav-group-body > div { overflow: hidden; padding-top: 4px; }

.nav-link-sub {
  padding-left: 34px;
  font-size: .8125rem;
}

.sidebar-ft {
  padding: 10px 20px 90px 26px;
  padding-bottom: max(90px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-border-light);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  margin-bottom: 2px;
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-accent-light);
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .6875rem;
  font-weight: 700;
  flex-shrink: 0;
  border: 1px solid #c5d3e8;
}

.sidebar-user-name {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: .6875rem;
  color: var(--color-text-subtle);
  margin-top: 1px;
}

/* Sidebar mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .4);
  z-index: 160;
  cursor: pointer;
  backdrop-filter: blur(2px);
}

/* ----- Main area ------------------------------------------ */
.admin-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ----- Topbar --------------------------------------------- */
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-6);
  gap: var(--sp-4);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

.topbar-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 7px;
  color: var(--color-text-muted);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.topbar-menu-btn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.topbar-title {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--color-text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ----- Content -------------------------------------------- */
.admin-content {
  flex: 1;
  padding: 65px 45px 32px;
  background: #ffffff;
}

/* Page heading row */
.page-hdr {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}

.page-hdr-title {
  font-size: 1.625rem;
  font-weight: 700;
  color: #334155;
  letter-spacing: -.03em;
  line-height: 1.2;
}

/* Filter/search bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}

.filter-bar .form-control {
  flex: 1;
  min-width: 160px;
  max-width: 300px;
}

.filter-bar select.form-control {
  flex: 0 0 auto;
  width: auto;
  min-width: 150px;
}

/* Form card sections */
.form-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  margin-bottom: var(--sp-4);
  box-shadow: var(--shadow-xs);
}

.form-card-title {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--color-border-light);
  letter-spacing: -.01em;
}

/* Code display chip */
.code-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px 10px;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: .8125rem;
  font-weight: 600;
  color: var(--color-accent);
  letter-spacing: .06em;
}

/* Two-column admin layout (form + aside) */
.admin-form-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--sp-4);
  align-items: start;
}

/* ----- Responsive ----------------------------------------- */
/* Mobile top bar */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  background: #f0f0f0;
  border-bottom: 1px solid var(--color-border-light);
  z-index: 150;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.mobile-topbar-brand {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--color-text);
}

.mobile-ham {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
}
.mobile-ham:hover { background: var(--color-bg); color: var(--color-text); }

/* Close button inside sidebar (mobile only) */
.sidebar-close {
  display: none;
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
  z-index: 1;
}
.sidebar-close:hover { background: var(--color-bg); color: var(--color-text); }

@media (max-width: 960px) {
  .mobile-topbar { display: flex; }
  .sidebar {
    left: auto;
    right: 0;
    transform: translateX(100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-overlay.is-active { display: block; }
  .admin-main { margin-left: 0; min-width: 0; overflow-x: hidden; }
  .admin-content { padding-top: calc(64px + 30px); }
  .sidebar-hd { position: relative; }
  .sidebar-close { display: flex; }
}

@media (max-width: 768px) {
  .admin-form-layout { grid-template-columns: 1fr; }
  .admin-content { padding: calc(64px + 30px) var(--sp-4) var(--sp-4); }
}

@media (max-width: 640px) {
  .filter-bar .form-control { max-width: none; }
  .filter-bar select.form-control { min-width: 0; flex: 1; }

  /* Projects table — hide low-priority columns (Tip, Uplata, Rok/Kreirano) */
  .table-projects th:nth-child(3),
  .table-projects td:nth-child(3),
  .table-projects th:nth-child(5),
  .table-projects td:nth-child(5),
  .table-projects th:nth-child(6),
  .table-projects td:nth-child(6) { display: none; }
}

/* ============================================================
   Admin dark mode overrides
   All CSS-variable-based rules adapt automatically.
   Only hardcoded values need explicit overrides here.
============================================================ */
/* Primary button — accent is light in dark mode so flip text color */
[data-theme="dark"] .btn-primary          { background: #2a3042; color: #f1f5f9; border-color: #3d4562; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
[data-theme="dark"] .btn-primary:hover    { background: #323a52; border-color: #4d5575; color: #fff; }
/* Secondary button */
[data-theme="dark"] .btn-secondary        { background: var(--color-surface-alt); border-color: var(--color-border); }
[data-theme="dark"] .btn-secondary:hover  { background: var(--color-border); border-color: var(--color-border); }
/* Ghost button */
[data-theme="dark"] .btn-ghost:hover      { background: var(--color-surface-alt); }

/* Alert text colors — hardcoded dark values unreadable on dark backgrounds */
[data-theme="dark"] .alert-success        { color: #86efac; }
[data-theme="dark"] .alert-warning        { color: #fbbf24; }
[data-theme="dark"] .alert-danger,
[data-theme="dark"] .alert-error          { color: #fca5a5; }
[data-theme="dark"] .alert-info           { color: #7dd3fc; }

/* Badge dark mode — dark bg, vivid colored border + text */
[data-theme="dark"] .badge-success { background: #052e16; color: #4ade80; border-color: #22c55e; }
[data-theme="dark"] .badge-warning { background: #2c1000; color: #fb923c; border-color: #f97316; }
[data-theme="dark"] .badge-danger  { background: #2d0808; color: #f87171; border-color: #ef4444; }
[data-theme="dark"] .badge-info    { background: #08152e; color: #60a5fa; border-color: #3b82f6; }
[data-theme="dark"] .badge-accent  { background: #17104a; color: #a5b4fc; border-color: #6366f1; }
[data-theme="dark"] .badge-neutral { background: var(--color-surface-alt); color: var(--color-text-muted); border-color: var(--color-border); }

[data-theme="dark"] .sidebar              { background: var(--color-surface); }
[data-theme="dark"] .sidebar-brand-box    { background: var(--color-surface-alt); }
[data-theme="dark"] .nav-link:hover       { background: var(--color-surface-alt); }
[data-theme="dark"] .nav-link.is-active   { background: var(--color-surface-alt); color: var(--color-accent); }
[data-theme="dark"] .nav-group-toggle:hover { background: var(--color-surface-alt); }
[data-theme="dark"] .sidebar-avatar       { border-color: var(--color-border); }
[data-theme="dark"] .admin-content        { background: var(--color-surface); }
[data-theme="dark"] .page-hdr-title       { color: var(--color-text); }
[data-theme="dark"] .mobile-topbar        { background: var(--color-surface); }
[data-theme="dark"] .card-interactive:hover { border-color: var(--color-border); }
[data-theme="dark"] .topbar               { box-shadow: 0 1px 4px rgba(0,0,0,.25); }
[data-theme="dark"] .sidebar-nav          { scrollbar-color: var(--color-border) transparent; }
[data-theme="dark"] .sidebar-nav::-webkit-scrollbar-thumb { background: var(--color-border); }
