/* ─── Variables ─────────────────────────────────────────────────────────────── */

:root {
    --bg-primary: #f4f5f7;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #f8f8f8;
    --red: #c41e3a;
    --red-dark: #a31830;
    --red-light: rgba(196, 30, 58, 0.08);
    --blue: #1e40af;
    --blue-light: rgba(30, 64, 175, 0.08);
    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --text-muted: #999999;
    --border: #e2e4e8;
    --border-light: #f0f0f0;
    --radius: 6px;
    --radius-lg: 10px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);

    --status-active: #16a34a;
    --status-active-bg: rgba(22, 163, 74, 0.1);
    --status-inactive: #6b7280;
    --status-inactive-bg: rgba(107, 114, 128, 0.1);
    --status-pending: #d97706;
    --status-pending-bg: rgba(217, 119, 6, 0.1);
}

/* ─── Reset / Base ─────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main { flex: 1; }

a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-dark); }

img { max-width: 100%; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ─── Header ───────────────────────────────────────────────────────────────── */

.site-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    text-decoration: none;
    display: flex;
    align-items: center;
}

.logo-img {
    height: 52px;
    width: auto;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-links-desktop {
    display: flex;
    gap: 2px;
    margin-right: 12px;
}

.nav-link {
    color: var(--text-secondary);
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 400;
    transition: all 0.15s;
    text-decoration: none;
}

.nav-link:hover { color: var(--text-primary); background: var(--bg-primary); }
.nav-link.active { color: var(--red); background: var(--red-light); font-weight: 500; }

.nav-user {
    color: var(--text-secondary);
    font-size: 13px;
    margin-right: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color 0.15s;
}

.nav-user:hover { color: var(--text-primary); }

.nav-btn {
    padding: 7px 16px;
    border-radius: var(--radius);
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.nav-btn--accent {
    background: var(--red);
    color: #fff;
}
.nav-btn--accent:hover { background: var(--red-dark); }

.nav-btn--ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.nav-btn--ghost:hover { background: var(--bg-primary); color: var(--text-primary); }

/* Hamburger */
.nav-hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
}
.nav-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.2s;
}

.nav-accordion {
    display: none;
    flex-direction: column;
    background: #fff;
    border-top: 1px solid var(--border);
}
.nav-accordion.open { display: flex; }

.nav-accordion-link {
    color: var(--text-secondary);
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
    text-decoration: none;
}
.nav-accordion-link:hover { color: var(--text-primary); background: var(--bg-primary); }
.nav-accordion-link.active { color: var(--red); font-weight: 500; }

/* ─── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius);
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); color: #fff; }

.btn-secondary { background: var(--blue); color: #fff; }
.btn-secondary:hover { background: #1a35a0; color: #fff; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-primary); color: var(--text-primary); }

.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ─── Forms ────────────────────────────────────────────────────────────────── */

.form-field { margin-bottom: 14px; }

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-input);
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-light);
    background: #fff;
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-error {
    color: #dc2626;
    font-size: 12px;
    margin-top: 4px;
    min-height: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ─── Cards / Panels ────────────────────────────────────────────────────────── */

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body { padding: 20px; }

/* ─── Table ────────────────────────────────────────────────────────────────── */

.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--bg-card);
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 14px;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
    cursor: pointer;
    transition: background 0.1s;
}
tbody tr:hover { background: var(--red-light); }

.td-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.td-avatar {
    width: 44px;
    padding-right: 4px;
    vertical-align: middle;
}

/* ─── Status badges ─────────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-active   { background: var(--status-active-bg);   color: var(--status-active); }
.badge-inactive { background: var(--status-inactive-bg); color: var(--status-inactive); }
.badge-pending  { background: var(--status-pending-bg);  color: var(--status-pending); }

/* ─── Page layout ───────────────────────────────────────────────────────────── */

.page-section {
    padding: 28px 0;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ─── Search / Filter bar ───────────────────────────────────────────────────── */

.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-bar .form-input,
.filter-bar .form-select {
    max-width: 220px;
    background: #fff;
}

/* ─── Slide panel ───────────────────────────────────────────────────────────── */

.panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 200;
    display: none;
    align-items: stretch;
    justify-content: flex-end;
}

.panel-overlay.open { display: flex; }

.panel {
    width: 420px;
    max-width: 100vw;
    background: #fff;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    animation: slideIn 0.2s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
}

.panel-title {
    font-size: 15px;
    font-weight: 600;
}

.panel-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 2px 6px;
    border-radius: var(--radius);
    transition: all 0.1s;
}
.panel-close:hover { background: var(--border); color: var(--text-primary); }

.panel-body {
    padding: 22px;
    flex: 1;
}

.panel-footer {
    padding: 16px 22px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    background: var(--bg-primary);
}

/* ─── Modal ─────────────────────────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    padding: 28px;
    position: relative;
}

.modal-logo { text-align: center; }

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-primary);
    text-align: center;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

/* ─── Hero (landing page) ────────────────────────────────────────────────────── */

.hero {
    background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 60%, #7a0d1e 100%);
    min-height: calc(100vh - 64px);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-icon {
    font-size: 64px;
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.9);
}

.hero-title {
    font-size: 40px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 12px;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 17px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 32px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.hero-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    color: var(--red);
    padding: 13px 30px;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.hero-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

/* ─── Empty state ────────────────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ─── Toast / banner ─────────────────────────────────────────────────────────── */

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.2s ease;
    max-width: 360px;
}

.toast-success { background: #16a34a; color: #fff; }
.toast-error   { background: #dc2626; color: #fff; }

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

/* ─── Expiry warning ─────────────────────────────────────────────────────────── */

.td-expired { color: #dc2626; font-weight: 500; }
.td-expiring-soon { color: var(--status-pending); font-weight: 500; }

/* ─── Divider ────────────────────────────────────────────────────────────────── */

.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* ─── Footer ────────────────────────────────────────────────────────────────── */

.site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 16px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .nav-links-desktop { display: none; }
    .nav-hamburger { display: flex; }

    .form-row { grid-template-columns: 1fr; }

    .page-header { flex-direction: column; align-items: flex-start; }

    .panel { width: 100%; }

    .hero-title { font-size: 28px; }
    .hero-subtitle { font-size: 15px; }

    thead th:nth-child(9), tbody td:nth-child(9),
    thead th:nth-child(8), tbody td:nth-child(8),
    thead th:nth-child(6), tbody td:nth-child(6),
    thead th:nth-child(7), tbody td:nth-child(7) { display: none; }
}

@media (max-width: 480px) {
    .container { padding: 0 14px; }
    .filter-bar .form-input,
    .filter-bar .form-select { max-width: 100%; }
}
