/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:     #1e5aa0;
    --primary-dk:  #163f72;
    --primary-lt:  #e8f0fb;
    --success:     #1a7a4a;
    --success-lt:  #d4f4e3;
    --danger:      #b91c1c;
    --danger-lt:   #fde8e8;
    --warning:     #92400e;
    --warning-lt:  #fef3c7;
    --gray-50:     #f9fafb;
    --gray-100:    #f3f4f6;
    --gray-200:    #e5e7eb;
    --gray-400:    #9ca3af;
    --gray-600:    #4b5563;
    --gray-800:    #1f2937;
    --radius:      8px;
    --shadow:      0 1px 4px rgba(0,0,0,.10);
    --shadow-md:   0 4px 16px rgba(0,0,0,.12);
    --font:        'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
    font-family: var(--font);
    font-size: 15px;
    color: var(--gray-800);
    background: var(--gray-50);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: 'Cascadia Code', 'Fira Mono', monospace; font-size: 0.875em; }

/* ── Navbar ───────────────────────────────────────────────────────────────── */
.navbar {
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.navbar-brand { font-weight: 700; font-size: 1.1rem; letter-spacing: .02em; }
.navbar-links { display: flex; align-items: center; gap: 20px; }
.navbar-links a { color: rgba(255,255,255,.88); font-size: .9rem; }
.navbar-links a:hover { color: #fff; text-decoration: none; }

/* ── Main / Footer ────────────────────────────────────────────────────────── */
.main-content { flex: 1; padding: 32px 24px; max-width: 1100px; width: 100%; margin: 0 auto; }
.footer { text-align: center; padding: 16px; font-size: .8rem; color: var(--gray-400); border-top: 1px solid var(--gray-200); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 18px; border-radius: var(--radius);
    font-size: .9rem; font-weight: 500; cursor: pointer;
    border: 1.5px solid transparent; transition: all .15s;
    text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.07); }
.btn-primary    { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-secondary  { background: var(--gray-600); color: #fff; border-color: var(--gray-600); }
.btn-outline    { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary-lt); }
.btn-link       { background: none; border: none; color: rgba(255,255,255,.88); font-size: .9rem; cursor: pointer; }
.btn-link:hover { color: #fff; }
.btn-full       { width: 100%; justify-content: center; }
.btn-sm         { padding: 5px 12px; font-size: .82rem; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; font-size: .9rem; }
.alert-success { background: var(--success-lt); color: var(--success); border: 1px solid #86efac; }
.alert-error   { background: var(--danger-lt);  color: var(--danger);  border: 1px solid #fca5a5; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
    background: #fff; border-radius: var(--radius);
    border: 1px solid var(--gray-200); padding: 24px;
    box-shadow: var(--shadow);
}
.card-title    { font-size: 1rem; font-weight: 600; margin-bottom: 16px; color: var(--gray-800); }
.card-subtitle { font-size: .9rem; font-weight: 600; margin-bottom: 10px; color: var(--gray-600); }
.card-desc     { font-size: .875rem; color: var(--gray-600); margin-bottom: 16px; }
.card-full     { grid-column: 1 / -1; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group   { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 500; font-size: .875rem; margin-bottom: 6px; color: var(--gray-600); }
.form-control {
    width: 100%; padding: 9px 12px; border: 1.5px solid var(--gray-200);
    border-radius: var(--radius); font-size: .9rem; font-family: var(--font);
    transition: border-color .15s; background: #fff;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,90,160,.12); }
.form-row       { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-compact { display: flex; gap: 10px; align-items: center; }
.form-row-compact .form-control { flex: 1; }
.form-actions   { display: flex; gap: 12px; justify-content: flex-end; padding-top: 8px; }
.form-card      { max-width: 560px; }
.field-error    { color: var(--danger); font-size: .8rem; display: block; margin-top: 4px; }
.field-hint     { color: var(--gray-400); font-size: .78rem; display: block; margin-top: 4px; }

/* ── Auth ─────────────────────────────────────────────────────────────────── */
.auth-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card      { background: #fff; border-radius: 12px; padding: 40px; width: 100%; max-width: 400px; box-shadow: var(--shadow-md); border: 1px solid var(--gray-200); }
.auth-logo      { font-size: 2.5rem; text-align: center; margin-bottom: 8px; }
.auth-title     { text-align: center; font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.auth-subtitle  { text-align: center; color: var(--gray-400); font-size: .875rem; margin-bottom: 28px; }

/* ── Page Header ──────────────────────────────────────────────────────────── */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--gray-200);
}
.page-header h1 { font-size: 1.4rem; font-weight: 700; }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-container  { background: #fff; border-radius: var(--radius); border: 1px solid var(--gray-200); overflow: hidden; box-shadow: var(--shadow); }
.data-table       { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table thead { background: var(--gray-50); border-bottom: 2px solid var(--gray-200); }
.data-table th    { padding: 12px 16px; text-align: left; font-weight: 600; color: var(--gray-600); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.data-table td    { padding: 13px 16px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-50); }
.actions          { display: flex; gap: 8px; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge        { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge-green  { background: var(--success-lt); color: var(--success); }
.badge-red    { background: var(--danger-lt);  color: var(--danger); }
.badge-blue   { background: var(--primary-lt); color: var(--primary); }

/* ── Detail Grid ──────────────────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; font-size: .9rem; }
.detail-list dt { font-weight: 500; color: var(--gray-600); white-space: nowrap; }
.detail-list dd { color: var(--gray-800); }
.key-code     { background: var(--gray-100); padding: 3px 8px; border-radius: 4px; font-size: .95em; letter-spacing: .08em; }
.divider      { border: none; border-top: 1px solid var(--gray-200); margin: 20px 0; }

/* ── Uses Bar ─────────────────────────────────────────────────────────────── */
.uses-display   { text-align: center; padding: 12px 0; }
.uses-remaining { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.uses-number    { font-size: 3rem; font-weight: 800; color: var(--primary); line-height: 1; }
.uses-number.uses-zero { color: var(--danger); }
.uses-label     { font-size: .8rem; color: var(--gray-400); text-transform: uppercase; letter-spacing: .06em; }
.uses-total     { font-size: .85rem; color: var(--gray-400); margin: 6px 0 12px; }
.uses-bar       { height: 8px; background: var(--gray-100); border-radius: 999px; overflow: hidden; }
.uses-bar-fill  { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }

/* ── URL Display ──────────────────────────────────────────────────────────── */
.url-display  { display: flex; align-items: center; gap: 12px; background: var(--gray-100); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; overflow: hidden; }
.url-display code { flex: 1; word-break: break-all; font-size: .82rem; }
.link-actions { display: flex; gap: 12px; }

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 64px 24px; }
.empty-icon  { font-size: 3rem; margin-bottom: 12px; }
.empty-state h2 { margin-bottom: 8px; }
.empty-state p  { color: var(--gray-400); margin-bottom: 20px; }

/* ── Coupon Page ──────────────────────────────────────────────────────────── */
.coupon-page   { max-width: 480px; margin: 0 auto; }

.coupon-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-dk));
    color: #fff; border-radius: 16px; padding: 24px;
    box-shadow: 0 8px 32px rgba(30,90,160,.35);
    margin-bottom: 32px;
}
.coupon-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.coupon-brand  { font-size: .85rem; opacity: .8; font-weight: 500; }
.coupon-discount { font-size: 2rem; font-weight: 900; letter-spacing: -.02em; }

.coupon-body   { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.coupon-name   { font-size: 1.2rem; font-weight: 700; margin-bottom: 4px; }
.coupon-phone  { font-size: .875rem; opacity: .75; margin-bottom: 8px; }
.coupon-uses   { font-size: .82rem; background: rgba(255,255,255,.18); padding: 4px 10px; border-radius: 999px; display: inline-block; }

.qr-image      { width: 110px; height: 110px; border-radius: 8px; background: #fff; padding: 6px; }

.coupon-key    { margin-top: 16px; font-size: .75rem; opacity: .55; letter-spacing: .08em; text-align: right; }

/* ── Wallet Section ───────────────────────────────────────────────────────── */
.wallet-section { text-align: center; }
.wallet-section h2 { margin-bottom: 8px; font-size: 1.1rem; }
.wallet-section p  { color: var(--gray-600); font-size: .875rem; margin-bottom: 24px; }

.wallet-buttons { display: flex; flex-direction: column; gap: 14px; align-items: center; margin-bottom: 28px; }
.wallet-btn      { display: block; }
.wallet-btn-img  { height: 52px; width: auto; display: block; }
.wallet-btn-img-disabled { opacity: .4; filter: grayscale(1); }
.wallet-btn-disabled { text-align: center; }
.wallet-note     { display: block; font-size: .75rem; color: var(--gray-400); margin-top: 6px; }

.wallet-help     { text-align: left; border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: hidden; }
.wallet-help details { border-bottom: 1px solid var(--gray-200); }
.wallet-help details:last-child { border-bottom: none; }
.wallet-help summary { padding: 12px 16px; font-weight: 500; font-size: .875rem; cursor: pointer; user-select: none; }
.wallet-help summary:hover { background: var(--gray-50); }
.wallet-help ol  { padding: 0 16px 14px 32px; font-size: .85rem; color: var(--gray-600); line-height: 1.7; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 680px) {
    .detail-grid { grid-template-columns: 1fr; }
    .form-row    { grid-template-columns: 1fr; }
    .main-content { padding: 20px 16px; }
    .navbar      { padding: 0 16px; }
    .actions     { flex-wrap: wrap; }
}
