:root {
  --yellow: #fdb913;
  --yellow-600: #e2a200;
  --yellow-100: #fff6dc;
  --ink: #16171a;
  --ink-2: #212328;
  --ink-3: #2c2f36;
  --concrete: #f3f2ef;
  --concrete-2: #e4e1da;
  --steel: #666c78;
  --text: #22252b;
  --white: #ffffff;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #15803d;
  --success-bg: #f0fdf4;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 10px 28px -14px rgba(22, 23, 26, 0.22);
  --font-display: "Archivo Black", "Arial Black", sans-serif;
  --font-cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--concrete);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; color: var(--ink); line-height: 1.15; }
p { margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  background: rgba(22, 23, 26, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.65rem 1.2rem; border-radius: 10px; border: 1.5px solid transparent;
  font-weight: 600; font-size: 0.9rem; cursor: pointer; text-decoration: none;
  transition: transform 0.15s ease, background 0.2s, border-color 0.2s, color 0.2s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn--sm { padding: 0.48rem 0.9rem; font-size: 0.84rem; }
.btn--block { width: 100%; }
.btn--primary { background: var(--yellow); color: var(--ink); }
.btn--primary:hover:not(:disabled) { background: #ffc838; }
.btn--dark { background: var(--ink); color: var(--white); }
.btn--dark:hover:not(:disabled) { background: var(--ink-3); }
.btn--outline { background: var(--white); color: var(--ink); border-color: var(--concrete-2); }
.btn--outline:hover:not(:disabled) { border-color: var(--ink); }
.btn--ghost { background: rgba(255, 255, 255, 0.08); color: var(--white); border-color: rgba(255, 255, 255, 0.2); }
.btn--ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); }
.btn--danger { background: var(--danger); color: var(--white); }
.btn--danger:hover:not(:disabled) { background: #b91c1c; }
.btn--danger-outline { background: transparent; color: #fca5a5; border-color: rgba(252, 165, 165, 0.35); }
.btn--danger-outline:hover:not(:disabled) { background: rgba(220, 38, 38, 0.18); color: var(--white); }

.icon-btn {
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--concrete-2);
  background: var(--white); color: var(--ink); font-size: 1.2rem; cursor: pointer;
  display: inline-grid; place-items: center;
}
.link-btn {
  border: 0; background: none; color: var(--yellow-600); font-weight: 600;
  cursor: pointer; padding: 0.25rem 0; font-size: 0.88rem; text-decoration: underline;
}

/* ---------- Boot & Auth ---------- */
.boot {
  min-height: 100vh; display: grid; place-items: center; background: var(--ink); color: var(--white);
}
.boot__card { display: grid; place-items: center; gap: 1rem; text-align: center; opacity: 0.9; }

.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at top right, rgba(253, 185, 19, 0.14), transparent 45%), var(--ink);
}
.auth__card {
  width: min(440px, 100%); background: var(--white); border-radius: var(--radius-lg);
  padding: 2rem; box-shadow: 0 28px 60px -20px rgba(0, 0, 0, 0.55);
}
.auth__brand { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.4rem; }
.auth__brand strong { display: block; font-family: var(--font-display); font-size: 1.05rem; font-weight: 400; color: var(--ink); }
.auth__brand small { display: block; font-family: var(--font-cond); letter-spacing: 0.16em; text-transform: uppercase; color: var(--yellow-600); font-weight: 700; font-size: 0.78rem; }
.auth__card h1 { font-family: var(--font-display); font-weight: 400; font-size: 1.55rem; margin-bottom: 0.45rem; }
.auth__sub { color: var(--steel); font-size: 0.92rem; margin-bottom: 1.4rem; }
.auth__links { display: grid; gap: 0.35rem; justify-items: center; text-align: center; }
.auth__footer {
  margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--concrete-2);
  display: flex; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
  font-size: 0.82rem; color: var(--steel);
}
.auth__footer a { color: var(--ink); font-weight: 600; text-decoration: none; }

.stack { display: grid; gap: 1rem; }
.field { display: grid; gap: 0.35rem; font-size: 0.86rem; font-weight: 600; color: var(--ink); }
.field input, .field select, .input-sm, .select-sm, .inline-form input {
  width: 100%; padding: 0.68rem 0.85rem; border: 1.5px solid var(--concrete-2); border-radius: 10px;
  background: var(--white); color: var(--ink); font-weight: 500;
}
.field input:focus, .field select:focus, .input-sm:focus, .select-sm:focus, .inline-form input:focus {
  outline: none; border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(253, 185, 19, 0.22);
}
.input-sm, .select-sm { padding: 0.48rem 0.75rem; font-size: 0.86rem; width: auto; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 4.2rem; }
.pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: 0; background: var(--concrete); color: var(--ink); border-radius: 7px;
  padding: 0.3rem 0.55rem; font-size: 0.78rem; font-weight: 600; cursor: pointer;
}

.alert {
  padding: 0.72rem 0.9rem; border-radius: 10px; font-size: 0.88rem; font-weight: 500;
  background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca;
}
.alert--success { background: var(--success-bg); color: var(--success); border-color: #bbf7d0; }

/* ---------- Layout ---------- */
.app { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }

.sidebar {
  background: var(--ink); color: var(--white); display: flex; flex-direction: column;
  padding: 1.2rem; position: sticky; top: 0; height: 100vh; z-index: 40;
}
.sidebar__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.6rem; }
.sidebar__close { display: none; background: var(--ink-2); color: var(--white); border-color: var(--ink-3); }
.brand-lockup { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; }
.brand-lockup strong { display: block; font-family: var(--font-display); font-weight: 400; font-size: 1rem; color: var(--white); }
.brand-lockup small { display: block; font-size: 0.74rem; color: var(--yellow); font-weight: 600; }

.side-nav { display: grid; gap: 0.4rem; }
.side-nav__item {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 0.9rem; border-radius: 10px;
  border: 0; background: transparent; color: rgba(255, 255, 255, 0.74);
  font-weight: 600; font-size: 0.92rem; cursor: pointer; text-align: left;
  transition: background 0.18s, color 0.18s;
}
.side-nav__item svg { width: 19px; height: 19px; fill: currentColor; flex: none; }
.side-nav__item:hover { background: rgba(255, 255, 255, 0.08); color: var(--white); }
.side-nav__item.is-active { background: var(--yellow); color: var(--ink); }

.badge {
  margin-left: auto; background: rgba(255, 255, 255, 0.14); color: inherit;
  border-radius: 999px; padding: 0.1rem 0.5rem; font-size: 0.75rem; font-weight: 700;
}
.side-nav__item.is-active .badge { background: rgba(22, 23, 26, 0.15); }
.badge--accent { background: rgba(253, 185, 19, 0.22); color: var(--yellow); }

.sidebar__foot { margin-top: auto; display: grid; gap: 0.6rem; padding-top: 1rem; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.conn-pill { display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; color: rgba(255, 255, 255, 0.68); margin-bottom: 0.2rem; }
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25); }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--white); border-bottom: 1px solid var(--concrete-2);
  padding: 0.9rem 1.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  position: sticky; top: 0; z-index: 20;
}
.topbar__left { display: flex; align-items: center; gap: 0.9rem; min-width: 0; }
.topbar__menu { display: none; }
.topbar__title { font-family: var(--font-cond); text-transform: uppercase; letter-spacing: 0.03em; font-size: 1.5rem; font-weight: 700; }
.topbar__sub { font-size: 0.82rem; color: var(--steel); }
.topbar__right { display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; }
.user-chip {
  background: var(--concrete); border: 1px solid var(--concrete-2); border-radius: 999px;
  padding: 0.35rem 0.75rem; font-size: 0.8rem; font-weight: 600; color: var(--ink);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.content { padding: 1.5rem; display: grid; gap: 1.25rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  background: var(--ink); color: var(--white); padding: 0.8rem 1.15rem; border-radius: 12px;
  border-left: 4px solid var(--yellow); box-shadow: var(--shadow); font-weight: 500; font-size: 0.9rem;
}
.toast--error { border-left-color: var(--danger); }

/* ---------- KPI & Panels ---------- */
.tab-panel { display: grid; gap: 1.25rem; }
.kpi-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1rem; }
.kpi-card {
  background: var(--white); border: 1px solid var(--concrete-2); border-radius: var(--radius);
  padding: 1rem 1.1rem; display: grid; gap: 0.25rem; box-shadow: 0 4px 14px -10px rgba(22, 23, 26, 0.16);
}
.kpi-card__label { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--steel); }
.kpi-card__value { font-family: var(--font-display); font-size: 1.85rem; color: var(--ink); line-height: 1.1; }
.kpi-card__meta { font-size: 0.8rem; color: var(--steel); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.panel-grid { display: grid; gap: 1.2rem; }
.panel-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel {
  background: var(--white); border: 1px solid var(--concrete-2); border-radius: var(--radius-lg);
  padding: 1.25rem; display: grid; gap: 1rem; align-content: start;
}
.panel--wide { grid-column: 1 / -1; }
.panel__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.panel__head h2 { font-family: var(--font-cond); font-size: 1.3rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.panel__head p { font-size: 0.84rem; color: var(--steel); margin-top: 0.15rem; }

.chart-wrap { position: relative; min-height: 200px; }
.chart-wrap--sm { min-height: 190px; }
.chart-empty {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  padding: 1rem; color: var(--steel); font-size: 0.9rem; background: rgba(243, 242, 239, 0.65); border-radius: 12px;
}

.sub-heading { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--steel); margin-top: 0.4rem; }
.mini-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.55rem; }
.mini-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  padding: 0.5rem 0.7rem; background: var(--concrete); border-radius: 9px; font-size: 0.86rem;
}
.mini-list li strong { color: var(--ink); }

.device-bars { display: grid; gap: 0.65rem; }
.device-bar { display: grid; gap: 0.25rem; font-size: 0.84rem; }
.device-bar__top { display: flex; justify-content: space-between; font-weight: 600; }
.device-bar__track { height: 8px; background: var(--concrete); border-radius: 999px; overflow: hidden; }
.device-bar__fill { height: 100%; background: var(--yellow); border-radius: 999px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.data-table th, .data-table td { text-align: left; padding: 0.72rem 0.75rem; border-bottom: 1px solid var(--concrete-2); vertical-align: top; }
.data-table th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--steel); font-weight: 700; }
.pill {
  display: inline-flex; align-items: center; padding: 0.2rem 0.55rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 700; background: var(--concrete); color: var(--ink);
}
.pill--amber { background: var(--yellow-100); color: #926000; }
.pill--green { background: var(--success-bg); color: var(--success); }
.pill--dark { background: var(--ink); color: var(--white); }

/* ---------- Gallery Manager ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.toolbar__filters, .toolbar__actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.pill-btn {
  border: 1.5px solid var(--concrete-2); background: var(--white); color: var(--ink);
  border-radius: 999px; padding: 0.42rem 0.9rem; font-size: 0.84rem; font-weight: 600; cursor: pointer;
}
.pill-btn.is-active { background: var(--ink); color: var(--white); border-color: var(--ink); }

.info-banner {
  background: var(--yellow-100); border: 1.5px solid var(--yellow); border-radius: var(--radius);
  padding: 1rem 1.2rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.info-banner p { font-size: 0.86rem; color: #5b4506; margin-top: 0.2rem; }

.gallery-stats-bar {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
  font-size: 0.84rem; color: var(--steel); font-weight: 600;
}

.admin-gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.1rem; }
.gal-card {
  background: var(--white); border: 1px solid var(--concrete-2); border-radius: var(--radius-lg);
  overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 6px 18px -12px rgba(22, 23, 26, 0.2);
}
.gal-card__media { position: relative; aspect-ratio: 16 / 10; background: var(--ink); overflow: hidden; }
.gal-card__media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-card__badges {
  position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; gap: 0.4rem;
}
.gal-card__body { padding: 1rem; display: grid; gap: 0.4rem; flex: 1; }
.gal-card__body h3 { font-family: var(--font-cond); font-size: 1.2rem; text-transform: uppercase; }
.gal-card__body p { font-size: 0.84rem; color: var(--steel); }
.gal-card__meta { font-size: 0.78rem; color: var(--steel); display: flex; gap: 0.7rem; flex-wrap: wrap; margin-top: auto; padding-top: 0.35rem; }
.gal-card__actions {
  padding: 0.75rem 1rem; border-top: 1px solid var(--concrete-2); background: #faf9f7;
  display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center;
}
.btn-xs {
  padding: 0.34rem 0.62rem; font-size: 0.78rem; border-radius: 8px;
  border: 1px solid var(--concrete-2); background: var(--white); color: var(--ink); font-weight: 600; cursor: pointer;
}
.btn-xs:hover { border-color: var(--ink); }
.btn-xs--danger { color: var(--danger); border-color: #fecaca; margin-left: auto; }
.btn-xs--danger:hover { background: var(--danger-bg); border-color: var(--danger); }

/* ---------- Settings & Forms ---------- */
.setup-steps { margin: 0; padding-left: 1.25rem; display: grid; gap: 0.85rem; font-size: 0.9rem; }
.dns-box {
  margin-top: 0.5rem; padding: 0.75rem; border-radius: 10px; background: var(--concrete);
  display: grid; gap: 0.4rem; font-size: 0.83rem;
}
.inline-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0.5rem; }
.hint { font-size: 0.8rem; color: var(--steel); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 80; background: rgba(16, 17, 19, 0.72);
  backdrop-filter: blur(4px); display: grid; place-items: center; padding: 20px; overflow-y: auto;
}
.modal__dialog {
  width: min(580px, 100%); background: var(--white); border-radius: var(--radius-lg);
  padding: 1.5rem; box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.5);
  display: grid; gap: 1rem;
}
.modal__dialog--sm { width: min(420px, 100%); }
.modal__head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.modal__head h2 { font-family: var(--font-cond); font-size: 1.4rem; text-transform: uppercase; }
.modal__foot { display: flex; justify-content: flex-end; gap: 0.65rem; padding-top: 0.4rem; }

.mode-tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.dropzone {
  border: 2px dashed var(--concrete-2); border-radius: var(--radius); padding: 1.4rem 1rem;
  text-align: center; cursor: pointer; display: grid; gap: 0.25rem; background: #faf9f7;
  transition: border-color 0.2s, background 0.2s;
}
.dropzone:hover, .dropzone.is-drag { border-color: var(--yellow); background: var(--yellow-100); }
.dropzone span { font-size: 0.82rem; color: var(--steel); }
.compression-info { font-size: 0.82rem; font-weight: 600; color: var(--success); margin-top: 0.45rem; }

.preview-box {
  position: relative; border-radius: var(--radius); overflow: hidden; height: 180px; background: var(--ink);
}
.preview-box img { width: 100%; height: 100%; object-fit: cover; }
.preview-box::after {
  content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgba(16, 17, 19, 0.78), transparent 55%);
}
.preview-cap {
  position: absolute; left: 1rem; bottom: 0.85rem; z-index: 1; color: var(--white);
  font-family: var(--font-cond); font-size: 1.15rem; font-weight: 700; text-transform: uppercase;
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; }
.check-field { display: flex; align-items: center; gap: 0.55rem; font-size: 0.88rem; font-weight: 600; cursor: pointer; }
.check-field input { width: 18px; height: 18px; accent-color: var(--yellow); }
.confirm-msg { color: var(--steel); font-size: 0.94rem; }

.status-select {
  padding: 0.35rem 0.55rem; border-radius: 8px; border: 1.5px solid var(--concrete-2);
  font-size: 0.82rem; font-weight: 600; background: var(--white);
}
.empty-state {
  grid-column: 1 / -1; background: var(--white); border: 1px dashed var(--concrete-2);
  border-radius: var(--radius-lg); padding: 2.5rem 1.5rem; text-align: center; color: var(--steel);
}

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 268px; transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .sidebar.is-open { transform: none; }
  .sidebar__close, .topbar__menu { display: inline-grid; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 35; }
  .panel-grid--2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid-2, .inline-form { grid-template-columns: 1fr; }
  .topbar { padding: 0.8rem 1rem; }
  .content { padding: 1rem; }
}
