/* ═══════════════════════════════════════════════════════════════
   PPAI Shortener — Grafana-inspired Admin UI
   Dark / Light theme via [data-theme] on <html>
══════════════════════════════════════════════════════════════ */

/* ── Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Inter:wght@300;400;500;600&display=swap');

/* ── Variables ── */
:root {
  --font-ui: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 6px;
  --radius-lg: 10px;
  --sidebar-w: 220px;
  --transition: 0.18s ease;
}

[data-theme="dark"] {
  --bg:           #111217;
  --bg-panel:     #181b24;
  --bg-card:      #1e2130;
  --bg-hover:     #252a3a;
  --bg-input:     #12141c;
  --border:       #2a2f45;
  --border-focus: #4f7de8;

  --text:         #d4d9f0;
  --text-dim:     #7b82a8;
  --text-muted:   #4a5080;

  --accent:       #4f7de8;
  --accent-hover: #6b94f5;
  --accent-glow:  rgba(79,125,232,0.25);

  --green:        #39d08a;
  --red:          #e85c5c;
  --orange:       #f0a845;
  --yellow:       #f0d145;

  --sidebar-bg:   #0f1118;
  --sidebar-border: #1d2135;

  --scrollbar-bg: #1e2130;
  --scrollbar-thumb: #2f3650;
}

[data-theme="light"] {
  --bg:           #f4f5f8;
  --bg-panel:     #ffffff;
  --bg-card:      #ffffff;
  --bg-hover:     #f0f2f8;
  --bg-input:     #f8f9fc;
  --border:       #dde0ec;
  --border-focus: #4f7de8;

  --text:         #1e2134;
  --text-dim:     #6b7299;
  --text-muted:   #a0a8c8;

  --accent:       #4f7de8;
  --accent-hover: #3a66d4;
  --accent-glow:  rgba(79,125,232,0.15);

  --green:        #1faa6e;
  --red:          #d93535;
  --orange:       #d68a00;
  --yellow:       #c4a800;

  --sidebar-bg:   #1a1f32;
  --sidebar-border: #252c48;

  --scrollbar-bg: #eef0f8;
  --scrollbar-thumb: #c4c8dc;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: var(--font-ui); }
input, select, textarea { font-family: var(--font-ui); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-bg); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }

/* ── Utilities ── */
.hidden { display: none !important; }
.mono { font-family: var(--font-mono) !important; }

/* ══════════════════════════════════════════════════════════════
   LOGIN SCREEN
══════════════════════════════════════════════════════════════ */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  z-index: 100;
}

.login-card {
  width: 400px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}

.login-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 4px;
}
.logo-icon { font-size: 22px; }
.logo-text { font-size: 20px; font-weight: 600; letter-spacing: -0.3px; }
.logo-accent { color: var(--accent); }

.login-sub {
  color: var(--text-dim); font-size: 13px;
  margin-bottom: 28px; padding-left: 2px;
}

.login-error {
  background: rgba(232,92,92,0.12);
  border: 1px solid rgba(232,92,92,0.4);
  color: var(--red);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ══════════════════════════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════════════════════════ */
.app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 8px;
  padding: 0 20px;
  margin-bottom: 28px;
}
[data-theme="dark"] .sidebar-logo .logo-text { color: #d4d9f0; }
[data-theme="light"] .sidebar-logo .logo-text { color: #e0e4f5; }

.sidebar-nav { flex: 1; padding: 0 10px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px;
  border: none; border-radius: var(--radius);
  background: transparent;
  color: #7b82a8;
  font-size: 13.5px; font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(79,125,232,0.12); color: #c8d0f0; }
.nav-item.active { background: rgba(79,125,232,0.2); color: #8bb0f8; }
.nav-icon { font-size: 15px; }

.sidebar-bottom {
  padding: 0 14px;
  display: flex; align-items: center; gap: 8px;
  border-top: 1px solid var(--sidebar-border);
  padding-top: 16px;
  margin-top: 10px;
}

.company-badge {
  flex: 1;
  font-size: 11.5px;
  color: #5a6080;
  font-family: var(--font-mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.theme-toggle, .btn-logout {
  width: 30px; height: 30px;
  border: 1px solid #2a2f45;
  border-radius: var(--radius);
  background: transparent;
  color: #7b82a8;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: all var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover, .btn-logout:hover {
  background: rgba(79,125,232,0.15); color: #8bb0f8;
  border-color: var(--accent);
}

/* ── Main ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  overflow-x: hidden;
}

.view { display: none; padding: 28px 32px; }
.view.active { display: block; }

.view-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 22px;
}
.view-title { font-size: 22px; font-weight: 600; letter-spacing: -0.3px; }
.view-sub { color: var(--text-dim); font-size: 13px; margin-top: 3px; }

.header-actions { display: flex; gap: 10px; align-items: center; }

/* ── Stats bar ── */
.stats-bar {
  display: flex; gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.stat-pill {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 18px;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 120px;
}
.stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-val { font-size: 22px; font-weight: 600; font-family: var(--font-mono); color: var(--accent); }

/* ── Table ── */
.table-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.links-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

.links-table th {
  padding: 11px 14px;
  text-align: left;
  font-weight: 500;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  user-select: none;
  white-space: nowrap;
}

.links-table th[data-sort] { cursor: pointer; }
.links-table th[data-sort]:hover { color: var(--text); }
.sort-arrow { opacity: 0.4; font-size: 11px; }

.links-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.links-table tr:last-child td { border-bottom: none; }
.links-table tbody tr {
  transition: background var(--transition);
}
.links-table tbody tr:hover { background: var(--bg-hover); }

.empty-row td {
  text-align: center;
  color: var(--text-muted);
  padding: 36px !important;
  font-style: italic;
}

/* Cell types */
.code-cell {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}
.url-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
  font-size: 12.5px;
}
.url-cell a { color: var(--text-dim); }
.url-cell a:hover { color: var(--accent); }
.clicks-cell { font-family: var(--font-mono); font-weight: 500; }
.date-cell { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.note-cell { color: var(--text-dim); font-size: 12px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 500;
}
.badge-green { background: rgba(57,208,138,0.12); color: var(--green); border: 1px solid rgba(57,208,138,0.25); }
.badge-red   { background: rgba(232,92,92,0.12);  color: var(--red);   border: 1px solid rgba(232,92,92,0.25); }
.badge-orange{ background: rgba(240,168,69,0.12); color: var(--orange); border: 1px solid rgba(240,168,69,0.25); }

.action-btns { display: flex; gap: 6px; }
.btn-icon {
  width: 28px; height: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); border-color: var(--text-muted); }
.btn-icon.danger:hover { background: rgba(232,92,92,0.12); color: var(--red); border-color: rgba(232,92,92,0.4); }
.btn-icon.copy:hover { background: var(--accent-glow); color: var(--accent); border-color: var(--accent); }

/* ══════════════════════════════════════════════════════════════
   STATS VIEW
══════════════════════════════════════════════════════════════ */
.stats-cards {
  display: flex; gap: 18px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}
.stats-card {
  flex: 1; min-width: 160px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
}
.sc-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.sc-val { font-size: 36px; font-family: var(--font-mono); font-weight: 600; color: var(--accent); }

.section-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }

.top-links-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.top-links-list { display: flex; flex-direction: column; gap: 10px; }

.top-link-row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.tl-code { font-family: var(--font-mono); color: var(--accent); font-size: 13px; min-width: 90px; }
.tl-url { flex: 1; color: var(--text-dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-bar-wrap { width: 120px; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.tl-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.6s ease; }
.tl-clicks { font-family: var(--font-mono); font-size: 13px; font-weight: 600; min-width: 40px; text-align: right; }

/* ══════════════════════════════════════════════════════════════
   FORM ELEMENTS
══════════════════════════════════════════════════════════════ */
.field-wrap { margin-bottom: 18px; }
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 7px;
}
.required { color: var(--red); }

.field-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13.5px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.field-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.field-input::placeholder { color: var(--text-muted); }
.field-select { appearance: none; cursor: pointer; }

.search-input {
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  width: 220px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-input::placeholder { color: var(--text-muted); }

/* Range slider */
.range-input {
  width: 100%;
  accent-color: var(--accent);
  height: 4px;
  cursor: pointer;
}
.range-labels {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text-muted); margin-top: 4px;
}

/* Code preview */
.code-preview {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 10px;
  word-break: break-all;
}
.preview-base { color: var(--text-muted); }
.preview-code-val { color: var(--accent); font-weight: 600; }

/* Code mode tabs */
.code-mode-tabs { display: flex; gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.mode-tab {
  flex: 1; padding: 7px 0;
  border: none; background: transparent;
  color: var(--text-dim); font-size: 12.5px;
  transition: all var(--transition);
}
.mode-tab.active { background: var(--accent); color: #fff; }
.mode-tab:not(.active):hover { background: var(--bg-hover); }

/* ══════════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════════ */
.btn {
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  border: none;
  transition: all var(--transition);
  outline: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 4px 14px var(--accent-glow); }
.btn-primary:active { transform: scale(0.98); }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-full { width: 100%; justify-content: center; padding: 11px 18px; }

/* ══════════════════════════════════════════════════════════════
   DRAWER
══════════════════════════════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 50;
  backdrop-filter: blur(2px);
  animation: fade-in 0.2s ease;
}

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 420px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  z-index: 60;
  display: flex; flex-direction: column;
  animation: slide-in 0.25s ease;
  overflow-y: auto;
}

.drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg-panel);
  z-index: 1;
}
.drawer-title { font-size: 16px; font-weight: 600; }
.drawer-close {
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.drawer-close:hover { background: rgba(232,92,92,0.12); color: var(--red); border-color: rgba(232,92,92,0.4); }

.drawer-body { padding: 24px; flex: 1; }

.drawer-actions {
  display: flex; gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.drawer-actions .btn { flex: 1; justify-content: center; }

.error-msg {
  background: rgba(232,92,92,0.1);
  border: 1px solid rgba(232,92,92,0.3);
  color: var(--red);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* ══════════════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 16px;
  font-size: 13px;
  min-width: 240px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  animation: toast-in 0.25s ease;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent); }
.toast-icon { font-size: 15px; }
.toast-text { flex: 1; }
.toast-close { background: none; border: none; color: var(--text-muted); font-size: 13px; cursor: pointer; padding: 0; }

/* ══════════════════════════════════════════════════════════════
   QR DRAWER
══════════════════════════════════════════════════════════════ */
.qr-drawer { width: 700px; }

.qr-drawer-sub {
  font-size: 12px;
  color: var(--accent);
  margin-top: 2px;
}

.qr-drawer-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Left: preview ── */
.qr-preview-col {
  width: 230px;
  flex-shrink: 0;
  padding: 24px 20px 24px 24px;
  display: flex; flex-direction: column; gap: 14px;
  border-right: 1px solid var(--border);
}

.qr-img-wrap {
  width: 190px; height: 190px;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  background: #fff;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.qr-img {
  width: 190px; height: 190px;
  display: block;
  image-rendering: pixelated;
  object-fit: contain;
}

.qr-spinner {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.92);
  font-size: 12px;
  color: #888;
}

.qr-url-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  display: flex; flex-direction: column; gap: 3px;
}
.qr-url-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.qr-url-val {
  font-size: 11.5px;
  color: var(--accent);
  word-break: break-all;
  line-height: 1.4;
}

.qr-preview-actions {
  display: flex; flex-direction: column; gap: 8px;
}
.qr-preview-actions .btn { justify-content: center; font-size: 13px; }
.qr-preview-actions a.btn { text-decoration: none; }

/* ── Right: settings ── */
.qr-settings-col {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 24px;
  display: flex; flex-direction: column; gap: 20px;
}

.qr-group-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* Style picker */
.style-picker {
  display: flex; flex-wrap: wrap; gap: 6px;
}

.style-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 10px;
  cursor: pointer;
  transition: all var(--transition);
  min-width: 54px;
}
.style-btn svg { width: 22px; height: 22px; }
.style-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.style-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }

/* Colors */
.color-row {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
}
.color-field {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 11px; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.4px;
}
.color-input-wrap {
  display: flex; align-items: center; gap: 8px;
}
.color-input-wrap input[type="color"] {
  width: 36px; height: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: none; padding: 2px; cursor: pointer;
}
.color-hex {
  font-family: var(--font-mono); font-size: 12px; color: var(--text-dim);
}

/* Transparent toggle */
.transparent-toggle {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 12px; color: var(--text-dim);
  user-select: none; margin-top: 2px;
}
.transparent-toggle input { display: none; }
.toggle-track {
  width: 32px; height: 18px; background: var(--border);
  border-radius: 9px; position: relative; transition: background var(--transition); flex-shrink: 0;
}
.toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #fff; transition: transform var(--transition);
}
.transparent-toggle input:checked ~ .toggle-track { background: var(--accent); }
.transparent-toggle input:checked ~ .toggle-track .toggle-thumb { transform: translateX(14px); }

/* Gradient */
.gradient-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.qr-select { max-width: 230px; font-size: 13px; }

/* Logo */
.logo-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-sm { padding: 6px 14px; font-size: 12.5px; }
.logo-preview {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 5px 10px; max-width: 200px;
}
.logo-thumb { width: 24px; height: 24px; object-fit: contain; border-radius: 3px; }
.logo-name {
  font-size: 11.5px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100px;
}
.logo-uploading { font-size: 12px; color: var(--text-muted); font-style: italic; }
.logo-size-wrap { margin-top: 12px; }

/* ── Image upload in create drawer ── */
.field-hint { color: var(--text-muted); font-weight: 400; font-size: 11.5px; }
.img-upload-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.img-upload-preview {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 10px;
}
.img-upload-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 3px; flex-shrink: 0; }

.qr-note {
  font-size: 11px; color: var(--text-muted);
  border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px;
}



/* Color grid */
.color-grid {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 12px 20px;
  align-items: start;
}

/* Size picker */
.size-picker { display: flex; gap: 6px; margin-top: 6px; }
.size-btn {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.size-btn:hover { border-color: var(--accent); color: var(--accent); }
.size-btn.active { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }

/* Output row */
.output-row { display: flex; gap: 24px; flex-wrap: wrap; }
.output-field { display: flex; flex-direction: column; gap: 4px; }

/* Logo options */
.logo-options-row { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.logo-size-block { flex: 1; min-width: 160px; }
.qr-note-inline { color: var(--text-muted); font-size: 10px; text-transform: none; letter-spacing: 0; font-weight: 400; }

/* ══════════════════════════════════════════════════════════════
   MOBILE TOPBAR (hidden on desktop)
══════════════════════════════════════════════════════════════ */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--sidebar-border);
  padding: 0 14px;
  align-items: center;
  justify-content: space-between;
  z-index: 40;
}
.mobile-topbar-logo { display: flex; align-items: center; gap: 8px; }
.mobile-logo-text { font-size: 17px; font-weight: 600; color: #d4d9f0; letter-spacing: -0.3px; }
.mobile-topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE (max-width: 768px)
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Login */
  .login-card {
    width: calc(100% - 32px);
    max-width: 400px;
    padding: 28px 20px;
  }

  /* Show mobile topbar */
  .mobile-topbar { display: flex; }

  /* Sidebar → bottom nav bar */
  .sidebar {
    top: auto;
    bottom: 0; left: 0; right: 0;
    width: 100%;
    height: 58px;
    flex-direction: row;
    align-items: center;
    padding: 0;
    border-right: none;
    border-top: 1px solid var(--sidebar-border);
    z-index: 40;
  }
  .sidebar-logo { display: none; }
  .sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: row;
    padding: 0;
    height: 100%;
  }
  .nav-item {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    font-size: 11px;
    padding: 0;
    margin: 0;
    border-radius: 0;
    height: 100%;
  }
  .nav-icon { font-size: 20px; }
  .sidebar-bottom { display: none; }

  /* Main content area */
  .main {
    margin-left: 0;
    padding-top: 52px;
    padding-bottom: 58px;
  }
  .view { padding: 14px 12px; }

  /* View header */
  .view-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 14px;
  }
  .header-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .search-input { width: 100%; }
  .header-actions .btn { width: 100%; justify-content: center; }

  /* Stats bar */
  .stats-bar { gap: 8px; margin-bottom: 12px; }
  .stat-pill { min-width: 0; flex: 1; padding: 8px 10px; }
  .stat-label { font-size: 10px; }
  .stat-val { font-size: 18px; }

  /* Table — hide Created, Expires, Note columns */
  .table-wrap { border-radius: var(--radius); }
  .links-table th, .links-table td { padding: 10px 8px; font-size: 12px; }
  .links-table th:nth-child(4), .links-table td:nth-child(4),
  .links-table th:nth-child(5), .links-table td:nth-child(5),
  .links-table th:nth-child(6), .links-table td:nth-child(6) { display: none; }
  .url-cell { max-width: 100px; }
  .code-cell { font-size: 12px; }
  .action-btns { gap: 4px; }
  .btn-icon { width: 32px; height: 32px; }

  /* Drawers — full screen between topbar and bottom nav */
  .drawer {
    top: 52px;
    right: 0; left: 0;
    bottom: 58px;
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .qr-drawer { width: 100%; }

  /* QR drawer — stack vertically */
  .qr-drawer-body { flex-direction: column; overflow-y: auto; }
  .qr-preview-col {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 14px;
    padding: 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
  }
  .qr-preview-actions { flex-direction: row; flex-wrap: wrap; }
  .qr-settings-col { padding: 16px; }

  /* Toast */
  #toast-container { bottom: 68px; right: 12px; left: 12px; }
  .toast { min-width: 0; width: 100%; }

  /* Stats view */
  .stats-cards { gap: 10px; }
  .stats-card { min-width: 0; padding: 16px; }
  .sc-val { font-size: 28px; }
  .tl-bar-wrap { display: none; }
  .tl-url { max-width: 90px; }
  .tl-code { min-width: 70px; }

  /* Img upload in create drawer */
  .img-upload-row { flex-direction: column; align-items: flex-start; }
}

/* ══════════════════════════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════════════════════════ */
@keyframes fade-in {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes scale-in {
  from { transform: translate(-50%, -50%) scale(0.92); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1);    opacity: 1; }
}
@keyframes toast-in {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
@keyframes toast-out {
  from { transform: translateY(0);    opacity: 1; }
  to   { transform: translateY(16px); opacity: 0; }
}

/* ─── API Tokens ─────────────────────────────────────────────── */
.token-gen-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.token-gen-row .field-input { flex: 1; }
.token-gen-row .btn-sm { white-space: nowrap; flex-shrink: 0; }
.token-cell { max-width: 320px; }
.token-val {
  font-size: 12.5px;
  color: var(--text-dim);
  word-break: break-all;
  letter-spacing: 0.02em;
}
.token-current-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 999px;
  background: rgba(57,208,138,0.12);
  color: var(--green);
  border: 1px solid rgba(57,208,138,0.25);
  vertical-align: middle;
}
