@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ============================================
   Portal Voucher Hotspot — Design System
   Default: Light Mode + Theme Toggle & Accent Color Support
   ============================================ */

:root {
    /* Base Color Tokens — LIGHT MODE (DEFAULT) */
    --bg:            #f8fafc;
    --bg-raised:     #ffffff;
    --bg-card:       #ffffff;
    --bg-input:      #f1f5f9;
    --border:        #e2e8f0;
    --border-hover:  #cbd5e1;
    --border-focus:  var(--accent);
    
    /* Accent & Brand (overridable via inline style) */
    --accent:        #2563eb;
    --accent-hover:  #1d4ed8;
    --accent-subtle: rgba(37, 99, 235, 0.08);

    /* Text Tokens */
    --text:          #0f172a;
    --text-secondary:#475569;
    --text-faint:    #94a3b8;

    /* Status Colors */
    --success:       #16a34a;
    --success-bg:    #dcfce7;
    --warning:       #ca8a04;
    --warning-bg:    #fef9c3;
    --danger:        #dc2626;
    --danger-bg:     #fee2e2;

    /* Sizing & Radius */
    --radius:        10px;
    --radius-sm:     6px;
    --radius-lg:     14px;
    --font:          'Inter', system-ui, -apple-system, sans-serif;
    --shadow:        0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05);
    --shadow-md:     0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

/* DARK MODE OVERRIDES */
[data-theme="dark"] {
    --bg:            #111318;
    --bg-raised:     #191c24;
    --bg-card:       #1f2330;
    --bg-input:      #161920;
    --border:        rgba(255, 255, 255, 0.08);
    --border-hover:  rgba(255, 255, 255, 0.15);
    
    --text:          #e4e6ed;
    --text-secondary:#8b90a0;
    --text-faint:    #5c6070;

    --success:       #22c55e;
    --success-bg:    rgba(34, 197, 94, 0.12);
    --warning:       #eab308;
    --warning-bg:    rgba(234, 179, 8, 0.12);
    --danger:        #ef4444;
    --danger-bg:     rgba(239, 68, 68, 0.12);
    --shadow:        none;
    --shadow-md:     none;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.2s, color 0.2s;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

/* ---- Page Shell ---- */
.page {
    max-width: 440px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.page-head {
    padding: 20px 20px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.page-head .head-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-head .back {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}

.page-head h2 {
    font-size: 16px;
    font-weight: 700;
}

.page-body {
    flex: 1;
    padding: 16px 20px 32px;
    display: flex;
    flex-direction: column;
}

.page-hero {
    text-align: center;
    padding: 24px 20px 8px;
    position: relative;
}

.page-hero h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.page-hero p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Theme Toggle Button */
.theme-toggle {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.theme-toggle:hover {
    color: var(--text);
    border-color: var(--border-hover);
}

/* ---- Progress Indicator ---- */
.steps {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 12px 20px 0;
    justify-content: center;
}

.step-bar {
    height: 3px;
    flex: 1;
    max-width: 100px;
    background: var(--border);
    border-radius: 2px;
    transition: background 0.3s;
}

.step-bar.done { background: var(--accent); }
.step-bar.active { background: linear-gradient(90deg, var(--accent) 50%, var(--border) 50%); }

.step-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
    transition: background 0.3s;
}

.step-dot.done, .step-dot.active { background: var(--accent); }

/* ---- Card ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.card-flat {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    margin-bottom: 12px;
}

/* ---- Row / Detail pairs ---- */
.row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 13px;
}

.row + .row { border-top: 1px solid var(--border); }
.row:first-child { padding-top: 0; }
.row:last-child { padding-bottom: 0; }

.row-label { color: var(--text-secondary); }
.row-value { font-weight: 600; text-align: right; word-break: break-all; }

/* ---- Package Select ---- */
.pkg-list { display: flex; flex-direction: column; gap: 8px; }

.pkg-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-raised);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.pkg-item:hover { border-color: var(--border-hover); }

.pkg-item.active {
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.pkg-item .name {
    font-size: 14px;
    font-weight: 700;
}

.pkg-item .speed {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.pkg-item .price {
    font-size: 15px;
    font-weight: 800;
    color: var(--accent);
    white-space: nowrap;
}

/* ---- Payment Channel Grid ---- */
.pay-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    margin: 14px 0 8px;
}

.pay-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.pay-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    background: var(--bg-raised);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    min-height: 70px;
}

.pay-item:hover { border-color: var(--border-hover); }

.pay-item.active {
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.pay-item.off {
    opacity: 0.35;
    pointer-events: none;
}

.pay-item img { height: 22px; object-fit: contain; }

.pay-item .label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
}

.pay-item .fee {
    font-size: 9px;
    color: var(--text-faint);
}

.pay-item .redirect-tag {
    position: absolute;
    top: 3px;
    right: 3px;
    font-size: 8px;
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--warning-bg);
    color: var(--warning);
    font-weight: 700;
}

/* ---- Payment Result ---- */
.pay-result-enter {
    animation: fadeUp 0.3s ease;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.code-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 10px 0;
}

.code-box .code {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 1.5px;
}

.code-box .copy-btn {
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
    transition: color 0.15s, border-color 0.15s;
}

.code-box .copy-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.code-box .copy-btn.copied {
    color: var(--success);
    border-color: var(--success);
}

.qr-frame {
    background: #ffffff;
    border-radius: var(--radius);
    padding: 12px;
    max-width: 180px;
    margin: 10px auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.qr-frame img { width: 100%; border-radius: 4px; }

/* ---- Countdown ---- */
.timer {
    text-align: center;
    padding: 8px 0;
}

.timer-label {
    font-size: 11px;
    color: var(--text-faint);
    margin-bottom: 2px;
}

.timer-value {
    font-size: 22px;
    font-weight: 800;
    font-family: 'Courier New', monospace;
    color: var(--warning);
    letter-spacing: 2px;
}

.timer-value.expired { color: var(--danger); }

/* ---- Instructions ---- */
.inst-list {
    list-style: none;
    counter-reset: step;
}

.inst-list li {
    counter-increment: step;
    padding: 6px 0 6px 28px;
    font-size: 12px;
    color: var(--text-secondary);
    position: relative;
    line-height: 1.5;
    border-bottom: 1px solid var(--border);
}

.inst-list li:last-child { border-bottom: none; }

.inst-list li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 7px;
    width: 18px;
    height: 18px;
    background: var(--bg);
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- Voucher Display ---- */
.voucher {
    text-align: center;
    background: var(--bg);
    border: 2px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: 24px 16px;
    margin: 12px 0;
}

.voucher .tag {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-faint);
    margin-bottom: 8px;
}

.voucher .cred {
    font-family: 'Courier New', monospace;
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 2px;
    margin-bottom: 6px;
    word-break: break-all;
}

.voucher .hint {
    font-size: 12px;
    color: var(--text-secondary);
}

.voucher .hint strong { color: var(--accent); }

/* ---- Status Icon ---- */
.status-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
}

.status-icon svg { width: 26px; height: 26px; }

.status-icon.ok  { background: var(--success-bg); color: var(--success); }
.status-icon.warn { background: var(--warning-bg); color: var(--warning); }
.status-icon.err { background: var(--danger-bg); color: var(--danger); }

/* ---- Form ---- */
.field { margin-bottom: 14px; }

.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.input {
    width: 100%;
    padding: 11px 12px;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s, background-color 0.15s;
    -webkit-appearance: none;
}

.input:focus { border-color: var(--border-focus); }
.input::placeholder { color: var(--text-faint); }

.input-with-icon { position: relative; }
.input-with-icon .input { padding-left: 38px; }

.input-with-icon .ico {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    pointer-events: none;
    display: flex;
}

.field-hint {
    font-size: 11px;
    margin-top: 4px;
    color: var(--text-faint);
}

.field-hint.err { color: var(--danger); }
.field-hint.ok { color: var(--success); }

select.input {
    cursor: pointer;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

select.input option { background: var(--bg-card); color: var(--text); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-family: var(--font);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background 0.15s, opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
    width: 100%;
    line-height: 1.4;
}

.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--accent);
    color: #ffffff;
}
.btn-primary:hover { filter: brightness(0.92); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1.5px solid var(--border);
}
.btn-outline:hover { border-color: var(--border-hover); background: var(--bg-raised); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
}
.btn-ghost:hover { color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }

.btn-sm {
    padding: 8px 14px;
    font-size: 12px;
    width: auto;
    border-radius: var(--radius-sm);
}

.btn-icon {
    width: auto;
    padding: 8px;
    min-width: 34px;
}

/* Color Picker & Preset Swatches (Admin Settings) */
.color-presets {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s;
    display: inline-block;
}

.color-swatch:hover { transform: scale(1.1); }
.color-swatch.active { border-color: var(--text); }

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.badge-ok  { background: var(--success-bg); color: var(--success); }
.badge-warn { background: var(--warning-bg); color: var(--warning); }
.badge-err { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--accent-subtle); color: var(--accent); }

/* ---- Alerts ---- */
.notice {
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
    line-height: 1.4;
}

.notice svg { flex-shrink: 0; margin-top: 1px; }

.notice-ok   { background: var(--success-bg); color: var(--success); }
.notice-warn { background: var(--warning-bg); color: var(--warning); }
.notice-err  { background: var(--danger-bg);  color: var(--danger); }
.notice-info { background: var(--accent-subtle); color: var(--accent); }

/* ---- Spinner ---- */
.spin {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spinning 0.6s linear infinite;
}

@keyframes spinning { to { transform: rotate(360deg); } }

/* ---- Dashboard ---- */
.dash {
    max-width: 1060px;
    margin: 0 auto;
    padding: 20px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.stat .stat-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
    margin-bottom: 6px;
}

.stat .stat-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
}

/* ---- Tabs ---- */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
    gap: 0;
}

.tab {
    padding: 10px 16px;
    font-family: var(--font);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-faint);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.tab.on {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab:hover:not(.on) { color: var(--text-secondary); }

.tab-panel { display: none; }
.tab-panel.on { display: block; animation: fadeUp 0.2s ease; }

/* ---- Table ---- */
.tbl-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.tbl th, .tbl td {
    padding: 10px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.tbl th {
    font-weight: 700;
    color: var(--text-faint);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--bg-input); }

/* ---- Login ---- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
}

.login-box { width: 100%; max-width: 360px; }

/* ---- Utilities ---- */
.tc { text-align: center; }
.tr { text-align: right; }
.mono { font-family: 'Courier New', monospace; }
.accent { color: var(--accent); }
.muted { color: var(--text-secondary); }
.faint { color: var(--text-faint); }
.c-ok { color: var(--success); }
.c-warn { color: var(--warning); }
.c-err { color: var(--danger); }
.bold { font-weight: 700; }
.xbold { font-weight: 800; }
.small { font-size: 12px; }
.xs { font-size: 11px; }
.lg { font-size: 16px; }
.xl { font-size: 20px; }

.mt0 { margin-top: 0; }
.mt1 { margin-top: 6px; }
.mt2 { margin-top: 12px; }
.mt3 { margin-top: 18px; }
.mt4 { margin-top: 24px; }
.mb0 { margin-bottom: 0; }
.mb1 { margin-bottom: 6px; }
.mb2 { margin-bottom: 12px; }
.mb3 { margin-bottom: 18px; }
.mb4 { margin-bottom: 24px; }
.mx-auto { margin-left: auto; margin-right: auto; }
.pt2 { padding-top: 12px; }
.pt4 { padding-top: 24px; }

.flex { display: flex; }
.between { display: flex; justify-content: space-between; align-items: center; }
.items-center { align-items: center; }
.wrap { flex-wrap: wrap; }
.col { flex-direction: column; }
.gap1 { gap: 6px; }
.gap2 { gap: 10px; }
.gap3 { gap: 14px; }

.w-full { width: 100%; }
.hide { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 440px) {
    .page-body { padding: 12px 16px 28px; }
    .page-head { padding: 16px 16px 0; }
    .steps { padding: 10px 16px 0; }
    .pay-list { gap: 6px; }
}

@media (min-width: 640px) {
    .pay-list { grid-template-columns: repeat(3, 1fr); }
}

@media print {
    body { background: #fff; color: #000; }
    .page-head, .steps, .btn, .theme-toggle { display: none; }
    .card { border: 1px solid #ccc; background: #fff; }
    .voucher { border-color: #000; }
    .voucher .cred { color: #000; }
}
