/* ── TOKENS ─────────────────────────────────────────── */
:root {
  --bg:        #0f1923;
  --bg-2:      #162130;
  --bg-3:      #1d2e40;
  --border:    #263750;
  --teal:      #00b4a6;
  --teal-dim:  #007d73;
  --teal-glow: rgba(0,180,166,.15);
  --gold:      #f4c34d;
  --danger:    #e05252;
  --text:      #e8edf2;
  --text-2:    #8fa4b8;
  --text-3:    #4d6478;
  --radius:    10px;
  --radius-lg: 16px;
  --sidebar-w: 240px;
  --topbar-h:  56px;
  font-family: 'Segoe UI', system-ui, sans-serif;
}

/* ── RESET ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); min-height: 100dvh; }
button { cursor: pointer; font: inherit; border: none; background: none; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
ul { list-style: none; }
a { color: var(--teal); }

/* ── SCREENS ────────────────────────────────────────── */
.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; }

/* ── LOAD SCREEN ────────────────────────────────────── */
#screen-load {
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 32px 16px;
  background: radial-gradient(ellipse at 50% 0%, rgba(0,180,166,.12) 0%, transparent 70%), var(--bg);
}
.load-hero { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.logo-mark { width: 64px; height: 64px; filter: drop-shadow(0 0 24px rgba(0,180,166,.4)); }
.load-title { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; color: var(--text); }
.load-sub { color: var(--text-2); font-size: .9rem; }

.load-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--text-2);
  text-align: center;
  transition: border-color .2s, background .2s;
  cursor: default;
}
.drop-zone.drag-over {
  border-color: var(--teal);
  background: var(--teal-glow);
  color: var(--teal);
}
.drop-zone code { background: var(--bg-3); padding: 2px 6px; border-radius: 4px; font-size: .85rem; color: var(--text); }
.drop-zone span { color: var(--text-3); font-size: .8rem; }

.load-hint { font-size: .78rem; color: var(--text-3); text-align: center; }

/* ── BUTTONS ─────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--teal); color: #0f1923;
  font-weight: 600; font-size: .875rem;
  padding: 10px 20px; border-radius: 8px;
  cursor: pointer; transition: opacity .15s;
}
.btn-primary:hover { opacity: .88; }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-3); color: var(--text);
  font-weight: 500; font-size: .875rem;
  padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer; transition: border-color .15s;
}
.btn-secondary:hover { border-color: var(--teal); }

.btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(224,82,82,.15); color: var(--danger);
  font-weight: 500; font-size: .875rem;
  padding: 8px 16px; border-radius: 8px;
  border: 1px solid rgba(224,82,82,.3);
  cursor: pointer; transition: background .15s;
}
.btn-danger:hover { background: rgba(224,82,82,.25); }

.icon-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); }

.btn-export {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--teal); color: #0f1923;
  font-weight: 600; font-size: .82rem;
  padding: 7px 14px; border-radius: 7px;
  transition: opacity .15s;
}
.btn-export:hover { opacity: .88; }

/* ── TOPBAR ──────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; gap: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-title { font-weight: 700; font-size: 1rem; letter-spacing: -.01em; }

.version-badge {
  font-size: .72rem; background: var(--bg-3);
  border: 1px solid var(--border); color: var(--text-2);
  padding: 3px 8px; border-radius: 99px;
}

/* ── LAYOUT ──────────────────────────────────────────── */
#screen-admin {
  display: flex; flex-direction: column;
  min-height: 100dvh;
}
.admin-body {
  display: flex;
  flex: 1;
  padding-top: var(--topbar-h);
  min-height: calc(100dvh - var(--topbar-h) - 36px);
}

/* ── SIDEBAR ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 16px 0;
  overflow-y: auto;
  position: fixed;
  top: var(--topbar-h); bottom: 0; left: 0;
  z-index: 50;
  transition: transform .25s ease;
}
.sidebar.hidden { transform: translateX(-100%); }

.sidebar-section { padding: 8px 0; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 16px; }

.sidebar-label {
  font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-3);
  padding: 0 16px 6px;
}

.nav-list { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 10px; border-radius: 8px;
  color: var(--text-2); font-size: .875rem;
  transition: background .15s, color .15s;
  text-align: left;
}
.nav-item:hover { background: var(--bg-3); color: var(--text); }
.nav-item.active { background: var(--teal-glow); color: var(--teal); }

.nav-item .tab-icon { font-size: 1rem; width: 20px; text-align: center; }
.nav-item .tab-count {
  margin-left: auto; font-size: .72rem;
  background: var(--bg-3); color: var(--text-3);
  padding: 1px 6px; border-radius: 99px;
}

/* ── MAIN PANEL ──────────────────────────────────────── */
.main-panel {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 24px;
  overflow-y: auto;
  transition: margin-left .25s;
}
.main-panel.sidebar-hidden { margin-left: 0; }

.panel { display: none; }
.panel.active { display: block; }

.panel-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 12px;
  min-height: 300px; color: var(--text-3);
  text-align: center;
}

/* ── PANEL HEADER ────────────────────────────────────── */
.panel-header {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 16px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.panel-header h2 { font-size: 1.3rem; font-weight: 700; }
.panel-header p { color: var(--text-2); font-size: .875rem; margin-top: 2px; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── CARDS / TABLES ──────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: .9rem; font-weight: 600; }
.card-body { padding: 16px; }

/* ── SINGLE CARD EDITOR ──────────────────────────────── */
.single-card-editor { display: flex; flex-direction: column; gap: 16px; }

/* ── LIST TABLE ──────────────────────────────────────── */
.list-table-wrap { overflow-x: auto; }
.list-table {
  width: 100%; border-collapse: collapse;
  font-size: .85rem;
}
.list-table th {
  text-align: left; padding: 10px 12px;
  color: var(--text-3); font-weight: 600; font-size: .72rem;
  text-transform: uppercase; letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.list-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(38,55,80,.5);
  vertical-align: top;
  max-width: 240px;
}
.list-table tr:last-child td { border-bottom: none; }
.list-table tr:hover td { background: var(--bg-3); }

.cell-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; display: block; }
.cell-url  { color: var(--teal); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; display: block; }
.cell-type { font-size: .72rem; background: var(--bg-3); color: var(--text-2); padding: 2px 6px; border-radius: 4px; }

.row-actions { display: flex; gap: 4px; }

/* ── FORM FIELDS ─────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: .78rem; font-weight: 600; color: var(--text-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

input[type="text"],
input[type="url"],
input[type="number"],
input[type="email"],
textarea,
select {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 12px;
  font-size: .875rem;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--teal); }
textarea { resize: vertical; min-height: 80px; }
select option { background: var(--bg-2); }

.field-hint { font-size: .72rem; color: var(--text-3); }

/* ── APP SETTINGS ────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* ── ALERTS ──────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: 8px;
  font-size: .875rem;
}
.alert-error { background: rgba(224,82,82,.12); border: 1px solid rgba(224,82,82,.3); color: #f08080; }
.hidden { display: none !important; }

/* ── MODAL ───────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(10,16,24,.8);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-box {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 560px;
  max-height: 90dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-body { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── TOAST ───────────────────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: .85rem;
  display: flex; align-items: center; gap: 8px;
  animation: toast-in .2s ease;
  pointer-events: auto;
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
}
.toast.success { border-color: var(--teal); color: var(--teal); }
.toast.error   { border-color: var(--danger); color: var(--danger); }
@keyframes toast-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ── DRAG HANDLE ─────────────────────────────────────── */
.drag-handle {
  cursor: grab; color: var(--text-3); padding: 0 4px;
}
.drag-handle:active { cursor: grabbing; }
.dragging { opacity: .4; }
tr.drag-over-top td { border-top: 2px solid var(--teal); }

/* ── ORDER BADGE ─────────────────────────────────────── */
.order-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg-3); color: var(--text-3);
  font-size: .72rem; font-weight: 700;
}

/* ── RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 700px) {
  :root { --sidebar-w: 100%; }
  .sidebar {
    left: 0; right: 0;
    transform: translateX(-100%);
  }
  .sidebar.visible { transform: translateX(0); }
  .main-panel { margin-left: 0; }
  .field-row, .field-row-3 { grid-template-columns: 1fr; }
  .panel-header { flex-direction: column; }
}

/* ── SEARCH BAR ──────────────────────────────────────── */
.search-wrap { margin-bottom: 16px; position: relative; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search-input { padding-left: 38px; }

/* ── EMPTY STATE ─────────────────────────────────────── */
.empty-rows {
  text-align: center; padding: 32px; color: var(--text-3);
  font-size: .875rem;
}

/* ── TAB TYPE BADGE ──────────────────────────────────── */
.type-badge {
  display: inline-block; font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 4px;
}
.type-badge.single { background: rgba(244,195,77,.1); color: var(--gold); border: 1px solid rgba(244,195,77,.3); }
.type-badge.list   { background: rgba(0,180,166,.1);  color: var(--teal); border: 1px solid rgba(0,180,166,.3); }

/* ── TOPBAR BRAND ────────────────────────────────────────── */
.topbar-brand {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .72rem; font-weight: 600; color: var(--text-3);
  text-decoration: none; letter-spacing: .01em;
  padding: 4px 8px; border-radius: 6px;
  border: 1px solid transparent;
  transition: color .15s, border-color .15s;
}
.topbar-brand:hover { color: var(--teal); border-color: var(--border); }

/* ── APP FOOTER ──────────────────────────────────────────── */
.app-footer {
  height: 36px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; color: var(--text-3);
  flex-shrink: 0;
  /* spans full width below admin-body */
  position: sticky; bottom: 0; z-index: 40;
  margin-top: auto;
}
.app-footer a { color: var(--teal); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

/* Compensate for footer height */
.main-panel { padding-bottom: 52px; }

/* ── LOAD SCREEN POWERED BY ──────────────────────────────── */
.load-powered {
  font-size: .75rem; color: var(--text-3); text-align: center;
  margin-top: -8px;
}
.load-powered a { color: var(--teal); text-decoration: none; }
.load-powered a:hover { text-decoration: underline; }

/* ── ABOUT US PANEL ──────────────────────────────────────── */
.about-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 560px;
  display: flex; flex-direction: column; gap: 20px;
}
.about-logo-wrap {
  display: flex; align-items: center; gap: 16px;
}
.about-brand {
  font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em;
  color: var(--text);
}
.about-tagline { font-size: .82rem; color: var(--text-2); margin-top: 2px; }
.about-desc { font-size: .9rem; color: var(--text-2); line-height: 1.6; }
.about-desc strong { color: var(--text); }

.about-links { display: flex; flex-wrap: wrap; gap: 10px; }
.about-link-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 8px;
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text); font-size: .84rem; font-weight: 500;
  text-decoration: none; transition: border-color .15s, color .15s;
}
.about-link-btn:hover { border-color: var(--teal); color: var(--teal); }
.about-link-wa:hover { border-color: #25D366; color: #25D366; }

.about-divider {
  height: 1px; background: var(--border);
  margin: 4px 0;
}
.about-copy { font-size: .75rem; color: var(--text-3); }

/* ── FOOTER LEFT ADJUSTMENT ──────────────────────────────── */
#screen-admin .sidebar.hidden ~ .admin-body + .app-footer { left: 0; }

@media (max-width: 700px) {
  .app-footer { left: 0; }
  .topbar-brand span { display: none; }
}

/* ── BACKUP / LAST EXPORT SECTION ───────────────────────── */
.backup-section {
  width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 10px;
}
.backup-divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-3); font-size: .75rem;
}
.backup-divider::before,
.backup-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

.backup-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: default;
  transition: border-color .2s;
}
.backup-card:hover { border-color: var(--teal); }
.backup-icon { flex-shrink: 0; }
.backup-info { flex: 1; min-width: 0; }
.backup-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin-bottom: 2px; }
.backup-name  { font-size: .9rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.backup-meta  { font-size: .75rem; color: var(--text-2); margin-top: 1px; }

.backup-clear-btn {
  font-size: .72rem; color: var(--text-3); background: none; border: none;
  cursor: pointer; align-self: flex-end; padding: 2px 0;
  text-decoration: underline; text-underline-offset: 2px;
  transition: color .15s;
}
.backup-clear-btn:hover { color: var(--danger); }
