/* CSZDPiZ Public / Portal Styles */
:root {
    --bg: #ffffff;
    --bg-page: #f1f5f9;
    --text: #1e293b;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --border: #e2e8f0;
    --success: #16a34a;
    --error: #dc2626;
    --header-bg: #0f172a;
    --header-text: #f1f5f9;
    --header-muted: #94a3b8;
}

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

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg-page);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Top navbar ---- */
.portal-header {
    background: var(--header-bg);
    border-bottom: 1px solid #1e293b;
    position: sticky;
    top: 0;
    z-index: 100;
}

.portal-header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 8px;
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--header-text);
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
    margin-right: 24px;
    flex-shrink: 0;
}

.portal-brand:hover { text-decoration: none; color: #fff; }
.portal-brand i { font-size: 22px; }

.portal-nav-top {
    display: flex;
    gap: 2px;
    flex: 1;
    overflow-x: auto;
}

.portal-nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--header-muted);
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, color .15s;
}

.portal-nav-link:hover {
    background: rgba(255,255,255,.08);
    color: var(--header-text);
    text-decoration: none;
}

.portal-nav-link.active {
    background: rgba(59,130,246,.2);
    color: #93c5fd;
}

.portal-nav-link i { font-size: 17px; }

.portal-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    flex-shrink: 0;
}

.portal-user-email {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--header-muted);
    font-size: 13px;
}

.portal-user-email i { font-size: 15px; }

.portal-logout {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--header-muted);
    text-decoration: none;
    transition: background .15s, color .15s;
}

.portal-logout:hover {
    background: rgba(248,113,113,.15);
    color: #fca5a5;
    text-decoration: none;
}

.portal-logout i { font-size: 16px; }

/* ---- Main content ---- */
.portal-main {
    flex: 1;
    padding: 32px 20px;
}

.portal-container {
    max-width: 1100px;
    margin: 0 auto;
}

.portal-page-header {
    margin-bottom: 24px;
}

.portal-page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

/* ---- Footer ---- */
.portal-footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* ---- Legacy container (for non-layout pages) ---- */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px;
}

h1 { font-size: 24px; margin-bottom: 16px; }
h2 { font-size: 20px; margin-bottom: 12px; }
h3 { font-size: 16px; margin-bottom: 8px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Cards ---- */
.card {
    background: var(--bg);
    border-radius: 10px;
    border: 1px solid var(--border);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

/* ---- Stat cards ---- */
.portal-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.portal-stat {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.portal-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.portal-stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.portal-stat-icon.green  { background: #dcfce7; color: #16a34a; }
.portal-stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.portal-stat-icon.amber  { background: #fef3c7; color: #d97706; }

.portal-stat-value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
}

.portal-stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background .15s;
}

.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); text-decoration: none; }

/* ---- Tables ---- */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

.table td {
    padding: 10px 12px;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fafc; }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-active    { background: #dcfce7; color: #16a34a; }
.badge-completed { background: #dcfce7; color: #16a34a; }
.badge-trialing  { background: #dbeafe; color: #2563eb; }
.badge-past_due  { background: #fef3c7; color: #d97706; }
.badge-canceled  { background: #f3f4f6; color: #6b7280; }
.badge-expired   { background: #fee2e2; color: #dc2626; }
.badge-revoked   { background: #fee2e2; color: #dc2626; }
.badge-failed    { background: #fee2e2; color: #dc2626; }
.badge-pending   { background: #fef3c7; color: #a16207; }
.badge-paid      { background: #dcfce7; color: #16a34a; }
.badge-open      { background: #dbeafe; color: #2563eb; }

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* ---- Alerts ---- */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert i { font-size: 18px; flex-shrink: 0; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error   { background: #fee2e2; color: #991b1b; }

.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 0;
}

/* ---- Consent toggle cards ---- */
.consent-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 20px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    transition: border-color .15s;
}

.consent-card:hover { border-color: #cbd5e1; }

.consent-card input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    accent-color: var(--accent);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .portal-header-inner { padding: 0 12px; }
    .portal-brand span { display: none; }
    .portal-nav-link span { display: none; }
    .portal-nav-link { padding: 8px; }
    .portal-nav-link i { font-size: 20px; }
    .portal-user-email { display: none; }
    .portal-logout span { display: none; }
    .portal-main { padding: 20px 12px; }
    .portal-stats { grid-template-columns: 1fr 1fr; }
    .table { font-size: 13px; }
    .table th, .table td { padding: 8px 6px; }
}

@media (max-width: 480px) {
    .portal-stats { grid-template-columns: 1fr; }
}
