/* ==========================================================================
   xvoucha styles
   ========================================================================== */
:root {
    --primary: #e0392b;
    --primary-dark: #b7281c;
    --ink: #1c2333;
    --muted: #6b7280;
    --bg: #f5f6fa;
    --card: #ffffff;
    --line: #e5e7eb;
    --accent: #1f6feb;
    --ok: #16a34a;
    --warn: #d97706;
    --err: #dc2626;
    --radius: 12px;
    --shadow: 0 6px 24px rgba(20, 25, 40, .08);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    line-height: 1.5;
}

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; }
p { margin: 0 0 .8em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f1f3f7; padding: 2px 6px; border-radius: 6px; font-size: .95em; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

.btn {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, transform .05s;
    font-family: var(--font);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: #eef0f4; color: var(--ink); }
.btn-secondary:hover { background: #e2e5eb; text-decoration: none; }
.btn-danger { background: #fef2f2; color: var(--err); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-small { padding: 5px 12px; font-size: 12px; }
.btn-block { display: block; width: 100%; }

/* ==========================================================================
   Portal
   ========================================================================== */
body.portal { background: #fbfbfd; }

.portal-header {
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 50;
}
.portal-header .container {
    display: flex; align-items: center; justify-content: space-between;
    padding-top: 12px; padding-bottom: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--primary); }
.brand-logo { height: 34px; max-width: 180px; object-fit: contain; }
.brand-logo-lg { height: 56px; max-width: 200px; margin: 0 auto 10px; display: block; }

.report-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.report-stats .stat { background: #f8f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 14px; text-align: center; }
.report-stats .stat-label { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; }
.report-stats .stat-value { display: block; font-size: 22px; font-weight: 800; color: var(--ink); }
.report-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.report-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.report-cards .voucher-card { background: #f6f7fb; border: 1px dashed #3a6ef4; border-radius: 10px; padding: 14px; }
.report-cards .voucher-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: #3a6ef4; border-bottom: 1px solid #e3e7f3; padding-bottom: 8px; margin-bottom: 10px; }
.report-cards .voucher-card-head .small { font-weight: 600; color: #6b7280; text-transform: none; }
.report-cards .voucher-field { margin-bottom: 8px; }
.report-cards .voucher-code { font-size: 16px; user-select: all; }
.report-cards .voucher-meta { font-size: 12px; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: .3px; }
.portal-nav a { margin-left: 22px; color: var(--muted); font-weight: 600; }
.portal-nav a:hover { color: var(--ink); }

.hero {
    background: linear-gradient(135deg, #1c2333 0%, #2c3a55 100%);
    color: #fff;
    text-align: center;
    padding: 64px 0 56px;
}
.hero h1 { font-size: 34px; margin-bottom: 12px; }
.hero p { color: #cfd6e4; max-width: 620px; margin: 0 auto 22px; }
.hero p strong { color: #fff; }
.momo-logos { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.momo-logos span {
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 999px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
}

.section-title { font-size: 22px; margin: 44px 0 20px; text-align: center; }

.package-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}
.package-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px 20px;
    box-shadow: var(--shadow);
    display: flex; flex-direction: column;
    transition: transform .15s, border-color .15s;
}
.package-card:hover { transform: translateY(-3px); border-color: var(--primary); }
.package-card h3 { font-size: 17px; }
.package-card .price {
    font-size: 26px; font-weight: 800; color: var(--primary); margin: 6px 0 12px;
}
.features { list-style: none; padding: 0; margin: 0 0 18px; flex: 1; color: var(--muted); font-size: 14px; }
.features li { padding: 4px 0; border-bottom: 1px dashed var(--line); }
.features li:last-child { border-bottom: none; }
.features li::before { content: "•  "; color: var(--primary); font-weight: 800; }

.lookup { padding-bottom: 40px; }
.lookup .section-title { margin-top: 24px; }
.inline-form { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.inline-form input[type=tel] {
    padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px;
    font-size: 15px; min-width: 240px;
}
.lookup-table {
    width: 100%; margin-top: 18px; border-collapse: collapse; background: #fff;
    border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.lookup-table th, .lookup-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
.lookup-table th { background: #f8f9fb; }
.form-error { color: var(--err); font-weight: 600; }

.portal-footer {
    border-top: 1px solid var(--line); background: #fff;
    text-align: center; padding: 22px 0; color: var(--muted); font-size: 13px;
}

/* ---- Modal ---- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(15, 20, 35, .6);
    display: flex; align-items: center; justify-content: center; z-index: 100;
    padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
body.modal-open { overflow: hidden; }
.modal {
    background: #fff; border-radius: 16px; max-width: 440px; width: 100%;
    padding: 28px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.3);
    max-height: 90vh; overflow-y: auto;
}
.modal-close {
    position: absolute; top: 12px; right: 14px; background: none; border: none;
    font-size: 24px; color: var(--muted); cursor: pointer; line-height: 1;
}
.modal h3 { margin-bottom: 6px; }
.modal .muted { margin-bottom: 16px; }
.modal label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
.modal input[type=tel], .modal input[type=text], .modal select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line);
    border-radius: 8px; font-size: 15px;
}
.form-note { font-size: 12.5px; color: var(--muted); margin: 10px 0; }
#pay-btn { margin-top: 8px; }

.spinner {
    width: 44px; height: 44px; border: 4px solid #f0f0f4; border-top-color: var(--primary);
    border-radius: 50%; margin: 8px auto 18px; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.success-icon {
    width: 56px; height: 56px; border-radius: 50%; background: var(--ok); color: #fff;
    font-size: 28px; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px;
}
.error-icon {
    width: 56px; height: 56px; border-radius: 50%; background: var(--err); color: #fff;
    font-size: 26px; display: flex; align-items: center; justify-content: center; margin: 0 auto 14px;
}

.voucher-box {
    background: #f6f7fb; border: 1px dashed var(--primary); border-radius: 10px;
    padding: 14px; margin: 6px 0 16px;
}
.voucher-field { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.voucher-label { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); width: 90px; }
.voucher-code { font-weight: 800; font-size: 18px; letter-spacing: 1px; flex: 1; }
.voucher-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); flex-wrap: wrap; gap: 6px; }

/* ==========================================================================
   Admin
   ========================================================================== */
.admin-wrap { display: flex; min-height: 100vh; }

.sidebar {
    width: 230px; background: #161b28; color: #cbd2e0; flex-shrink: 0;
    display: flex; flex-direction: column;
}
.sidebar .brand { padding: 20px 20px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand-name { color: #fff; }
.sidebar nav { flex: 1; padding: 12px 0; }
.sidebar nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 20px; color: #cbd2e0; font-size: 14px; font-weight: 600;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,.05); text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,.08); border-left-color: var(--primary); color: #fff; }
.sidebar nav a .nav-badge {
    margin-left: auto; background: #e11d48; color: #fff; font-size: 11px; font-weight: 700;
    padding: 1px 7px; border-radius: 999px; line-height: 16px;
}
.sidebar .side-foot { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.sidebar .side-foot a { color: #ff8f85; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    background: #fff; border-bottom: 1px solid var(--line);
    padding: 14px 24px; display: flex; align-items: center; justify-content: space-between;
}
.topbar h1 { font-size: 18px; margin: 0; }
.admin-content { padding: 24px; }

.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px; margin-bottom: 22px;
}
.card h2 { font-size: 16px; margin-bottom: 14px; }
.card h3 { font-size: 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow);
}
.stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; }
.stat .value { font-size: 26px; font-weight: 800; margin-top: 4px; }
.stat .sub { font-size: 12.5px; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table.data {
    width: 100%; border-collapse: collapse; background: #fff; font-size: 14px;
}
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { background: #f8f9fb; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
table.data tr:hover td { background: #fafbfd; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-ok, .badge-unused, .badge-paid { background: #dcfce7; color: #15803d; }
.badge-warn, .badge-pending, .badge-used { background: #fef3c7; color: #b45309; }
.badge-err, .badge-disabled, .badge-failed { background: #fee2e2; color: #b91c1c; }
.badge-info, .badge-expired, .badge-abandoned { background: #e0e7ff; color: #4338ca; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
label.f { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
input.t, select.t, textarea.t {
    width: 100%; padding: 9px 12px; border: 1px solid var(--line);
    border-radius: 8px; font-size: 14px; font-family: var(--font);
}
input.t:focus, select.t:focus, textarea.t:focus { outline: 2px solid #d6e4ff; border-color: var(--accent); }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; font-weight: 600; }
.flash-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.flash-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.flash-info { background: #e0e7ff; color: #4338ca; border: 1px solid #c7d2fe; }

/* Admin / company login */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(1100px 500px at 85% -10%, rgba(255,255,255,.07), transparent 60%),
        linear-gradient(135deg, #141a28, #26344d);
    padding: 20px;
}
.login-card {
    background: #fff; border-radius: 18px; width: 100%; max-width: 860px;
    display: flex; overflow: hidden;
    box-shadow: 0 24px 70px rgba(0,0,0,.4);
}
.login-side {
    flex: 0 0 42%; background: linear-gradient(160deg, #1d2740, #2e3f5e 55%, #395078);
    color: #fff; padding: 40px 32px; display: flex; flex-direction: column; justify-content: space-between;
}
.login-side .brand { margin: 0 0 4px; }
.login-side .brand-dot { background: #ff5a4a; }
.login-side .brand-name { color: #fff; font-size: 22px; }
.login-side h2 { color: #fff; font-size: 21px; margin: 6px 0 8px; line-height: 1.3; }
.login-side p { color: #c3cde3; font-size: 13.5px; line-height: 1.6; margin: 0; }
.login-side ul.features { list-style: none; margin: 20px 0 0; padding: 0; font-size: 13px; color: #d5dcee; }
.login-side ul.features li { display: flex; gap: 9px; align-items: center; padding: 5px 0; }
.login-side ul.features li::before { content: "\2713"; color: #7ed494; font-weight: 700; flex: 0 0 auto; }
.login-side .side-foot { margin-top: 28px; font-size: 12px; color: #8fa0bd; }
.login-main { flex: 1 1 58%; padding: 40px 36px; display: flex; flex-direction: column; justify-content: center; }
.login-title { font-size: 21px; margin: 0 0 4px; }
.login-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }
.login-card .field { margin-bottom: 14px; }
@media (max-width: 700px) { .login-card { max-width: 400px; } .login-side { display: none; } }

/* Password visibility toggle */
.pw-wrap { position: relative; }
.pw-wrap .t { padding-right: 46px; width: 100%; }
.pw-toggle {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    border: 0; background: transparent; color: var(--muted); cursor: pointer;
    padding: 7px; border-radius: 8px; line-height: 0;
}
.pw-toggle:hover { color: var(--ink); background: var(--bg); }
.login-remember { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.login-footer { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; font-size: 13px; color: var(--muted); }

.panel-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-actions form { margin: 0; }

.install-body { max-width: 640px; margin: 40px auto; }
.step { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 22px; margin-bottom: 16px; }
.step h2 { font-size: 17px; }
.check-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.check-row .ok { color: var(--ok); font-weight: 700; }
.check-row .bad { color: var(--err); font-weight: 700; }

@media (max-width: 760px) {
    .admin-wrap { flex-direction: column; }
    .sidebar { width: 100%; }
    .sidebar nav { display: flex; flex-wrap: wrap; padding: 6px; }
    .sidebar nav a { border-left: none; border-bottom: 2px solid transparent; padding: 9px 12px; }
    .sidebar nav a.active { border-bottom-color: var(--primary); }
    .form-grid { grid-template-columns: 1fr; }
    .hero h1 { font-size: 26px; }
}

/* Print: hide screen-only helpers so voucher sheets print cleanly */
@media print {
    .no-print { display: none !important; }
    .voucher-box { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
