/* =====================================================
   NETBEGINS CLIENT AREA — STYLESHEET
   The EdVPN admin panel's design — its palette, type and components — with
   the client pages' own pieces after them. The colour tokens are copied from
   the admin panel's navbar.php; keep the two in step.
   ===================================================== */

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

/* Persian pages: Vazirmatn, served from assets/fonts (variable weight, SIL OFL).
   Self-hosted so the panel still looks right where Google Fonts is blocked. */
@font-face {
    font-family: 'Vazirmatn';
    src: url('fonts/Vazirmatn.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg:           #0f1117;
    --surface:      #1a1d27;
    --surface-2:    #242838;
    --border:       #2d3148;
    --accent:       #6c63ff;
    --accent-hover: #5a52e0;
    --accent-dim:   rgba(108, 99, 255, 0.15);
    --accent-glow:  rgba(108, 99, 255, 0.35);
    --text:         #e2e8f0;
    --text-muted:   #64748b;
    --text-dim:     #94a3b8;
    --success:      #22c55e;
    --success-dim:  rgba(34, 197, 94, 0.12);
    --danger:       #ef4444;
    --danger-dim:   rgba(239, 68, 68, 0.12);
    --warning:      #f59e0b;
    --warning-dim:  rgba(245, 158, 11, 0.12);
    --info:         #38bdf8;
    --info-dim:     rgba(56, 189, 248, 0.12);
    --sidebar-w:    220px;
    --topbar-h:     52px;
    --radius:       8px;
    --radius-sm:    5px;
    --font-ui:      'Inter', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', 'Fira Code', monospace;
    --shadow:       0 4px 24px rgba(0, 0, 0, 0.4);
    --transition:   150ms ease;

    /* Chart series. Validated against this theme's surface (#1a1d27):
       lightness band, chroma, colour-blind separation and 3:1 contrast. */
    --chart-download: #6366f1;
    --chart-upload:   #0ea5c4;
}

[data-theme="light"] {
    --bg:           #f0f7f0;
    --surface:      #ffffff;
    --surface-2:    #e8f5e8;
    --border:       #c8e6c8;
    --accent:       #2e7d32;
    --accent-hover: #256628;
    --accent-dim:   rgba(46, 125, 50, 0.12);
    --accent-glow:  rgba(46, 125, 50, 0.28);
    --text:         #0d1f0e;
    --text-muted:   #6a8f6b;
    --text-dim:     #2e5230;
    --success:      #1b5e20;
    --success-dim:  rgba(27, 94, 32, 0.13);
    --danger:       #c62828;
    --danger-dim:   rgba(198, 40, 40, 0.10);
    --warning:      #e65100;
    --warning-dim:  rgba(230, 81, 0, 0.10);
    --info:         #01579b;
    --info-dim:     rgba(1, 87, 155, 0.10);
    --shadow:       0 4px 24px rgba(46, 125, 50, 0.10);

    /* Validated against #ffffff. */
    --chart-download: #4f46e5;
    --chart-upload:   #0891b2;
}

html { height: 100%; transition: background-color 200ms ease, color 200ms ease; }

body {
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg);
    min-height: 100%;
    padding-inline-start: var(--sidebar-w);
    padding-top: var(--topbar-h);
}
body.bare { padding: 0; }

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

/* --- Topbar --- */
.topbar {
    position: fixed;
    top: 0; inset-inline-start: var(--sidebar-w); inset-inline-end: 0;
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 24px;
    z-index: 100;
}

.topbar-greeting {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
    white-space: nowrap;
}
.topbar-user {
    color: var(--accent);
    font-family: var(--font-mono);
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-panel {
    margin-inline-start: 4px;
    padding: 1px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 11px;
    color: var(--text-dim);
}

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.topbar-logout {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 1.6;
    cursor: pointer;
    transition: all var(--transition);
}
.topbar-logout:hover {
    background: var(--danger-dim);
    border-color: var(--danger);
    color: var(--danger);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}
.theme-toggle:hover { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { width: 16px; height: 16px; }
/* Language switch: the other language, named in that language. */
.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 11px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
    transition: all var(--transition);
}
.lang-switch:hover { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); text-decoration: none; }
.lang-switch svg { width: 15px; height: 15px; flex-shrink: 0; }
.lang-switch[lang="fa"] { font-family: 'Vazirmatn', Tahoma, sans-serif; font-size: 13px; }
.lang-switch[lang="en"] { font-family: 'Inter', system-ui, sans-serif; }
.lang-short { display: none; }

/* Sign-in and error pages: the switches sit in the top corner. */
.corner-tools {
    position: fixed;
    top: 18px;
    inset-inline-end: 18px;
    display: flex;
    gap: 8px;
    z-index: 10;
}
.corner-tools > * { height: 34px; background: var(--surface); }
.corner-tools .theme-toggle { width: 34px; }

/* --- Brand mark: an "N" stroked in white on the accent square --- */
.brand-mark svg {
    fill: none;
    stroke: #fff;
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0; bottom: 0; inset-inline-start: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-inline-end: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-brand-icon {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar-brand-icon svg { width: 20px; height: 20px; }
.sidebar-brand-name { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.sidebar-brand-sub {
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.sidebar-nav { padding: 12px 0; list-style: none; flex: 1; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-inline-start: 3px solid transparent;
    transition: all var(--transition);
}
.sidebar-nav a svg { width: 15px; height: 15px; opacity: 0.7; flex-shrink: 0; transition: opacity var(--transition); }
.sidebar-nav a:hover {
    color: var(--text);
    background: var(--accent-dim);
    border-inline-start-color: var(--accent);
    text-decoration: none;
}
.sidebar-nav a:hover svg { opacity: 1; }
.sidebar-nav a.active { color: var(--accent); background: var(--accent-dim); border-inline-start-color: var(--accent); }
.sidebar-nav a.active svg { opacity: 1; fill: var(--accent); }

/* --- Page --- */
.page-content { max-width: 1100px; margin: 0 auto; padding: 28px 28px 32px; }

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    margin: 16px 0 4px;
}
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }
.page-note { font-size: 12px; color: var(--text-muted); margin-top: -4px; }

.page-footer {
    margin-top: 40px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
}

/* --- Cards --- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
}
.card-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* --- Stat tiles --- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: inherit;
}
.stat-card.accent { border-top: 2px solid var(--accent); }
.stat-link { transition: border-color var(--transition), background var(--transition); }
.stat-link:hover { text-decoration: none; border-color: var(--accent); }

.stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}
.stat-value {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.1;
}
.stat-value-text { font-family: var(--font-ui); font-size: 20px; letter-spacing: -0.01em; }
.stat-sub { font-size: 12px; color: var(--text-muted); }
.stat-split { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-dim); font-family: var(--font-mono); }
.stat-split span { display: inline-flex; align-items: center; gap: 6px; }

/* Series keys: the colour sits on a mark beside the text, never on the text. */
.key { display: inline-block; width: 10px; height: 3px; border-radius: 2px; }
.key-dl { background: var(--chart-download); }
.key-ul { background: var(--chart-upload); }

/* --- Tables --- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 10px 14px;
    text-align: start;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody td { padding: 9px 14px; color: var(--text-dim); white-space: nowrap; }
td.mono { font-family: var(--font-mono); font-size: 12px; color: var(--text); }
th.num, td.num { text-align: end; font-variant-numeric: tabular-nums; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    transition: all var(--transition);
    line-height: 1.4;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text-dim); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn.disabled { opacity: 0.4; cursor: default; pointer-events: none; }

/* --- Forms --- */
.form-section { max-width: 560px; }
.form-group { margin-bottom: 18px; }

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="email"],
select {
    width: 100%;
    background-color: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    padding: 9px 13px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
    appearance: none;
}
select {
    cursor: pointer;
    padding-inline-end: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2394a3b8'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 18px;
}
[dir="rtl"] select { background-position: left 10px center; }
select option { background: var(--surface-2); color: var(--text); }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
input::placeholder { color: var(--text-muted); }

.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row input { flex: 1; min-width: 0; }
.input-row .btn { min-width: 64px; }
.form-hint { margin-top: 5px; font-size: 12px; color: var(--text-muted); }

/* --- Alerts --- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    line-height: 1.5;
}
.alert-success { background: var(--success-dim); border: 1px solid rgba(34, 197, 94, 0.25);  color: var(--success); }
.alert-danger  { background: var(--danger-dim);  border: 1px solid rgba(239, 68, 68, 0.25);  color: var(--danger);  }
.alert-warning { background: var(--warning-dim); border: 1px solid rgba(245, 158, 11, 0.25); color: var(--warning); }
.alert-info    { background: var(--info-dim);    border: 1px solid rgba(56, 189, 248, 0.25); color: var(--info);    }
.alert-list { margin: 0; padding-inline-start: 18px; }
.alert a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

.card-text { font-size: 13px; color: var(--text-dim); line-height: 1.55; margin-bottom: 16px; }
.card.form-section { scroll-margin-top: calc(var(--topbar-h) + 16px); }

.callout {
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border-inline-start: 3px solid var(--accent);
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.55;
}
.callout strong { color: var(--text); font-weight: 600; }

/* --- Sign-in page --- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 40px;
    width: 100%;
    max-width: 400px;
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand-icon {
    width: 48px; height: 48px;
    background: var(--accent);
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}
.login-brand-icon svg { width: 30px; height: 30px; }
.login-title { font-size: 20px; font-weight: 700; color: var(--text); }
.login-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.login-hint { font-size: 12px; color: var(--text-muted); text-align: center; margin-top: 16px; }
.copy { font-size: 11px; text-align: center; color: var(--text-muted); margin-top: 20px; }

/* --- Utility --- */
.mono { font-family: var(--font-mono); }

/* =====================================================
   CLIENT PAGES
   ===================================================== */

/* --- Subscription: the headline card --- */
.sub-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 24px 40px;
    align-items: center;
    padding: 26px 28px;
}
.sub-hero.state-expired,
.sub-hero.state-suspended { border-color: rgba(239, 68, 68, 0.35); box-shadow: inset 3px 0 0 var(--danger); }
.sub-hero.state-ending { box-shadow: inset 3px 0 0 var(--warning); }
/* The state stripe sits on the reading edge: the right, on Persian pages. */
[dir="rtl"] .sub-hero.state-expired,
[dir="rtl"] .sub-hero.state-suspended { box-shadow: inset -3px 0 0 var(--danger); }
[dir="rtl"] .sub-hero.state-ending { box-shadow: inset -3px 0 0 var(--warning); }

/* The one hero figure on the page: same sans as everything else, proportional digits. */
.hero-figure {
    margin-top: 6px;
    font-size: 56px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.03em;
    color: var(--text);
}
.hero-word { font-size: 40px; }
.hero-unit {
    margin-inline-start: 8px;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--text-muted);
}
.hero-caption { margin-top: 12px; font-size: 13px; color: var(--text-dim); }

.sub-hero-status { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* State pill: a dot plus a word, so the state never rests on colour alone. */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding-block: 3px;
    padding-inline: 9px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.status-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-active   { background: var(--success-dim); color: var(--success); }
.status-ending   { background: var(--warning-dim); color: var(--warning); }
.status-expired  { background: var(--danger-dim);  color: var(--danger);  }
.status-inactive { background: var(--info-dim);    color: var(--info);    }

/* Days-left meter: the track is a quiet step of the surface, the fill carries state. */
.meter {
    height: 8px;
    margin: 18px 0 8px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
}
.meter-fill { height: 100%; border-radius: 999px; background: var(--accent); }
.meter-fill.is-warning { background: var(--warning); }
.meter-caption { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

/* --- Subscription: detail list --- */
.details {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    column-gap: 24px;
}
.details > div { padding: 12px 0; border-top: 1px solid var(--border); min-width: 0; }
.details dt {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 3px;
}
.details dd { font-size: 14px; color: var(--text); overflow-wrap: anywhere; }

/* --- Segmented filter (Activity) --- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.segmented {
    display: inline-flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.seg {
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    color: var(--text-dim);
    border-inline-start: 1px solid var(--border);
    transition: background var(--transition), color var(--transition);
}
.seg:first-child { border-inline-start: none; }
.seg:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.seg.is-on { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
.seg-count { margin-inline-start: 4px; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.seg.is-on .seg-count { color: inherit; opacity: .8; }

/* --- Usage chart --- */
.chart-card { padding: 20px 24px 18px; --chart-gutter: 56px; }
.chart-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px 24px;
    margin-bottom: 22px;
}
.chart-head .card-title { margin-bottom: 2px; }
.chart-sub { font-size: 12px; color: var(--text-muted); }
.chart-empty { padding: 28px 0; text-align: center; font-size: 13px; color: var(--text-muted); }

.legend { display: flex; gap: 16px; list-style: none; font-size: 12px; color: var(--text-dim); }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; }

/* Plot area. The left margin is the y-axis gutter; tick labels hang into it. */
.chart { position: relative; height: 220px; margin-inline-start: var(--chart-gutter); }
.chart-gridline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }
.chart-gridline span {
    position: absolute;
    inset-inline-end: calc(100% + 8px);
    top: -8px;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 16px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--text-muted);
}

.chart-cols { position: absolute; inset: 0; display: flex; align-items: stretch; }

/* A day's hit target is its whole column, not just the painted bar. */
.day {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    outline: none;
    cursor: default;
}
.day::before {
    content: '';
    position: absolute;
    inset: 0 1px;
    border-radius: 4px 4px 0 0;
    background: transparent;
    transition: background var(--transition);
}
.day:hover::before, .day:focus-visible::before { background: var(--surface-2); }
.day:focus-visible::before { box-shadow: inset 0 0 0 2px var(--accent-glow); }

/* Thin columns: at most 24px, square on the baseline, 4px round at the top,
   and a 2px surface gap between the stacked download and upload segments. */
.day-stack {
    position: relative;
    width: min(24px, 64%);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.seg-dl, .seg-ul { display: block; flex-basis: 0; min-height: 1px; }
.seg-dl { background: var(--chart-download); }
.seg-ul { background: var(--chart-upload); }
.day-stack > :first-child { border-radius: 4px 4px 0 0; }
.day:hover .day-stack, .day:focus-visible .day-stack { filter: brightness(1.15); }

/* The one direct label: the busiest day's total, above its column. */
.day-peak {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-family: var(--font-mono);
    font-size: 11px;
    white-space: nowrap;
    color: var(--text-dim);
    pointer-events: none;
}
.day-peak.at-start { left: auto; transform: none; inset-inline-start: 0; }
.day-peak.at-end   { left: auto; transform: none; inset-inline-end: 0; }

.chart-x { display: flex; margin-top: 8px; margin-inline-start: var(--chart-gutter); }
.chart-x span {
    flex: 1 1 0;
    width: 0;
    text-align: center;
    white-space: nowrap;
    font-size: 11px;
    color: var(--text-muted);
}

.chart-tip {
    position: fixed;
    z-index: 300;
    min-width: 170px;
    padding: 9px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    pointer-events: none;
}
.chart-tip[hidden] { display: none; }
.tip-value { font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.2; }
.tip-date { font-size: 11px; color: var(--text-muted); margin: 2px 0 7px; }
.tip-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.tip-row .key { width: 12px; }
.tip-num { margin-inline-start: auto; padding-inline-start: 12px; font-family: var(--font-mono); color: var(--text); }
.tip-sub { margin-top: 6px; font-size: 11px; color: var(--text-muted); }

.table-view { margin-top: 18px; }
.table-view summary {
    display: inline-block;
    font-size: 12px;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
}
.table-view summary:hover { color: var(--accent); }
.table-view[open] summary { margin-bottom: 10px; }

/* --- Activity timeline --- */
.timeline-card { padding: 8px 24px 12px; }
.tl-day {
    padding: 16px 0 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}
.timeline { list-style: none; }
.tl-item {
    display: grid;
    grid-template-columns: 96px 30px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 10px 0;
    border-top: 1px solid var(--border);
}
.tl-time { padding-top: 5px; font-size: 12px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.tl-title { font-size: 13px; font-weight: 500; color: var(--text); }
.tl-detail { font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.tl-detail .sep { margin: 0 2px; opacity: .6; }

.ev-icon {
    width: 30px; height: 30px;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-2);
    color: var(--text-dim);
}
.ev-icon svg { width: 15px; height: 15px; fill: currentColor; }
.tone-accent  { background: var(--accent-dim);  color: var(--accent);  }
.tone-success { background: var(--success-dim); color: var(--success); }
.tone-danger  { background: var(--danger-dim);  color: var(--danger);  }
.tone-warning { background: var(--warning-dim); color: var(--warning); }
.tone-info    { background: var(--info-dim);    color: var(--info);    }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 4px 0 8px; }
.pager-status { font-size: 12px; color: var(--text-muted); }

/* --- Announcements and added days --- */
.notice-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.notice {
    --tone: var(--info);
    --tone-dim: var(--info-dim);
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 14px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-inline-start: 3px solid var(--tone);
    border-radius: var(--radius);
}
.notice-success { --tone: var(--success); --tone-dim: var(--success-dim); }
.notice-warning { --tone: var(--warning); --tone-dim: var(--warning-dim); }
.notice-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    background: var(--tone-dim);
    color: var(--tone);
}
.notice-icon svg { width: 17px; height: 17px; fill: currentColor; }
.notice-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 2px 14px; }
.notice-title { font-size: 14px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.notice-time { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.notice-body { margin-top: 4px; font-size: 13px; line-height: 1.7; color: var(--text-dim); overflow-wrap: anywhere; }
.notice-label { color: var(--text-muted); }
.notice-facts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.notice-facts > div {
    display: flex; align-items: baseline; gap: 6px;
    padding: 2px 11px;
    border-radius: 999px;
    background: var(--surface-2);
    font-size: 12px;
}
.notice-facts dt { color: var(--text-muted); }
.notice-facts dd { color: var(--text); font-weight: 600; }
.notice-more { align-self: flex-start; font-size: 13px; font-weight: 500; }

/* Close button, in the corner on the reading side's end. */
.notice { position: relative; }
.notice.is-closable .notice-head { padding-inline-end: 30px; }
.notice-close { position: absolute; top: 10px; inset-inline-end: 10px; }
.notice-close button {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.notice-close button:hover,
.notice-close button:focus-visible { background: var(--surface-2); color: var(--text); outline: none; }
.notice-close button:focus-visible { box-shadow: 0 0 0 2px var(--accent-glow); }
.notice-close button:disabled { opacity: .5; cursor: default; }
.notice-close svg { width: 16px; height: 16px; fill: currentColor; }
.notice.is-leaving { opacity: 0; transform: scale(.98); transition: opacity 180ms ease, transform 180ms ease; }
@media (prefers-reduced-motion: reduce) { .notice.is-leaving { transition: none; } }

/* --- Subscription history card --- */
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.card-head .card-title { margin-bottom: 0; }
.card-link { font-size: 12px; font-weight: 500; }
.history-card { padding-bottom: 10px; }
.history-card .timeline { margin-top: 8px; }

/* The unit beside a large figure, set smaller: "1.24 GB". */
.stat-unit { font-family: var(--font-ui); font-size: 0.6em; font-weight: 500; color: var(--text-dim); }

/* =====================================================
   PERSIAN — right to left, Vazirmatn
   Layout already follows the direction through logical properties
   (inline-start/end); this block only adjusts the type.
   ===================================================== */
html[lang="fa"] {
    --font-ui:   'Vazirmatn', Tahoma, sans-serif;
    /* JetBrains Mono for Latin usernames and addresses; it has no Persian
       digits, so figures fall through to Vazirmatn. */
    --font-mono: 'JetBrains Mono', 'Vazirmatn', monospace;
}
html[lang="fa"] body { line-height: 1.75; }
/* Persian letters join; any tracking pulls words apart. */
html[lang="fa"] * { letter-spacing: 0; }
/* Small labels were sized for Latin capitals; Persian needs a step more. */
html[lang="fa"] :is(.stat-label, .card-title, .details dt, .tl-day, thead th, label) { font-size: 12.5px; font-weight: 600; }
html[lang="fa"] .sidebar-brand-sub { font-size: 11px; }
html[lang="fa"] .sidebar-nav a { font-size: 14px; }
html[lang="fa"] :is(.stat-value, .tip-value, .hero-figure) { font-family: var(--font-ui); }
html[lang="fa"] .stat-value { font-weight: 700; }
html[lang="fa"] .hero-figure { font-weight: 700; letter-spacing: 0; }
html[lang="fa"] .hero-word { font-size: 38px; }
html[lang="fa"] .chart-card { --chart-gutter: 84px; }
html[lang="fa"] .chart-gridline span { font-family: var(--font-ui); }
html[lang="fa"] .tl-item { grid-template-columns: 104px 30px minmax(0, 1fr); }
/* Latin entry fields (username, password, email) read left to right. */
html[lang="fa"] input[dir="ltr"] { text-align: left; }

/* =====================================================
   MOBILE — the sidebar becomes a bottom tab bar
   ===================================================== */
@media (max-width: 768px) {
    body { padding-inline-start: 0; padding-bottom: 70px; }

    .sidebar {
        top: auto;
        bottom: 0; left: 0; right: 0;
        height: 58px;
        width: 100%;
        flex-direction: row;
        border-inline-end: none;
        border-top: 1px solid var(--border);
        overflow: visible;
    }
    .sidebar-brand { display: none; }
    .sidebar-nav { display: flex; width: 100%; padding: 0; }
    .sidebar-nav li { flex: 1; }
    .sidebar-nav a {
        flex-direction: column;
        justify-content: center;
        gap: 3px;
        height: 100%;
        padding: 6px 4px;
        font-size: 10px;
        border-inline-start: none;
        border-top: 2px solid transparent;
        text-align: center;
    }
    .sidebar-nav a svg { width: 18px; height: 18px; }
    .sidebar-nav a:hover,
    .sidebar-nav a.active { border-inline-start-color: transparent; border-top-color: var(--accent); }

    .topbar { inset-inline-start: 0; padding: 0 14px; }
    .page-content { padding: 16px 14px 24px; }
    .page-title { margin-top: 0; }
    .card { padding: 16px 16px; }

    .sub-hero { grid-template-columns: 1fr; padding: 20px; }
    .hero-figure { font-size: 48px; }
    .hero-word { font-size: 34px; }

    .chart { height: 180px; }
    .chart-card { --chart-gutter: 46px; }
    html[lang="fa"] .chart-card { --chart-gutter: 70px; }
    /* Narrow columns: keep the last date inside the card by letting it
       overflow leftwards instead of centring it past the edge. */
    .chart-x span:last-child { display: flex; justify-content: flex-end; }
    .chart-x .x-alt { visibility: hidden; }
    .timeline-card { padding: 4px 16px 10px; }
    .notice { padding: 14px 16px; gap: 12px; }
    .tl-item, html[lang="fa"] .tl-item { grid-template-columns: 30px minmax(0, 1fr); }
    html[lang="fa"] .sidebar-nav a { font-size: 11px; }
    .tl-time { grid-column: 2; grid-row: 2; padding-top: 0; font-size: 11px; color: var(--text-muted); }
    .ev-icon { grid-row: 1 / span 2; }
    .segmented { width: 100%; }
    .seg { flex: 1; text-align: center; padding: 7px 4px; }
}

@media (max-width: 480px) {
    .topbar-panel { display: none; }
    .lang-long { display: none; }
    .lang-short { display: inline; }
    .login-card { padding: 28px 22px; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 20px; }
    .stat-value-text { font-size: 16px; }
}
