/* PNLSEO Design System — tokens, layout shell, navigation */
:root {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    font-size: 16px;
    --font-sans: 'Vazirmatn', Tahoma, sans-serif;
    --font-mono: 'Vazirmatn', Tahoma, sans-serif;

    /* Color — light (ChatGPT-inspired) */
    --bs-body-bg: #f7f7f8;
    --bs-body-color: #0d0d0d;
    --surface-elevated: #ffffff;
    --surface-muted: #ececf1;
    --surface-subtle: #f7f7f8;
    --border-color: #ececf1;
    --border-strong: #d9d9e3;
    --input-border: #d9d9e3;
    --input-bg: #ffffff;
    --accent: #10a37f;
    --accent-hover: #0d8a6a;
    --accent-soft: rgba(16, 163, 127, 0.12);
    --accent-muted: rgba(16, 163, 127, 0.06);
    --chart-primary: #10a37f;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-soft: rgba(239, 68, 68, 0.1);
    --success: #10a37f;
    --success-soft: rgba(16, 163, 127, 0.12);
    --warning: #f59e0b;
    --warning-soft: rgba(245, 158, 11, 0.12);
    --muted: #6e6e80;
    --muted-strong: #353740;
    --table-header-bg: #f7f7f8;
    --table-stripe: rgba(0, 0, 0, 0.02);
    --alert-error-bg: var(--danger-soft);
    --alert-success-bg: var(--success-soft);
    --overlay: rgba(0, 0, 0, 0.45);

    /* Elevation */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
    --card-shadow: var(--shadow-xs);
    --header-shadow: none;

    /* Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.25rem;
    --radius-full: 9999px;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;

    /* Typography */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;

    /* Focus & motion */
    --focus-ring: 0 0 0 3px rgba(16, 163, 127, 0.28);
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;

    /* Layout */
    --header-height: 4rem;
    --content-max: 1440px;
    --sidebar-width: 17.5rem;
}

[data-theme='dark'] {
    color-scheme: dark;
    --bs-body-bg: #212121;
    --bs-body-color: #ececec;
    --surface-elevated: #2f2f2f;
    --surface-muted: #2a2a2a;
    --surface-subtle: #262626;
    --border-color: #424242;
    --border-strong: #565656;
    --input-border: #565656;
    --input-bg: #2f2f2f;
    --accent: #10a37f;
    --accent-hover: #1cb88a;
    --accent-soft: rgba(16, 163, 127, 0.18);
    --accent-muted: rgba(16, 163, 127, 0.08);
    --chart-primary: #1cb88a;
    --danger: #f87171;
    --danger-hover: #fca5a5;
    --danger-soft: rgba(248, 113, 113, 0.14);
    --success: #1cb88a;
    --success-soft: rgba(28, 184, 138, 0.14);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.14);
    --muted: #9b9b9b;
    --muted-strong: #d1d1d1;
    --table-header-bg: #333333;
    --table-stripe: rgba(255, 255, 255, 0.03);
    --alert-error-bg: var(--danger-soft);
    --alert-success-bg: var(--success-soft);
    --overlay: rgba(0, 0, 0, 0.65);
    --shadow-xs: none;
    --shadow-sm: none;
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.45);
    --card-shadow: none;
    --focus-ring: 0 0 0 3px rgba(16, 163, 127, 0.35);
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    transition: background-color var(--transition-base), color var(--transition-base);
}

h1, h2, h3, h4 {
    line-height: var(--leading-tight);
    font-weight: 700;
    color: var(--bs-body-color);
}

p {
    margin-top: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* App shell header */
header,
header.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface-elevated);
    color: var(--bs-body-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--header-shadow);
    padding: 0 var(--space-6);
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

.top-bar__brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
    flex: 1 1 auto;
}

.title-block {
    min-width: 0;
}

header h1,
.title-block h1 {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subtitle {
    margin: 0.15rem 0 0;
    font-size: var(--text-xs);
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex: 0 1 auto;
    min-width: 0;
}

.main-nav-wrapper {
    display: contents;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1);
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
}

.main-nav a {
    color: var(--muted-strong);
    text-decoration: none;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: 600;
    white-space: nowrap;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.main-nav a:hover {
    color: var(--bs-body-color);
    background: var(--surface-elevated);
}

.main-nav a.active {
    color: var(--accent);
    background: var(--surface-elevated);
    box-shadow: var(--shadow-xs);
}

.main-nav a:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.toolbar-buttons {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    justify-content: flex-end;
}

.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
    color: var(--bs-body-color);
    cursor: pointer;
    flex-shrink: 0;
}

.menu-toggle__bar {
    display: block;
    width: 1.125rem;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    position: relative;
}

.menu-toggle__bar::before,
.menu-toggle__bar::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
}

.menu-toggle__bar::before {
    top: -6px;
}

.menu-toggle__bar::after {
    top: 6px;
}

.nav-overlay {
    display: none;
}

.calendar-toggle select {
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--surface-muted);
    color: var(--bs-body-color);
    padding: 0.4rem 0.85rem;
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: pointer;
    min-height: 2.25rem;
}

.calendar-toggle select:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.toolbar-toggle {
    margin: 0;
    display: flex;
}

.debug-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid var(--border-color);
    background: var(--surface-muted);
    color: var(--muted-strong);
    border-radius: var(--radius-full);
    padding: 0.4rem 0.85rem;
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: pointer;
    min-height: 2.25rem;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.debug-switch:hover {
    background: var(--surface-elevated);
    border-color: var(--border-strong);
}

.debug-switch.is-active {
    background: var(--success-soft);
    border-color: transparent;
    color: var(--success);
}

.debug-indicator {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--border-strong);
    display: inline-block;
    flex-shrink: 0;
}

.debug-switch.is-active .debug-indicator {
    background: var(--success);
}

.debug-label {
    white-space: nowrap;
}

.theme-toggle,
.language-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    min-height: 2.25rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--surface-muted);
    color: var(--muted-strong);
    font-size: var(--text-xs);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.theme-toggle {
    border: 1px solid var(--border-color);
}

.language-toggle:hover,
.theme-toggle:hover {
    background: var(--surface-elevated);
    color: var(--bs-body-color);
    border-color: var(--border-strong);
}

.theme-toggle:focus-visible,
.language-toggle:focus-visible,
.debug-switch:focus-visible,
.menu-toggle:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

main {
    padding: var(--space-6);
    max-width: var(--content-max);
    margin-inline: auto;
    width: 100%;
}

.layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    gap: var(--space-6);
    align-items: start;
}

.sidebar {
    background: var(--surface-elevated);
    color: var(--bs-body-color);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    position: sticky;
    top: calc(var(--header-height) + var(--space-4));
    max-height: calc(100vh - var(--header-height) - var(--space-8));
    overflow-y: auto;
    border: 1px solid var(--border-color);
    transition: background-color var(--transition-base), color var(--transition-base);
}

.sidebar h2 {
    margin: 0 0 var(--space-3);
    font-size: var(--text-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.app-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}

.app-list li {
    margin-bottom: 0.5rem;
    border-radius: 0.8rem;
    transition: background 0.2s ease;
}

.app-list li a {
    display: block;
    padding: 0.75rem;
    text-decoration: none;
    color: inherit;
    border-radius: 0.8rem;
}

.app-list li.active {
    background-color: var(--accent-soft);
}

.app-list li.active a {
    color: var(--accent);
    font-weight: 600;
}

.app-list li:hover:not(.active) {
    background-color: var(--surface-muted);
}

.app-list small {
    color: var(--muted);
}

.add-app summary,
.add-section summary {
    cursor: pointer;
    font-weight: bold;
    margin-bottom: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background-color: var(--surface-elevated);
    padding: 0.45rem 0.9rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.add-app summary:hover,
.add-section summary:hover {
    background-color: var(--table-stripe);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.add-app form,
.add-section form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--muted-strong);
}

/* Checkbox + title on one row (panel.css forces column on all labels). */
label.check-inline,
.check-inline {
    display: inline-flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 0.55rem !important;
    font-weight: 500;
    cursor: pointer;
    max-width: 100%;
}

label.check-inline > input[type="checkbox"],
.check-inline > input[type="checkbox"] {
    flex: 0 0 auto;
    width: 1.05rem;
    height: 1.05rem;
    margin: 0;
    accent-color: var(--accent, #2dd4bf);
}

label.check-inline > span,
.check-inline > span {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.45;
    font-weight: 500;
}

input[type="text"],
input[type="url"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"],
select,
textarea {
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    line-height: var(--leading-normal);
    background-color: var(--input-bg);
    color: var(--bs-body-color);
    min-height: 2.625rem;
    transition: border-color var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
    opacity: 1;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--focus-ring);
}

input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

textarea {
    resize: vertical;
}

button {
    border: none;
    border-radius: var(--radius-md);
    padding: 0.625rem 1.125rem;
    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1.2;
    background-color: var(--accent);
    color: #fff;
    cursor: pointer;
    min-height: 2.625rem;
    transition: background-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

button:hover:not(:disabled) {
    background-color: var(--accent-hover);
}

button:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

button.danger {
    background-color: var(--danger);
}

button.danger:hover:not(:disabled) {
    background-color: var(--danger-hover);
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.7rem;
    margin-bottom: 1rem;
}

.alert.error {
    background-color: var(--alert-error-bg);
    color: var(--danger);
}

.alert.success {
    background-color: var(--alert-success-bg);
    color: var(--success);
}

.card {
    background: var(--surface-elevated);
    padding: var(--space-5);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    margin-bottom: var(--space-5);
    border: 1px solid var(--border-color);
}

.card h2 {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--bs-body-color);
    letter-spacing: -0.01em;
}

.card > h2:not(:last-child) {
    padding-bottom: var(--space-3);
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-color);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    border: none;
    padding: 0;
    margin: 0;
}

.card-subtitle {
    margin: var(--space-1) 0 0;
    color: var(--muted);
    font-size: var(--text-sm);
    font-weight: 400;
    line-height: var(--leading-relaxed);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.store-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    width: 100%;
}

.store-grid--row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.store-grid__item {
    flex: 1 1 220px;
    min-width: 220px;
}

fieldset {
    border: 1px solid var(--border-color);
    border-radius: 0.8rem;
    padding: 0.75rem;
}

legend {
    font-weight: bold;
    padding: 0 0.4rem;
}

.items {
    display: grid;
    gap: 1rem;
}

.dashboard {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    min-width: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-3);
}

.stat-card {
    background: var(--surface-elevated);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    transition: background-color var(--transition-base), border-color var(--transition-base);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-height: 5.75rem;
    min-width: 0;
}

.stat-card h3 {
    margin: 0;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.stat-card p {
    margin: 0;
    font-size: clamp(1.5rem, 2.5vw, 1.875rem);
    font-weight: 700;
    line-height: var(--leading-tight);
    color: var(--bs-body-color);
    font-variant-numeric: tabular-nums;
}

.stat-card small {
    display: block;
    margin-top: auto;
    color: var(--muted);
    font-size: var(--text-xs);
}

.charts {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: var(--space-4);
    min-width: 0;
}

.charts > .card {
    min-width: 0;
    margin-bottom: 0;
}

.trend-filters {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    background: var(--surface-elevated);
    margin-bottom: 0;
}

.trend-filters .filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    width: 100%;
}

.trend-filters label {
    flex: 1 1 10rem;
    min-width: 0;
}

.trend-filters select {
    width: 100%;
    min-width: 0;
}

.analytics-card {
    margin-top: 1.5rem;
}

.inline-filter {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
    gap: var(--space-4);
    align-items: end;
    margin-bottom: var(--space-4);
}

.inline-filter label {
    min-width: 0;
}

.analytics-rollup {
    margin-top: 1.5rem;
}

.analytics-rollup .inline-filter {
    margin-bottom: 1.25rem;
}

.card-header.with-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-header.stacked {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.card-header.stacked .card-subtitle {
    margin-top: 0.25rem;
}

.analytics-panel.is-hidden {
    display: none;
}

.input-with-upload {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.7rem;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--muted-strong);
}

.icon-btn svg {
    width: 1.05rem;
    height: 1.05rem;
}

.icon-btn:hover {
    background: var(--surface-muted);
}

.icon-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}



.input-with-upload input[type="url"] {
    flex: 1;
}

.input-with-upload .upload-status {
    font-size: 0.75rem;
    color: var(--muted);
    min-width: 4.5rem;
}

.input-with-upload .upload-status.is-success {
    color: var(--success);
}

.input-with-upload .upload-status.is-error {
    color: var(--danger);
}

.input-with-upload.is-uploading .upload-status {
    color: var(--accent);
}

.inline-filter label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-weight: 600;
    color: var(--muted-strong);
}

.table-wrapper.compact table {
    font-size: 0.875rem;
}

.table-wrapper.compact code {
    font-size: 0.75rem;
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    background-color: var(--surface-elevated);
}

th,
td {
    text-align: right;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

th {
    background-color: var(--table-header-bg);
    color: var(--muted-strong);
    font-weight: 600;
}

tbody tr:nth-child(even) {
    background-color: var(--table-stripe);
}

.ua-cell {
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ip-cell {
    direction: ltr;
    text-align: left;
    font-feature-settings: "tnum";
}

.ua-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 520px;
}

.ua-display .ua-text {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: ltr;
    text-align: left;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.8rem;
    color: var(--muted-strong);
    background: transparent;
    padding: 0;
}

.ua-display .ua-copy {
    flex: 0 0 auto;
}

.app-counts {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 220px;
}

.app-count-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.app-count-name {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-count-num {
    flex: 0 0 auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    color: var(--muted-strong);
    font-size: 0.85rem;
}


.muted {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.small-text {
    font-size: 0.85rem;
}

.form-hint {
    font-size: 0.85rem;
    color: var(--muted);
    margin: -0.25rem 0 0.75rem;
}

.card--sub {
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-top: 1rem;
}

.app-geo {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.app-geo__status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-geo__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.85rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--surface-elevated);
    border: 1px solid var(--border-color);
    color: var(--muted-strong);
}

.app-geo__badge.is-active {
    background: var(--alert-success-bg);
    color: var(--success);
    border-color: transparent;
}

.app-auth__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.inline-form button {
    height: 100%;
}

.token-box {
    background: var(--input-bg);
    border: 1px dashed var(--border-color);
    border-radius: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.token-box__row {
    display: flex;
    align-items: stretch;
    gap: 0.5rem;
}

.token-box__input {
    flex: 1 1 auto;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-family: var(--code-font, 'Courier New', monospace);
    font-size: 0.95rem;
    direction: ltr;
    background: var(--surface);
}

.token-box__hint {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.5rem;
}

.token-hint {
    margin: 0.5rem 0;
}

.app-auth h3 {
    margin-top: 0;
}

.app-auth button {
    white-space: nowrap;
}

.grid-two {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.grid-four {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.field-label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--muted-strong);
}


.schedule-grid {
    display: grid;
    gap: 0.75rem;
    align-items: flex-start;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

@media (min-width: 992px) {
    .schedule-grid {
        grid-template-columns: repeat(4, minmax(150px, 1fr));
    }
}

.schedule-grid > label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
    max-width: none;
    overflow: visible;
}

.schedule-grid > label .field-label {
    margin: 0;
}

.schedule-grid > label > .date-field,
.schedule-grid > label > .time-field {
    width: 100%;
    max-width: 12.5rem;
    min-width: 0;
    box-sizing: border-box;
}

@media (max-width: 575.98px) {
    .schedule-grid > label > .date-field,
    .schedule-grid > label > .time-field {
        max-width: none;
    }
}

.date-field {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0.45rem 0.75rem;
}


.pwt-datepicker-container,
.pwt-date-picker,
.pwt-date-view,
.pwt-date-container {
    width: 22rem !important;
    max-width: 95vw !important;
    min-width: 20rem !important;
}

.pwt-datepicker-container {
    z-index: 2050 !important;
}

.date-field__display {
    width: 100%;
    min-width: 0;
    background: transparent;
    border: 0;
    padding: 0;
    padding-inline-end: 2.25rem;
}

.date-field::after {
    content: '📅';
    position: absolute;
    inset-inline-end: 0.75rem;
    color: var(--muted);
    pointer-events: none;
    font-size: 1rem;
    opacity: 0.7;
}

[data-theme='dark'] .date-field::after {
    color: rgba(226, 232, 240, 0.8);
}

.grid-three {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.multi-input {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.multi-input__rows {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.multi-input__row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.multi-input__field {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex: 1 1 auto;
}

.multi-input__row [data-multi-field] {
    flex: 1 1 auto;
}

.multi-input__field--weight {
    flex: 0 0 120px;
    max-width: 140px;
}

.multi-input__field--weight input {
    text-align: center;
    width: 100%;
}

.multi-input__suffix {
    font-weight: 600;
    color: var(--muted);
}

.multi-input .secondary {
    align-self: flex-start;
}

.icon-button {
    border: 1px solid var(--border-color);
    background: var(--surface-elevated);
    color: var(--muted-strong);
    border-radius: 0.6rem;
    padding: 0.35rem 0.6rem;
    cursor: pointer;
    line-height: 1;
    font-size: 1rem;
    transition: background-color 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.icon-button:hover {
    background: var(--surface-muted);
}

.icon-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button.secondary {
    background-color: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    box-shadow: none;
}

button.secondary:hover:not(:disabled) {
    background-color: var(--accent-soft);
    color: var(--accent-hover);
    border-color: var(--accent-hover);
}

.app-scope {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.app-scope select[multiple] {
    display: none;
}

.app-picker {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.app-picker__controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.app-picker__controls select {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0.45rem 0.75rem;
    background-color: var(--input-bg);
    color: var(--bs-body-color);
}

.selected-apps {
    background: var(--surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0.6rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.selected-apps__label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted-strong);
}

.selected-apps__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.selected-apps__chips .chip:not(.muted) {
    background: transparent;
    border: 1px dashed var(--accent);
    color: var(--accent);
    padding: 0.35rem 0.9rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.selected-apps__chips .chip:not(.muted):hover {
    background-color: var(--accent-muted);
}

.chip {
    background: var(--surface-muted);
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
    color: var(--bs-body-color);
}

.chip.muted {
    color: var(--muted);
    background: transparent;
    border: 1px dashed var(--border-color);
}

.chip--removable {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.chip__text {
    white-space: nowrap;
}

.chip__remove {
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
}

.chip__remove:hover {
    color: var(--accent);
}

.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.chip--link {
    text-decoration: none;
    border: 1px solid var(--border-color);
}

.chip--link:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.time-field {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0.45rem 0.55rem;
    gap: 0.3rem;
    direction: ltr;
}

.time-field__inputs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.time-field__part {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
}

.time-field__part input[type="number"] {
    width: 4.5ch;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    text-align: center;
    font-weight: 600;
    color: var(--bs-body-color);
    border-radius: 0.5rem;
    padding: 0.35rem 0.25rem;
    -moz-appearance: textfield;
}

.time-field__part input[type="number"]::-webkit-outer-spin-button,
.time-field__part input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.time-field__separator {
    font-weight: 700;
    color: var(--muted-strong);
    align-self: center;
}

.time-field__hint {
    font-size: 0.7rem;
    color: var(--muted-strong);
    text-align: start;
}

.app-meta {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.9rem;
}

.app-meta .code-link {
    font-family: var(--font-mono);
    background: var(--surface-muted);
    border-radius: 0.5rem;
    padding: 0.3rem 0.6rem;
    color: var(--accent);
}

.code-link {
    text-decoration: none;
    word-break: break-all;
}

.rule-scope-summary {
    margin-top: 1rem;
    border: 1px dashed var(--border-color);
    border-radius: 0.75rem;
    padding: 0.75rem;
    background: var(--surface-muted);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rule-scope-summary__line {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
    font-size: 0.95rem;
}

.rule-scope-summary__line strong {
    font-weight: 700;
}

.rule-scope-summary__links details {
    cursor: pointer;
}

.rule-scope-summary__links summary {
    font-size: 0.85rem;
    color: var(--accent);
}

.rule-scope-summary__links summary:hover {
    text-decoration: underline;
}

.schedule-form {
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
}

.days {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
}

.days label {
    flex-direction: row;
    align-items: center;
    gap: 0.35rem;
    font-weight: normal;
}

.item {
    background: var(--surface-muted);
    padding: 1rem;
    border-radius: 0.8rem;
    display: grid;
    gap: 0.75rem;
    border: 1px solid var(--border-color);
}

.inline-form {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
    align-items: center;
}

.form-with-actions .form-actions {
    justify-content: flex-start;
}

.form-actions.inline {
    justify-content: flex-start;
}

.checkbox {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.danger-form {
    display: flex;
    justify-content: flex-end;
}

.notification-block {
    display: grid;
    gap: 0.75rem;
    background-color: var(--surface-muted);
    padding: 1rem;
    border-radius: 0.9rem;
    border: 1px solid var(--border-color);
}

.actions {
    background-color: var(--surface-elevated);
    padding: 0.8rem;
    border-radius: 0.8rem;
    border: 1px solid var(--border-color);
}

footer {
    text-align: center;
    padding: 1rem;
    color: var(--muted);
}

textarea,
input,
select,
button,
.card,
.sidebar,
.item {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.account-menu {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0.35rem 0.35rem 0.35rem 0.75rem;
    background-color: var(--surface-muted);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    max-width: min(100%, 18rem);
}

.account-menu__name {
    font-weight: 600;
    color: var(--muted-strong);
}

.account-menu__link {
    font-size: 0.85rem;
    color: var(--accent);
    text-decoration: none;
    padding: 0.1rem 0.4rem;
}

.account-menu__link:hover,
.account-menu__link:focus {
    color: var(--accent-hover);
}

.account-menu__logout {
    color: var(--danger);
}

.account-menu__logout:hover,
.account-menu__logout:focus {
    color: var(--danger-hover);
}

.account-card {
    margin: 2.5rem auto 0;
    max-width: 960px;
}

.account-form {
    display: grid;
    gap: 1.25rem;
}

.twofa-settings {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(148, 163, 184, 0.28);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.twofa-settings__header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.twofa-settings__header .muted {
    margin: 0.35rem 0 0;
}

.twofa-status {
    display: flex;
    gap: 0.85rem;
    align-items: flex-start;
    padding: 1rem;
    border-radius: var(--radius-lg);
    background: var(--accent-soft);
    border: 1px solid var(--border-color);
}

.twofa-status--pending {
    background: var(--warning-soft);
}

.twofa-status--disabled {
    background: var(--surface-muted);
}

.twofa-status__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.85rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: var(--text-xs);
    background: var(--success-soft);
    color: var(--success);
}

.twofa-status--pending .twofa-status__badge {
    background: var(--warning-soft);
    color: var(--warning);
}

.twofa-status--disabled .twofa-status__badge {
    background: var(--surface-muted);
    color: var(--muted);
}

.twofa-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.twofa-form__field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.twofa-form__field input {
    width: 100%;
}

.twofa-grid {
    display: grid;
    gap: 1rem;
}

.twofa-secret {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.twofa-secret code {
    display: inline-block;
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.08);
    font-size: 0.95rem;
    letter-spacing: 0.08em;
}

.twofa-qr {
    display: flex;
    justify-content: center;
}

.twofa-qr img {
    max-width: 200px;
    width: 100%;
    border-radius: 16px;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.12);
}

@media (min-width: 720px) {
    .twofa-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

[data-theme='dark'] .twofa-status {
    background: var(--accent-soft);
}

[data-theme='dark'] .twofa-status--pending {
    background: var(--warning-soft);
}

[data-theme='dark'] .twofa-status--disabled {
    background: var(--surface-muted);
}

[data-theme='dark'] .twofa-secret code {
    background: var(--surface-muted);
    color: var(--bs-body-color);
}

.account-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.account-hint {
    margin: 0;
}

.account-logins {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.account-logins h3 {
    margin: 0;
    font-size: 1.1rem;
}

/* Authentication pages */
.auth-body {
    min-height: 100vh;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, var(--accent-muted), transparent),
        var(--bs-body-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-6) var(--space-4);
}

.auth-shell {
    width: min(100%, 26rem);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.auth-toolbar,
.login-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: var(--space-2);
}

.auth-toolbar .language-toggle,
.auth-toolbar .theme-toggle,
.login-toolbar .language-toggle,
.login-toolbar .theme-toggle {
    background: var(--surface-elevated);
    border-color: var(--border-color);
}

.auth-wrapper {
    width: 100%;
}

.auth-card,
.login-card {
    background: var(--surface-elevated);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    padding: var(--space-8) var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    width: 100%;
}

.auth-card h1,
.login-card h1 {
    margin: 0;
    font-size: var(--text-2xl);
    font-weight: 700;
    text-align: center;
    letter-spacing: -0.02em;
}

.auth-subtitle,
.login-card .hint {
    margin: calc(var(--space-2) * -1) 0 0;
    text-align: center;
    color: var(--muted);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
}

.auth-form,
.login-card form {
    display: grid;
    gap: var(--space-4);
}

.auth-form label,
.login-card .form-group label {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--muted-strong);
}

.auth-form input,
.login-card input[type="text"],
.login-card input[type="password"] {
    width: 100%;
}

.auth-actions {
    display: flex;
    justify-content: stretch;
    margin-top: var(--space-1);
}

.auth-actions button,
.login-card button[type="submit"] {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: var(--text-base);
    background: var(--accent);
}

.auth-actions button:hover:not(:disabled),
.login-card button[type="submit"]:hover:not(:disabled) {
    background: var(--accent-hover);
}

.auth-alert,
.error-message {
    margin: 0;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--alert-error-bg);
    color: var(--danger);
    font-size: var(--text-sm);
    text-align: center;
    border: 1px solid transparent;
}

.auth-hint {
    margin: 0;
    text-align: center;
    color: var(--muted);
    font-size: var(--text-sm);
}

.login-card .form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin: 0;
}

.login-card .back-link {
    display: block;
    text-align: center;
    color: var(--accent);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 600;
    margin-top: var(--space-2);
}

.login-card .back-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.login-card .back-link:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

.geo-dashboard {
    display: grid;
    gap: 1.5rem;
}

.geo-processing-card .card-header.stacked {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.geo-processing-card .card-header.stacked > div {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.geo-processing-card .card-subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.geo-form-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    align-items: end;
}

.geo-form .form-actions {
    margin-top: 1rem;
}

.geo-hint {
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.geo-report {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    background: var(--surface-muted, rgba(148, 163, 184, 0.15));
    font-size: 0.875rem;
}

.geo-report ul {
    margin: 0.5rem 0 0;
    padding-left: 1.25rem;
}

.link-button {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: var(--text-sm);
    padding: 0.25rem 0.5rem;
}

.link-button:hover,
.link-button:focus-visible {
    text-decoration: underline;
}

.geo-table__actions {
    display: flex;
    justify-content: center;
    margin-top: 0.5rem;
}

.geo-table__actions .link-button {
    font-weight: 600;
}

.geo-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.geo-actions .link-button {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: var(--text-sm);
    padding: 0;
}

.geo-actions .link-button.warn {
    color: var(--danger-color, #dc2626);
}

.geo-filter-form {
    margin-top: 1rem;
}

.geo-filter-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
}

.geo-filter-grid label {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.geo-toggle-start .checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    background: var(--surface-muted);
}

.geo-filter-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.geo-stats {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.geo-chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.geo-chart canvas {
    width: 100% !important;
}

.geo-table table {
    width: 100%;
}

.geo-table td,
.geo-table th {
    text-align: center;
}

.input-with-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.js-fieldset {
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 8px;
    background: var(--surface-muted);
}

.js-field {
    margin-bottom: 12px;
}

.field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.history-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-add-form label {
    display: block;
}

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--overlay);
    backdrop-filter: blur(4px);
    z-index: 999;
    padding: var(--space-4);
}

.modal[hidden] {
    display: none;
}

.modal__dialog {
    position: relative;
    background: var(--surface-elevated);
    color: var(--bs-body-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: min(1100px, 96%);
    max-height: 90vh;
    overflow: hidden;
    z-index: 1;
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    gap: 8px;
}

.modal__body {
    padding: 16px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/*
  Requests modal ("مشاهده همه درخواست ها")
  Previously, the modal body had overflow:hidden, so long tables (especially the
  "تمام درخواست‌ها بر اساس زمان" tab) were clipped with no way to scroll.
  Here we make only the requests modal scrollable while keeping the header fixed.
*/
.modal[data-requests-modal] .modal__dialog {
    display: flex;
    flex-direction: column;
}

.modal[data-requests-modal] .modal__body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal[data-requests-modal] .requests-tab {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/*
  IMPORTANT: Respect the [hidden] attribute for tab panes.
  The rule above sets display:flex, which can override the browser's default
  [hidden]{display:none} behavior depending on cascade order. When that happens
  the inactive pane stays visible, causing duplicated headers and broken tab
  switching.
*/
.modal[data-requests-modal] .requests-tab[hidden] {
    display: none !important;
}

.modal[data-requests-modal] .requests-tab .table-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.requests-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tab-button {
    border: 1px solid var(--border-color);
    background: var(--surface-elevated);
    color: var(--muted-strong);
    border-radius: 0.75rem;
    padding: 0.5rem 0.85rem;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.tab-button:hover {
    background: var(--surface-muted);
}

.tab-button.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.requests-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.requests-toolbar__label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.requests-toolbar__label select {
    width: auto;
}

.requests-toolbar__meta {
    color: var(--muted);
    font-size: 0.9rem;
}

.requests-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding-top: 0.5rem;
}

.modal__form form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: transparent;
}

.js-library-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.js-snippet {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    background: var(--surface-elevated);
}

.js-snippet__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.js-snippet__meta {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.js-snippet__content {
    background: var(--surface-muted);
    color: var(--bs-body-color);
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    max-height: 200px;
    overflow: auto;
    font-family: monospace;
    white-space: pre-wrap;
}

.js-snippet__actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-full);
    background: var(--accent-soft);
    color: var(--accent);
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1.4;
}

.target-nav__fields.is-hidden {
    display: none;
}

.tiny {
    padding: 6px 8px;
    font-size: 12px;
}

.js-library-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 16px;
    height: 100%;
}

.js-library-panel {
    background: var(--surface-muted);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.js-library-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: space-between;
}

.js-library-scroll {
    overflow-y: auto;
    padding-right: 4px;
    max-height: calc(80vh - 150px);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.js-library-panel--form form textarea {
    min-height: 120px;
}

.js-library-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.js-library-filters select,
.js-library-filters input[type="text"] {
    min-width: 180px;
}

.modal-open {
    overflow: hidden;
}

.media-library-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.media-library-toolbar input[type="text"] {
    min-width: 200px;
    flex: 1;
}

.media-library-scroll {
    overflow-y: auto;
    padding-right: 4px;
    max-height: calc(80vh - 170px);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.media-item {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.media-item__thumb {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--surface-muted);
    padding: 0;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    width: 100%;
}

.media-item__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-item__file {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--muted-strong);
    letter-spacing: 0.05em;
}

.media-item__badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(15, 23, 42, 0.8);
    color: #fff;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 999px;
}

.media-item__delete {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 2;
    padding: 0.25rem 0.5rem;
}

.media-item__info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.media-item__name {
    font-size: 0.8rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-item__date {
    font-size: 0.75rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 960px) {
    .js-library-layout {
        grid-template-columns: 1fr;
    }
}

/* === Dashboard chart legend (apps toggle) === */
.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0 4px 0;
    align-items: center;
}

.chart-legend__item {
    appearance: none;
    border: 1px solid var(--border-color);
    background: var(--surface-muted);
    color: var(--bs-body-color);
    border-radius: 999px;
    padding: 6px 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    transition: transform 120ms ease, opacity 120ms ease, box-shadow 120ms ease;
}

.chart-legend__item:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

[data-theme='dark'] .chart-legend__item:hover {
    box-shadow: 0 8px 18px rgba(0,0,0,0.35);
}

.chart-legend__item[aria-pressed="false"] {
    opacity: 0.55;
}

.chart-legend__swatch {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    flex: 0 0 10px;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.18);
}

[data-theme='dark'] .chart-legend__swatch {
    box-shadow: 0 0 0 2px rgba(15,23,42,0.8);
}

/* Content column & layout helpers */
.content {
    min-width: 0;
}

.layout > .content {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.empty-state {
    padding: var(--space-6) var(--space-4);
    text-align: center;
    color: var(--muted);
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface-subtle);
}

/* Tables — interaction & readability */
tbody tr {
    transition: background-color var(--transition-fast);
}

tbody tr:hover {
    background-color: var(--accent-muted);
}

th {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Secondary & ghost buttons — see base button.secondary above */

.tab-button.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.link-button {
    color: var(--accent);
}

.geo-actions .link-button,
.geo-table__actions .link-button {
    color: var(--accent);
}

.geo-actions .link-button.warn {
    color: var(--danger);
}

/* Alerts */
.alert {
    font-size: var(--text-sm);
    line-height: var(--leading-relaxed);
    border: 1px solid transparent;
}

.alert.error {
    border-color: rgba(220, 38, 38, 0.15);
}

.alert.success {
    border-color: rgba(21, 128, 61, 0.15);
}

/* Account settings anchor section */
#account-settings {
    scroll-margin-top: calc(var(--header-height) + var(--space-4));
}

.account-menu__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 6rem;
}

@media (min-width: 993px) {
    .account-menu__name {
        max-width: 8rem;
    }
}

/* Persian datepicker dark mode */
[data-theme='dark'] .card,
[data-theme='dark'] .stat-card,
[data-theme='dark'] .sidebar {
    border-color: var(--border-color);
}

[data-theme='dark'] .main-nav {
    background: var(--surface-muted);
    border-color: var(--border-color);
}

[data-theme='dark'] .main-nav a.active {
    background: var(--surface-elevated);
    color: var(--accent);
}

[data-theme='dark'] tbody tr:hover {
    background-color: var(--accent-muted);
}

[data-theme='dark'] .chart-skeleton {
    background: linear-gradient(180deg, var(--surface-muted) 0%, var(--surface-elevated) 100%);
}

[data-theme='dark'] .chart-skeleton__pulse {
    background: linear-gradient(
        90deg,
        var(--surface-muted) 0%,
        var(--border-strong) 45%,
        var(--surface-muted) 90%
    );
    background-size: 200% 100%;
}

[data-theme='dark'] .pwt-datepicker-container,
[data-theme='dark'] .pwt-date-picker {
    background: var(--surface-elevated) !important;
    color: var(--bs-body-color) !important;
    border-color: var(--border-color) !important;
}

/* Chart panels — skeleton, error, fixed height to prevent CLS */
.chart-panel {
    position: relative;
    min-height: 12.5rem;
    min-width: 0;
    width: 100%;
    overflow: hidden;
}

.chart-panel canvas {
    display: block;
    width: 100% !important;
    height: auto !important;
    max-height: 280px;
}

.chart-panel canvas[hidden] {
    display: none;
}

.chart-skeleton {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-4);
    background: linear-gradient(180deg, var(--surface-muted) 0%, var(--surface-elevated) 100%);
    border-radius: var(--radius-md);
    overflow: hidden;
    z-index: 1;
}

.chart-skeleton[hidden] {
    display: none;
}

.chart-skeleton__pulse {
    flex: 1;
    border-radius: var(--radius-md);
    background: linear-gradient(
        90deg,
        var(--surface-muted) 0%,
        var(--border-color) 45%,
        var(--surface-muted) 90%
    );
    background-size: 200% 100%;
    animation: chart-skeleton-shimmer 1.4s ease-in-out infinite;
    min-height: 8rem;
}

@keyframes chart-skeleton-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

.chart-error {
    margin: var(--space-3) 0 0;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: var(--text-sm);
    text-align: center;
}

.chart-error[hidden] {
    display: none;
}

.chart-empty {
    padding: var(--space-5);
    text-align: center;
    color: var(--muted);
    font-size: var(--text-sm);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface-subtle);
}
