/* ==========================================================================
   SIRENA — Agent Membership Management
   Theme tokens (design screenshots ke purple gradient se derive kiye gaye)
   ========================================================================== */
:root {
    --brand-900: #2B1B69;
    --brand-700: #4B21C9;
    --brand-600: #6C3CE9;
    --brand-500: #7B4BF0;
    --brand-300: #B8A2FA;
    --brand-050: #F1EDFE;

    --ink-900: #171233;
    --ink-600: #5A5578;
    --ink-400: #8E89A8;
    --line: #E7E4F2;
    --surface: #FFFFFF;
    --canvas: #F6F5FC;

    --ok: #16A34A;
    --ok-bg: #E7F7EC;
    --warn: #E08A00;
    --warn-bg: #FDF2DC;
    --danger: #DC2626;
    --danger-bg: #FDEAEA;
    --muted: #6B7280;
    --muted-bg: #EEF0F4;

    --radius: 16px;
    --radius-sm: 12px;
    --shadow: 0 6px 24px rgba(43, 27, 105, .08);
    --shadow-lg: 0 12px 36px rgba(43, 27, 105, .16);
    --gradient: linear-gradient(135deg, var(--brand-600) 0%, var(--brand-700) 100%);
}

* { -webkit-tap-highlight-color: transparent; }

body {
    background: var(--canvas);
    color: var(--ink-900);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    margin: 0;
    padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); }

/* ---------- Layout shells ---------- */
.app-shell { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--canvas); position: relative; }
.app-shell--wide { max-width: 1180px; }

.app-header {
    background: var(--gradient);
    color: #fff;
    padding: 18px 18px 46px;
    border-radius: 0 0 26px 26px;
}
.app-header .greet { font-size: 13px; opacity: .82; margin: 0; }
.app-header .who { font-size: 19px; font-weight: 700; margin: 2px 0 0; }
.app-header .agent-code { font-size: 12px; opacity: .8; }

.app-body { padding: 0 16px 96px; }
.app-body--pulled { margin-top: -34px; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; background: var(--gradient); display: flex; flex-direction: column; }
.auth-hero { color: #fff; text-align: center; padding: 46px 24px 26px; }
.auth-hero .logo-badge {
    width: 74px; height: 74px; border-radius: 24px; margin: 0 auto 14px;
    background: rgba(255, 255, 255, .16); display: grid; place-items: center;
    font-size: 30px; font-weight: 800; letter-spacing: 1px;
    border: 1px solid rgba(255, 255, 255, .28);
}
.auth-hero h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: .5px; }
.auth-hero p { margin: 6px 0 0; font-size: 13px; opacity: .85; }

.auth-card {
    background: var(--surface);
    border-radius: 26px 26px 0 0;
    padding: 26px 20px 40px;
    flex: 1;
    box-shadow: var(--shadow-lg);
}
.auth-card .section-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-600); margin-bottom: 6px; }
.field .req { color: var(--danger); }

.input, .select, textarea.input {
    width: 100%;
    border: 1px solid var(--line);
    background: #FBFAFF;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 14px;
    color: var(--ink-900);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    box-sizing: border-box;
}
.input:focus, .select:focus, textarea.input:focus {
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px rgba(108, 60, 233, .14);
    background: #fff;
}
.input::placeholder { color: var(--ink-400); }
.input.is-invalid { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12px; margin-top: 5px; }

.input-group { position: relative; }
.input-group .toggle-pass {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    background: none; border: 0; color: var(--ink-400); cursor: pointer; font-size: 13px;
}

.check-row { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 18px; font-size: 13px; }
.check-row label { display: flex; align-items: center; gap: 7px; color: var(--ink-600); margin: 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; border: 0; cursor: pointer;
    padding: 13px 18px; border-radius: var(--radius-sm);
    font-size: 15px; font-weight: 600; letter-spacing: .3px;
    transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--gradient); color: #fff; box-shadow: 0 8px 18px rgba(108, 60, 233, .28); }
.btn-primary:hover { color: #fff; box-shadow: 0 10px 22px rgba(108, 60, 233, .36); }
.btn-outline { background: #fff; color: var(--brand-600); border: 1.5px solid var(--brand-300); }
.btn-ghost { background: var(--brand-050); color: var(--brand-700); }
.btn-sm { padding: 9px 14px; font-size: 13px; width: auto; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--ink-400); font-size: 12px; margin: 18px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* ---------- Cards ---------- */
.card-soft {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 14px;
}
.card-title { font-size: 14px; font-weight: 700; margin: 0 0 12px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 20px 2px 10px; }
.section-head h2 { font-size: 15px; font-weight: 700; margin: 0; }
.section-head a { font-size: 13px; font-weight: 600; }

/* ---------- Stat tiles (dashboard) ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat {
    background: var(--surface); border-radius: var(--radius); padding: 14px;
    box-shadow: var(--shadow); display: flex; align-items: center; gap: 12px;
}
.stat .icon {
    width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
    font-size: 18px; flex: 0 0 auto;
}
.stat .value { font-size: 20px; font-weight: 800; line-height: 1.1; }
.stat .label { font-size: 12px; color: var(--ink-400); }
.icon-brand { background: var(--brand-050); color: var(--brand-600); }
.icon-ok { background: var(--ok-bg); color: var(--ok); }
.icon-warn { background: var(--warn-bg); color: var(--warn); }
.icon-danger { background: var(--danger-bg); color: var(--danger); }

.revenue-card {
    background: var(--gradient); color: #fff; border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow-lg); margin-bottom: 14px;
}
.revenue-card .label { font-size: 12px; opacity: .82; }
.revenue-card .amount { font-size: 26px; font-weight: 800; margin-top: 4px; }

/* ---------- Quick actions ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick {
    background: var(--surface); border-radius: var(--radius-sm); padding: 12px 6px;
    text-align: center; box-shadow: var(--shadow); color: var(--ink-900); font-size: 11px; font-weight: 600;
}
.quick .ico { font-size: 20px; display: block; margin-bottom: 6px; color: var(--brand-600); }

/* ---------- Member rows ---------- */
.member-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--line);
}
.member-row:last-child { border-bottom: 0; }
.avatar {
    width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto;
    background: var(--brand-050); color: var(--brand-700);
    display: grid; place-items: center; font-weight: 700; font-size: 14px;
    object-fit: cover;
}
.member-row .meta { flex: 1; min-width: 0; }
.member-row .name { font-size: 14px; font-weight: 600; }
.member-row .sub { font-size: 12px; color: var(--ink-400); }

/* ---------- Status badges ---------- */
.badge-status {
    font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
    display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
}
.badge-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-active { background: var(--ok-bg); color: var(--ok); }
.status-expiring { background: var(--warn-bg); color: var(--warn); }
.status-expired { background: var(--danger-bg); color: var(--danger); }
.status-pending, .status-cancelled { background: var(--muted-bg); color: var(--muted); }

/* ---------- Bottom nav ---------- */
.bottom-nav {
    position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
    width: 100%; max-width: 480px;
    background: #fff; border-top: 1px solid var(--line);
    display: flex; justify-content: space-around;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    z-index: 40;
}
.bottom-nav a {
    flex: 1; text-align: center; font-size: 11px; font-weight: 600;
    color: var(--ink-400); padding: 4px 0;
}
.bottom-nav a .ico { display: block; font-size: 19px; margin-bottom: 3px; }
.bottom-nav a.active { color: var(--brand-600); }

/* ---------- Alerts ---------- */
.alert-soft {
    border-radius: var(--radius-sm); padding: 12px 14px; font-size: 13px;
    margin-bottom: 14px; border: 1px solid transparent;
}
.alert-ok { background: var(--ok-bg); color: #14532D; border-color: #BBE7C8; }
.alert-err { background: var(--danger-bg); color: #7F1D1D; border-color: #F4C2C2; }

.empty-state { text-align: center; padding: 30px 12px; color: var(--ink-400); font-size: 13px; }
.empty-state .ico { font-size: 30px; color: var(--brand-300); display: block; margin-bottom: 8px; }

/* ---------- Admin (desktop) ---------- */
.admin-layout { display: flex; min-height: 100vh; }
.admin-side {
    width: 240px; background: var(--brand-900); color: #fff; padding: 20px 14px;
    position: sticky; top: 0; height: 100vh; flex: 0 0 auto;
}
.admin-side .brand { font-size: 20px; font-weight: 800; letter-spacing: 1px; margin-bottom: 24px; padding-left: 8px; }
.admin-side a {
    display: flex; align-items: center; gap: 10px; color: rgba(255, 255, 255, .74);
    padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-bottom: 4px;
}
.admin-side a.active, .admin-side a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.admin-main { flex: 1; padding: 22px 26px 40px; min-width: 0; }
.admin-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.admin-topbar h1 { font-size: 20px; font-weight: 700; margin: 0; }
.stat-grid--4 { grid-template-columns: repeat(4, 1fr); }

.table-soft { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-soft th {
    text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
    color: var(--ink-400); padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.table-soft td { padding: 12px; border-bottom: 1px solid var(--line); }
.table-soft tr:last-child td { border-bottom: 0; }

@media (max-width: 991px) {
    .admin-side { display: none; }
    .admin-main { padding: 16px; }
    .stat-grid--4 { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
