*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0f172a; --bg2: #1e293b; --bg3: #334155; --border: #334155;
  --text: #f1f5f9; --text2: #94a3b8;
  --primary: #1a56db; --primary2: #1d4ed8; --accent: #38bdf8;
  --success: #22c55e; --danger: #ef4444;
  --radius: 8px;
}
html { font-size: 15px; }
body { font-family: 'Sarabun', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
input, select { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: var(--radius); padding: 8px 12px; font-family: inherit; font-size: 0.9rem; transition: border-color .2s; }
input:focus, select:focus { outline: none; border-color: var(--primary); }

/* ── Navbar ── */
.navbar { position: fixed; top: 0; left: 0; right: 0; z-index: 200; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; height: 56px; background: rgba(15,23,42,.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.brand-link { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 900; font-size: 1.1rem; }
.brand-sub { color: var(--primary); }
.nav-links { display: flex; align-items: center; gap: 16px; }
.nav-link { color: var(--text2); font-size: .85rem; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius); font-family: inherit; font-size: .9rem; font-weight: 500; cursor: pointer; border: none; transition: all .15s; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary2); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: .82rem; }
.btn-icon { padding: 5px 8px; }
.hidden { display: none !important; }

/* ── Hero ── */
.hero-section { padding: 80px 20px 40px; min-height: 360px; display: flex; align-items: center; justify-content: center; }
.hero-inner { max-width: 780px; width: 100%; text-align: center; }
.hero-badge { display: inline-block; background: rgba(26,86,219,.2); color: var(--accent); font-size: .78rem; font-weight: 600; padding: 4px 14px; border-radius: 99px; margin-bottom: 16px; border: 1px solid rgba(26,86,219,.4); }
.hero-title { font-size: 2.4rem; font-weight: 900; margin-bottom: 10px; }
.gradient-text { background: linear-gradient(135deg, #1a56db, #38bdf8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.hero-subtitle { color: var(--text2); font-size: 1rem; margin-bottom: 28px; }

/* ── Shorten box ── */
.shorten-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; padding: 24px; text-align: left; }
.shorten-form { display: flex; flex-direction: column; gap: 10px; }
#url-input { width: 100%; font-size: 1rem; padding: 12px 16px; border-radius: 10px; }
.shorten-options { display: none; flex-wrap: wrap; gap: 10px; }
.shorten-options.show { display: flex; }
.shorten-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.shorten-result { margin-top: 16px; padding: 16px; background: var(--bg3); border-radius: 10px; }
.result-url { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.result-short { font-size: 1.1rem; font-weight: 900; color: var(--accent); }
.result-orig { font-size: .82rem; color: var(--text2); word-break: break-all; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── App Shell ── */
.app-shell { display: flex; min-height: calc(100vh - 56px); margin-top: 0; }
.sidebar { width: 200px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 56px; bottom: 0; left: 0; }
.sidebar-nav { padding: 12px 0; flex: 1; }
.sidebar-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 18px; background: none; border: none; cursor: pointer; color: var(--text2); font-family: inherit; font-size: .88rem; text-align: left; transition: all .15s; }
.sidebar-item:hover { background: var(--bg3); color: var(--text); }
.sidebar-item.active { background: rgba(26,86,219,.2); color: var(--primary); }
.si-icon { width: 20px; font-size: 1rem; }
.sidebar-user { padding: 14px 18px; border-top: 1px solid var(--border); font-size: .82rem; color: var(--text2); }
.sidebar-user img { width: 26px; height: 26px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.main-content { margin-left: 200px; flex: 1; padding: 28px; }

/* ── Pages ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h1 { font-size: 1.4rem; font-weight: 600; }
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card h3 { font-size: 1rem; font-weight: 600; }
.summary-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat-value { font-size: 1.8rem; font-weight: 900; color: var(--primary); margin: 6px 0; }
.stat-label { font-size: .82rem; color: var(--text2); }

/* ── Link card ── */
.link-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 10px; display: flex; align-items: center; gap: 14px; }
.link-card.expired { opacity: .5; }
.link-info { flex: 1; min-width: 0; }
.link-short { font-weight: 600; color: var(--accent); font-size: .95rem; }
.link-short:hover { text-decoration: underline; }
.link-orig { font-size: .8rem; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 340px; }
.link-meta { font-size: .78rem; color: var(--text2); margin-top: 2px; }
.link-clicks { font-size: 1rem; font-weight: 900; color: var(--primary); min-width: 56px; text-align: center; }
.link-clicks small { display: block; font-size: .72rem; font-weight: 400; color: var(--text2); }
.link-actions { display: flex; gap: 6px; flex-shrink: 0; }
.badge-pw { background: rgba(245,158,11,.15); color: #f59e0b; font-size: .72rem; padding: 1px 7px; border-radius: 99px; margin-left: 6px; }
.badge-exp { background: rgba(239,68,68,.15); color: #ef4444; font-size: .72rem; padding: 1px 7px; border-radius: 99px; margin-left: 6px; }
.badge-off { background: rgba(148,163,184,.15); color: #94a3b8; font-size: .72rem; padding: 1px 7px; border-radius: 99px; margin-left: 6px; }

/* ── Empty ── */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text2); }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 300; display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px 20px; overflow-y: auto; }
.modal-box { background: var(--bg2); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 760px; padding: 28px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal-header h2 { font-size: 1.2rem; font-weight: 600; margin: 0; }

/* ── Stats ── */
.stats-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stats-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.stats-block { background: var(--bg3); border-radius: 10px; padding: 14px; }
.stats-block h4 { font-size: .85rem; color: var(--text2); margin-bottom: 10px; }
.stats-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: .85rem; border-bottom: 1px solid var(--border); }
.stats-row:last-child { border-bottom: none; }
.stats-bar { height: 6px; background: var(--primary); border-radius: 3px; margin-top: 2px; }
.chart-wrap { background: var(--bg3); border-radius: 10px; padding: 14px; margin-bottom: 16px; }
.chart-wrap h4 { font-size: .85rem; color: var(--text2); margin-bottom: 10px; }

/* ── QR ── */
.qr-popup { text-align: center; }
.qr-popup img { max-width: 220px; background: white; padding: 12px; border-radius: 12px; }

@media (max-width: 700px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .app-shell { padding-top: 56px; }
  .hero-title { font-size: 1.7rem; }
  .summary-grid { grid-template-columns: 1fr; }
  .stats-grid-2 { grid-template-columns: 1fr; }
  .stats-summary { grid-template-columns: 1fr; }
}

/* ════════════ LIGHT THEME ════════════ */
:root {
  --bg: #ffffff; --bg2: #f8fafc; --bg3: #f1f5f9; --border: #e2e8f0;
  --text: #0f172a; --text2: #64748b;
  --primary: #1a56db; --primary2: #1d4ed8; --accent: #1a56db;
  --success: #16a34a; --warn: #d97706; --danger: #dc2626;
  --radius: 8px;
}
body { background: #fff; color: #0f172a; }
a { color: var(--primary); }
input, select, textarea { background: #fff; border-color: #e2e8f0; color: #0f172a; }
.navbar { background: rgba(255,255,255,.97); border-bottom: 1px solid #e2e8f0; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.brand-link { color: #0f172a; }
.nav-link { color: #64748b; }
.nav-link:hover { color: #0f172a; text-decoration: none; }
.sidebar { background: #f8fafc; border-color: #e2e8f0; }
.sidebar-item { color: #64748b; }
.sidebar-item:hover { background: #f1f5f9; color: #0f172a; }
.sidebar-item.active { background: rgba(26,86,219,.08); color: #1a56db; }
.sidebar-user { color: #64748b; border-color: #e2e8f0; }
.main-content { background: #fff; }
.card { background: #fff; border-color: #e2e8f0; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.data-table { background: #fff; }
.data-table th { background: #f8fafc; color: #64748b; }
.data-table td { border-color: #e2e8f0; }
.data-table tr:hover td { background: rgba(0,0,0,.02); }
.stat-card { background: #fff; border-color: #e2e8f0; }
.stat-label { color: #64748b; }
.stat-value { color: #1a56db; }
.empty-state { color: #94a3b8; }
.hero-badge { background: rgba(26,86,219,.08); color: #1a56db; border-color: rgba(26,86,219,.25); }
.hero-title { color: #0f172a; }
.hero-subtitle { color: #64748b; }
.gradient-text { background: linear-gradient(135deg,#1a56db,#0ea5e9); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.feature-card { background: #fff; border-color: #e2e8f0; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.feature-card p { color: #64748b; }
.btn-outline { color: #0f172a; border-color: #e2e8f0; }
.btn-outline:hover { border-color: #1a56db; color: #1a56db; background: rgba(26,86,219,.05); }
.modal-box { background: #fff; border-color: #e2e8f0; }

.th-flag {
  background: linear-gradient(90deg,
    #A51931 0%, #A51931 25%,
    #C0C0CC 25%, #C0C0CC 37.5%,
    #2E3192 37.5%, #2E3192 62.5%,
    #C0C0CC 62.5%, #C0C0CC 75%,
    #A51931 75%, #A51931 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 900;
  border: none;
  padding: 0;
  text-shadow: none;
  filter: none;
  display: inline;
}
