@font-face {
    font-family: 'Vazir';
    src: url('Vazir-Regular-FD.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

:root {
    --primary-color: #6200ea;
    --secondary-color: #2979ff;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-color: #333333;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Vazir', sans-serif;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--text-color);
}

.container {
    background-color: var(--card-bg);
    width: 100%;
    max-width: 600px;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

header {
    text-align: center;
    margin-bottom: 25px;
}

header h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
}

header p {
    color: #666;
    font-size: 0.9em;
}

.tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid #eee;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    cursor: pointer;
    font-family: 'Vazir', sans-serif;
    font-size: 1em;
    color: #666;
    transition: 0.3s;
}
.ui-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.ui-icon svg {
    width: 100%;
    height: 100%;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom: 3px solid var(--primary-color);
    font-weight: bold;
}

/* Dark theme: header and tab colors */
html[data-theme="dark"] header h1,
html[data-resolved-theme="dark"] header h1,
:root[data-theme="dark"] header h1 {
    color: #00d4d4;
}

html[data-theme="dark"] .tab-btn.active,
html[data-resolved-theme="dark"] .tab-btn.active,
:root[data-theme="dark"] .tab-btn.active {
    color: #00d4d4;
    border-bottom-color: #00d4d4;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

textarea {
    width: 100%;
    height: 150px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Vazir', sans-serif;
    resize: vertical;
    margin-bottom: 15px;
    font-size: 1em;
}

input[type="text"], input[type="password"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Vazir', sans-serif;
    margin-bottom: 15px;
    font-size: 1em;
    transition: all 0.3s;
}

input[type="text"]:hover, input[type="password"]:hover {
    border-color: var(--primary-color);
}

input[type="text"]:focus, input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(98, 0, 234, 0.1);
}

select {
    width: 100%;
    padding: 12px 12px 12px 45px;
    background-color: #f9f9fb;
    color: #333;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: all 0.3s;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Vazir', sans-serif;
    font-size: 1em;
    line-height: 1.5;
    height: auto;
    margin-bottom: 15px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3e%3cpath fill='%23333' d='M1 1 L6 6 L11 1'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-size: 12px 8px;
    background-position: left 12px center;
}

select:hover {
    border-color: var(--primary-color);
    background-color: rgba(98, 0, 234, 0.03);
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(98, 0, 234, 0.1);
}

select option {
    background-color: #fff;
    color: #333;
    padding: 10px;
    border-radius: 6px;
    line-height: 1.5;
}

select option:checked {
    background: linear-gradient(var(--primary-color), var(--primary-color));
    color: white;
}

/* Dark theme inputs */
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="password"],
html[data-resolved-theme="dark"] input[type="text"],
html[data-resolved-theme="dark"] input[type="password"],
:root[data-theme="dark"] input[type="text"],
:root[data-theme="dark"] input[type="password"] {
    background-color: rgba(255, 255, 255, 0.04);
    color: #e8f1ff;
    border-color: rgba(0, 212, 212, 0.25);
}

html[data-theme="dark"] input[type="text"]:hover,
html[data-theme="dark"] input[type="password"]:hover,
html[data-resolved-theme="dark"] input[type="text"]:hover,
html[data-resolved-theme="dark"] input[type="password"]:hover,
:root[data-theme="dark"] input[type="text"]:hover,
:root[data-theme="dark"] input[type="password"]:hover {
    border-color: #00d4d4;
}

html[data-theme="dark"] input[type="text"]:focus,
html[data-theme="dark"] input[type="password"]:focus,
html[data-resolved-theme="dark"] input[type="text"]:focus,
html[data-resolved-theme="dark"] input[type="password"]:focus,
:root[data-theme="dark"] input[type="text"]:focus,
:root[data-theme="dark"] input[type="password"]:focus {
    border-color: #00d4d4;
    box-shadow: 0 0 0 3px rgba(0, 212, 212, 0.15);
}

/* Dark theme select */
html[data-theme="dark"] select,
html[data-resolved-theme="dark"] select,
:root[data-theme="dark"] select {
    background-color: rgba(255, 255, 255, 0.04);
    color: #e8f1ff;
    border: 1px solid rgba(0, 212, 212, 0.25);
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3e%3cpath fill='%2300d4d4' d='M1 1 L6 6 L11 1'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-size: 12px 8px;
    background-position: left 12px center;
}

html[data-theme="dark"] select:hover,
html[data-resolved-theme="dark"] select:hover,
:root[data-theme="dark"] select:hover {
    border-color: #00d4d4;
    background-color: rgba(0, 212, 212, 0.08);
}

html[data-theme="dark"] select:focus,
html[data-resolved-theme="dark"] select:focus,
:root[data-theme="dark"] select:focus {
    outline: none;
    border-color: #00d4d4;
    box-shadow: 0 0 0 3px rgba(0, 212, 212, 0.15);
}

html[data-theme="dark"] select option,
html[data-resolved-theme="dark"] select option,
:root[data-theme="dark"] select option {
    background-color: rgba(15, 25, 45, 0.95);
    color: #e8f1ff;
    padding: 10px;
    border-radius: 6px;
}

html[data-theme="dark"] select option:checked,
html[data-resolved-theme="dark"] select option:checked,
:root[data-theme="dark"] select option:checked {
    background: linear-gradient(#00d4d4, #00d4d4);
    color: #0a0f1f;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    text-align: right;
    color: #333;
    font-weight: 500;
    font-size: 0.95em;
}

.label-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    line-height: 1.3;
}

.input-group .label-with-icon .ui-icon,
.checkbox-group .label-with-icon .ui-icon {
    color: #5f6d84;
}

html[data-theme="dark"] .input-group label,
html[data-resolved-theme="dark"] .input-group label,
:root[data-theme="dark"] .input-group label {
    color: #d8e7ff;
}

.checkbox-group {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    color: #333;
    font-size: 0.95em;
    gap: 10px;
}

.checkbox-group label.label-with-icon {
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    background-color: #fff;
    position: relative;
    flex-shrink: 0;
}

.checkbox-group input[type="checkbox"]:hover:not(:checked) {
    border-color: var(--primary-color);
    background-color: rgba(98, 0, 234, 0.05);
}

.checkbox-group input[type="checkbox"]:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-group input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.checkbox-group input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(98, 0, 234, 0.1);
}

/* Dark theme checkbox */
html[data-theme="dark"] .checkbox-group label,
html[data-resolved-theme="dark"] .checkbox-group label,
:root[data-theme="dark"] .checkbox-group label {
    color: #e8f1ff;
}

html[data-theme="dark"] .checkbox-group input[type="checkbox"],
html[data-resolved-theme="dark"] .checkbox-group input[type="checkbox"],
:root[data-theme="dark"] .checkbox-group input[type="checkbox"] {
    border-color: rgba(0, 212, 212, 0.3);
    background-color: rgba(0, 212, 212, 0.02);
}

html[data-theme="dark"] .checkbox-group input[type="checkbox"]:hover:not(:checked),
html[data-resolved-theme="dark"] .checkbox-group input[type="checkbox"]:hover:not(:checked),
:root[data-theme="dark"] .checkbox-group input[type="checkbox"]:hover:not(:checked) {
    border-color: #00d4d4;
    background-color: rgba(0, 212, 212, 0.08);
}

html[data-theme="dark"] .checkbox-group input[type="checkbox"]:checked,
html[data-resolved-theme="dark"] .checkbox-group input[type="checkbox"]:checked,
:root[data-theme="dark"] .checkbox-group input[type="checkbox"]:checked {
    background-color: #00d4d4;
    border-color: #00d4d4;
}

html[data-theme="dark"] .checkbox-group input[type="checkbox"]:checked::after,
html[data-resolved-theme="dark"] .checkbox-group input[type="checkbox"]:checked::after,
:root[data-theme="dark"] .checkbox-group input[type="checkbox"]:checked::after {
    color: #0a0f1f;
}

html[data-theme="dark"] .checkbox-group input[type="checkbox"]:focus,
html[data-resolved-theme="dark"] .checkbox-group input[type="checkbox"]:focus,
:root[data-theme="dark"] .checkbox-group input[type="checkbox"]:focus {
    box-shadow: 0 0 0 3px rgba(0, 212, 212, 0.15);
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-family: 'Vazir', sans-serif;
    font-size: 1em;
    cursor: pointer;
    transition: 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-with-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-with-icon .ui-icon {
    width: 17px;
    height: 17px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #3700b3;
}

/* Dark theme: button colors */
html[data-theme="dark"] .btn-primary,
html[data-resolved-theme="dark"] .btn-primary,
:root[data-theme="dark"] .btn-primary {
    background-color: #00d4d4;
    color: #0a0f1f;
}

html[data-theme="dark"] .btn-primary:hover,
html[data-resolved-theme="dark"] .btn-primary:hover,
:root[data-theme="dark"] .btn-primary:hover {
    background-color: #00ebeb;
    color: #0a0f1f;
}

.btn-secondary {
    background-color: #e0e0e0;
    color: #333;
    margin-top: 10px;
}

.btn-secondary:hover {
    background-color: #d5d5d5;
}

.flash-messages {
    margin-bottom: 20px;
}

.flash {
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
    text-align: center;
}

.flash.error {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.success-box, .result-box, .direct-view-box {
    text-align: center;
}

.code-display, .link-display {
    font-size: 1.2em;
    font-weight: bold;
    color: var(--primary-color);
    background: #f3f4f6;
    padding: 15px;
    border-radius: 10px;
    margin: 10px 0;
    cursor: pointer;
    border: 2px dashed #ccc;
    transition: all 0.3s;
}

.code-display:hover, .link-display:hover {
    border-color: var(--primary-color);
    background: #e8eaf6;
}
.admin-login-form {
    text-align: right;
}

.admin-login-form label {
    width: 100%;
    text-align: right;
    display: block;
}

.copied-success-text {
    vertical-align: middle;
}

.copied-check-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
.admin-topbar-center {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    text-align: center;
    width: min(760px, calc(100% - 200px));
}
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    margin-right: 6px;
}

.copied-check-icon svg {
    width: 100%;
.admin-actions-left {
    position: absolute;
    left: 0;
    top: 0;
}
    height: 100%;
    fill: currentColor;
}
@keyframes progress {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}
 .code-display {
    font-size: 2.5em;
    letter-spacing: 8px;
    direction: ltr;
}

.link-display {
    font-size: 0.9em;
    word-break: break-all;
    direction: ltr;
}

.result-box textarea {
    background-color: #f9f9f9;
    color: #333;
    border: none;
    height: auto;
    min-height: 250px;
}

.result-box h3 {
    text-align: right;
}

/* Scrollbar styling for textarea - light theme */
textarea::-webkit-scrollbar {
    width: 8px;
}

textarea::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.04);
    border-radius: 10px;
}

textarea::-webkit-scrollbar-thumb {
    background: rgba(98, 0, 234, 0.25);
    border-radius: 10px;
    transition: background 0.3s;
}

textarea::-webkit-scrollbar-thumb:hover {
    background: rgba(98, 0, 234, 0.45);
}

/* Scrollbar styling for textarea - dark theme */
html[data-theme="dark"] textarea::-webkit-scrollbar-track,
html[data-resolved-theme="dark"] textarea::-webkit-scrollbar-track,
:root[data-theme="dark"] textarea::-webkit-scrollbar-track {
    background: rgba(0, 212, 212, 0.04);
}

html[data-theme="dark"] textarea::-webkit-scrollbar-thumb,
html[data-resolved-theme="dark"] textarea::-webkit-scrollbar-thumb,
:root[data-theme="dark"] textarea::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 212, 0.25);
}

html[data-theme="dark"] textarea::-webkit-scrollbar-thumb:hover,
html[data-resolved-theme="dark"] textarea::-webkit-scrollbar-thumb:hover,
:root[data-theme="dark"] textarea::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 212, 0.45);
}

/* Firefox scrollbar styling - light theme */
textarea {
    scrollbar-width: thin;
    scrollbar-color: rgba(98, 0, 234, 0.25) rgba(0, 0, 0, 0.04);
}

/* Firefox scrollbar styling - dark theme */
html[data-theme="dark"] textarea,
html[data-resolved-theme="dark"] textarea,
:root[data-theme="dark"] textarea {
    scrollbar-color: rgba(0, 212, 212, 0.25) rgba(0, 212, 212, 0.04);
}

.code-input-container {
    display: flex;
    gap: 16px;
    justify-content: center;
    direction: ltr;
    margin-top: 0px;
}

.view-code-group {
    margin-top: 30px;
    margin-bottom: 20px;
    padding: 6px 0;
}

.view-code-group label {
    margin-bottom: 8px;
}

.code-digit {
    width: 50px;
    height: 60px;
    padding: 5px;
    text-align: center;
    font-size: 1.5em;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-family: 'Vazir', sans-serif;
    transition: border-color 0.3s;
}

.code-digit:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* Dark theme: code digit focus */
html[data-theme="dark"] .code-digit:focus,
html[data-resolved-theme="dark"] .code-digit:focus,
:root[data-theme="dark"] .code-digit:focus {
    border-color: #00d4d4;
}

.admin-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(41, 121, 255, 0.12);
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9em;
    border: 1px solid rgba(41, 121, 255, 0.2);
}

.admin-link:hover {
    background: rgba(41, 121, 255, 0.18);
}

body.admin-page {
    font-family: 'Vazir', sans-serif;
    min-height: 100vh;
    background:
        radial-gradient(circle at top, rgba(33, 98, 232, 0.32), transparent 35%),
        linear-gradient(180deg, #07111f 0%, #0a1630 100%);
    color: #e8f1ff;
    padding: 28px;
    display: block;
}

.admin-shell {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
}

.admin-login-shell {
    min-height: calc(100vh - 56px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-panel,
.admin-card {
    background: rgba(8, 18, 38, 0.86);
    border: 1px solid rgba(96, 145, 255, 0.16);
    border-radius: 22px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(16px);
}

.admin-login-panel {
    width: 100%;
    max-width: 520px;
    padding: 34px;
}

.admin-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(73, 146, 255, 0.2), rgba(85, 122, 255, 0.32));
    color: #d9e8ff;
    font-size: 0.9em;
    letter-spacing: 0.2px;
    margin-bottom: 18px;
}

.admin-login-panel h1,
.admin-topbar h1 {
    color: #f2f7ff;
    margin-bottom: 10px;
}

.admin-login-panel p,
.admin-topbar p,
.admin-filter-note,
.chart-card-header p {
    color: #9eb8df;
    line-height: 1.8;
}

.admin-login-form {
    margin-top: 24px;
}

.admin-login-form label,
.admin-field label {
    display: block;
    margin-bottom: 8px;
    color: #d8e7ff;
}
html[data-theme="dark"] .input-group .label-with-icon .ui-icon,
html[data-resolved-theme="dark"] .input-group .label-with-icon .ui-icon,
:root[data-theme="dark"] .input-group .label-with-icon .ui-icon,
html[data-theme="dark"] .checkbox-group .label-with-icon .ui-icon,
html[data-resolved-theme="dark"] .checkbox-group .label-with-icon .ui-icon,
:root[data-theme="dark"] .checkbox-group .label-with-icon .ui-icon {
    color: #00d4d4;
}

.admin-page input[type="text"],
.admin-page input[type="password"],
.admin-page input[type="date"],
.admin-page select {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(157, 185, 237, 0.2);
    color: #eff6ff;
}

.admin-page input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1) opacity(0.8);
}

/* Improve date input appearance to match admin theme */
.admin-filter-form input[type="date"] {
    padding: 10px 14px;
    border-radius: 10px;
    height: 44px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.02), 0 6px 18px rgba(3,10,30,0.45);
    font-family: 'Vazir', sans-serif;
    font-size: 0.95rem;
    color: #e8f1ff;
    border: 1px solid rgba(157,185,237,0.08);
    padding-right: 12px;
}

.admin-filter-form input[type="date"]:focus {
    outline: none;
    border-color: rgba(77,201,255,0.9);
    box-shadow: 0 6px 30px rgba(77,201,255,0.06), 0 1px 0 rgba(255,255,255,0.02) inset;
}

/* Center admin page titles */
.admin-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 30px;
}

.admin-topbar-center {
    text-align: center;
    flex: 1;
}

.admin-actions-left {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.admin-field label {
    text-align: right;
    display: block;
}

/* Dashboard layout */
.dashboard-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.dashboard-top-row {
    display: grid;
    grid-template-columns: 1fr 1.35fr;
    gap: 24px;
    align-items: start;
}

.dashboard-stats-column {
    min-width: 0;
}

.dashboard-main-chart-column,
.dashboard-full-chart {
    min-width: 0;
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.chart-card {
    padding: 22px;
}

.dashboard-main-chart-column .chart-wrap {
    height: 100%;
    min-height: 320px;
}

.dashboard-full-chart .chart-wrap {
    height: 360px;
}

.chart-wrap-wide {
    width: 100%;
}

.admin-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(73, 146, 255, 0.1);
    color: #4d9aff;
    border: 1px solid rgba(77, 201, 255, 0.2);
    transition: 0.3s;
    text-decoration: none;
}

.admin-icon-btn:hover {
    background: rgba(77, 201, 255, 0.2);
    border-color: rgba(77, 201, 255, 0.4);
}

.admin-login-panel-centered {
    text-align: center;
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}


.admin-page input::placeholder {
    color: #8ea8cf;
}

.admin-btn-primary {
    background: linear-gradient(135deg, #2f78ff, #4dcbff);
    color: white;
    box-shadow: 0 14px 30px rgba(52, 129, 255, 0.22);
}

.admin-btn-primary:hover {
    filter: brightness(1.06);
}

.admin-ghost-btn {
    width: auto;
    padding-inline: 18px;
    background: rgba(255, 255, 255, 0.04);
    color: #dceaff;
    border: 1px solid rgba(157, 185, 237, 0.15);
}

.admin-ghost-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.admin-topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: flex-end;
}

.admin-filter-card,
.table-card,
.chart-card {
    padding: 22px;
}

.admin-filter-form {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    align-items: end;
}

.admin-field-actions .btn {
    margin-top: 0;
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px;
    margin: 20px 0;
}

.stat-card {
    padding: 22px;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.stat-card span {
    color: #8ea8cf;
    font-size: 0.95em;
}

.stat-card strong {
    color: #f4f8ff;
    font-size: 2.1rem;
    line-height: 1.1;
}

.admin-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.chart-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.chart-card h2,
.table-card h2 {
    color: #f2f7ff;
    margin-bottom: 4px;
    font-size: 1.15rem;
}

.chart-wrap {
    position: relative;
    height: 320px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 6px;
}

.admin-table th,
.admin-table td {
    padding: 14px 12px;
    border-bottom: 1px solid rgba(157, 185, 237, 0.12);
    text-align: right;
}

.admin-table th {
    color: #cfe1ff;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.03);
}

.admin-table td {
    color: #e9f2ff;
}

.admin-table tbody tr:hover {
    background: rgba(73, 146, 255, 0.06);
}

.empty-state {
    text-align: center !important;
    color: #9eb8df !important;
    padding: 24px 12px !important;
}

.table-responsive {
    overflow-x: auto;
}

@media (max-width: 1100px) {
    .admin-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .admin-chart-grid {
        grid-template-columns: 1fr;
    }

    .admin-filter-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    body.admin-page {
        padding: 18px;
    }

    .admin-topbar {
        flex-direction: column;
    }

    .admin-actions {
        width: 100%;
        justify-content: stretch;
    }

    .admin-actions .btn {
        width: 100%;
    }

    .admin-stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card strong {
        font-size: 1.8rem;
    }

    .chart-wrap {
        height: 260px;
    }
}

/* Final overrides to win over earlier dashboard rules */
.admin-login-form {
    text-align: right;
}

.admin-login-form label {
    width: 100%;
    text-align: right;
    display: block;
}

.admin-topbar {
    position: relative;
    display: block;
    min-height: 96px;
    margin-bottom: 20px;
}

.admin-topbar-center {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    text-align: center;
    width: min(760px, calc(100% - 240px));
}

.admin-actions-left {
    position: absolute;
    left: 0;
    top: 0;
    display: flex;
    gap: 12px;
}

.dashboard-top-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
}

.dashboard-main-chart-column .chart-wrap {
    min-height: 320px;
}

.dashboard-full-chart .chart-wrap {
    min-height: 360px;
}

@media (max-width: 1100px) {
    .dashboard-top-row {
        grid-template-columns: 1fr;
    }

    .admin-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .admin-topbar {
        min-height: auto;
    }

    .admin-topbar-center {
        position: static;
        transform: none;
        width: 100%;
        margin-top: 56px;
    }

    .admin-actions-left {
        position: static;
        width: 100%;
        justify-content: flex-start;
    }

    .admin-stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card strong {
        font-size: 1.8rem;
    }

    .dashboard-full-chart .chart-wrap,
    .dashboard-main-chart-column .chart-wrap {
        min-height: 260px;
    }
}

/* Final dashboard overrides */
.admin-login-form,
.admin-login-form label {
    text-align: right !important;
}

.admin-login-form label {
    display: block !important;
    width: 100% !important;
}

.admin-topbar {
    position: relative !important;
    display: block !important;
    min-height: 150px !important;
    margin-bottom: 44px !important;
}

.admin-topbar-center {
    position: absolute !important;
    left: 50% !important;
    top: 0 !important;
    transform: translateX(-50%) !important;
    width: min(820px, calc(100% - 260px)) !important;
    text-align: center !important;
}

.admin-actions-left {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    display: flex !important;
    gap: 12px !important;
}

.dashboard-layout {
    gap: 28px !important;
    margin-top: 8px !important;
}

.dashboard-top-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) !important;
    gap: 24px !important;
    align-items: start !important;
    align-items: stretch !important;
}

.admin-stats-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 16px !important;
    margin: 0 !important;
    grid-auto-rows: minmax(0, 1fr) !important;
    height: 100% !important;
}

.stat-card {
    min-height: 140px !important;
}

.dashboard-hourly-section {
    display: flex !important;
    flex-direction: column !important;
    gap: 22px !important;
    margin-top: 18px !important;
}

.dashboard-filter-card {
    margin-bottom: 0 !important;
}

.dashboard-hourly-chart .chart-wrap,
.dashboard-main-chart-column .chart-wrap {
    min-height: 320px !important;
}

.dashboard-hourly-chart .chart-wrap {
    min-height: 360px !important;
}

.dashboard-ip-card {
    margin-top: 12px !important;
}

@media (max-width: 1100px) {
    .dashboard-top-row {
        grid-template-columns: 1fr !important;
    }

    .admin-stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 700px) {
    .admin-topbar {
        min-height: auto !important;
    }

    .admin-topbar-center {
        position: static !important;
        transform: none !important;
        width: 100% !important;
        margin-top: 56px !important;
    }

    .admin-actions-left {
        position: static !important;
        width: 100% !important;
        justify-content: flex-start !important;
    }

    .admin-stats-grid {
        grid-template-columns: 1fr !important;
    }

    .stat-card strong {
        font-size: 1.8rem !important;
    }

    .dashboard-hourly-chart .chart-wrap,
    .dashboard-main-chart-column .chart-wrap {
        min-height: 260px !important;
    }
}

/* Hard overrides for the dashboard layout so chart titles stay visible and stat cards fill the same height */
.dashboard-top-row {
    align-items: stretch !important;
}

.dashboard-stats-column {
    display: flex !important;
    min-height: 100% !important;
}

.admin-stats-grid {
    flex: 1 1 auto !important;
    height: 100% !important;
    grid-template-rows: repeat(2, minmax(0, 1fr)) !important;
}

.stat-card {
    min-height: 0 !important;
}

.dashboard-main-chart-column.admin-card,
.dashboard-hourly-chart.admin-card {
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
}

.dashboard-main-chart-column .chart-wrap,
.dashboard-hourly-chart .chart-wrap {
    flex: 1 1 auto !important;
    min-height: 0 !important;
}

.dashboard-stats-column,
.dashboard-main-chart-column {
    height: 100% !important;
}

.dashboard-hourly-section {
    gap: 24px !important;
    margin-top: 6px !important;
}

.dashboard-ip-card {
    margin-top: 20px !important;
}

@media (max-width: 1100px) {
    .dashboard-stats-column {
        min-height: auto !important;
    }

    .admin-stats-grid {
        height: auto !important;
        grid-template-rows: none !important;
    }
}

/* ===== Public page theme system ===== */
:root {
    --public-bg-start: #07111f;
    --public-bg-end: #0a1630;
    --public-card-bg: rgba(8, 18, 38, 0.86);
    --public-card-border: rgba(96, 145, 255, 0.16);
    --public-text: #e8f1ff;
    --public-muted: #9eb8df;
    --public-input-bg: rgba(255, 255, 255, 0.04);
    --public-input-border: rgba(157, 185, 237, 0.2);
    --public-tab-border: rgba(157, 185, 237, 0.2);
    --public-tab-text: #9eb8df;
    --public-secondary-bg: rgba(255, 255, 255, 0.08);
    --public-secondary-text: #dceaff;
    --public-code-bg: rgba(255, 255, 255, 0.05);
    --public-code-border: rgba(157, 185, 237, 0.25);
    --public-admin-link-bg: rgba(77, 164, 255, 0.2);
    --public-admin-link-border: rgba(98, 180, 255, 0.45);
    --public-admin-link-text: #eef6ff;
}

html[data-resolved-theme='light'] {
    --public-bg-start: #dbe9ff;
    --public-bg-end: #f1f6ff;
    --public-card-bg: rgba(255, 255, 255, 0.92);
    --public-card-border: rgba(41, 121, 255, 0.18);
    --public-text: #1d2a3e;
    --public-muted: #516b94;
    --public-input-bg: rgba(255, 255, 255, 0.98);
    --public-input-border: rgba(72, 116, 189, 0.22);
    --public-tab-border: rgba(72, 116, 189, 0.22);
    --public-tab-text: #4a6389;
    --public-secondary-bg: #e8eefb;
    --public-secondary-text: #22344f;
    --public-code-bg: #f4f7ff;
    --public-code-border: rgba(72, 116, 189, 0.25);
    --public-admin-link-bg: rgba(41, 121, 255, 0.12);
    --public-admin-link-border: rgba(41, 121, 255, 0.2);
    --public-admin-link-text: #2b4e88;
}

body:not(.admin-page) {
    background:
        radial-gradient(circle at top, rgba(33, 98, 232, 0.30), transparent 34%),
        radial-gradient(circle at 9% 40%, rgba(77, 201, 255, 0.18), transparent 24%),
        radial-gradient(circle at 88% 22%, rgba(120, 120, 255, 0.16), transparent 26%),
        radial-gradient(circle at 76% 82%, rgba(73, 146, 255, 0.14), transparent 28%),
        linear-gradient(180deg, var(--public-bg-start) 0%, var(--public-bg-end) 100%) !important;
    color: var(--public-text) !important;
}

body:not(.admin-page) .container {
    background: var(--public-card-bg) !important;
    border: 1px solid var(--public-card-border);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(14px);
}

body:not(.admin-page) header h1,
body:not(.admin-page) h3,
body:not(.admin-page) p,
body:not(.admin-page) label {
    color: var(--public-text);
}

body:not(.admin-page) header p,
body:not(.admin-page) .tab-btn,
body:not(.admin-page) .flash.error,
body:not(.admin-page) .copied-success-text {
    color: var(--public-muted);
}

body:not(.admin-page) .tabs {
    border-bottom-color: var(--public-tab-border);
}

body:not(.admin-page) .tab-btn {
    color: var(--public-tab-text);
}

body:not(.admin-page) textarea,
body:not(.admin-page) input[type="text"],
body:not(.admin-page) input[type="password"],
body:not(.admin-page) select,
body:not(.admin-page) .code-digit {
    background: var(--public-input-bg);
    border-color: var(--public-input-border);
    color: var(--public-text);
}

body:not(.admin-page) input[type="password"],
body:not(.admin-page) select {
    min-height: 46px;
    line-height: 1.5;
}

body:not(.admin-page) select {
    padding-left: 45px;
    padding-right: 12px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3e%3cpath fill='%2333445c' d='M1 1 L6 6 L11 1'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-size: 12px 8px;
    background-position: left 12px center;
}

html[data-resolved-theme='dark'] body:not(.admin-page) select,
html[data-theme='dark'] body:not(.admin-page) select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3e%3cpath fill='%2300d4d4' d='M1 1 L6 6 L11 1'/%3e%3c/svg%3e");
    background-position: left 12px center;
}

body:not(.admin-page) .btn-secondary {
    background: var(--public-secondary-bg);
    color: var(--public-secondary-text);
}

body:not(.admin-page) .code-display,
body:not(.admin-page) .link-display {
    background: var(--public-code-bg);
    border-color: var(--public-code-border);
}

body:not(.admin-page) .code-display:hover,
body:not(.admin-page) .link-display:hover {
    background: color-mix(in srgb, var(--public-code-bg) 75%, #2f78ff 25%);
}

body:not(.admin-page) .admin-link {
    background: var(--public-admin-link-bg);
    border-color: var(--public-admin-link-border);
    color: var(--public-admin-link-text);
}

body:not(.admin-page) .admin-link:hover {
    background: color-mix(in srgb, var(--public-admin-link-bg) 80%, #4dcbff 20%);
}

.public-top-actions {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 10px;
}

.theme-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--public-card-border);
    background: var(--public-input-bg);
    color: var(--public-text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
    transform: translateY(-1px);
    background: color-mix(in srgb, var(--public-input-bg) 80%, #2f78ff 20%);
}

.theme-toggle-btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
/* Code alert boxes — light and dark theme styles */
.code-alert {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 12px;
    text-align: center;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffe8a1;
    font-size: 0.98rem;
    direction: rtl;
}

.admin-page .code-alert,
.theme-dark .code-alert,
body.admin-page .code-alert,
body.theme-dark .code-alert,
html[data-theme="dark"] .code-alert,
html[data-resolved-theme="dark"] .code-alert,
:root[data-theme="dark"] .code-alert {
    background: linear-gradient(180deg, rgba(255,69,58,0.06), rgba(0,0,0,0.02));
    color: #fff2f1;
    border: 1px solid rgba(223, 116, 110, 0.306);
    box-shadow: 0 5px 14px rgba(0,0,0,0.5);
}

.admin-page .flash.error,
.theme-dark .flash.error,
body.admin-page .flash.error,
body.theme-dark .flash.error,
html[data-theme="dark"] .flash.error,
html[data-resolved-theme="dark"] .flash.error,
:root[data-theme="dark"] .flash.error {
    background: linear-gradient(180deg, rgba(232, 108, 108, 0.272), rgba(188, 83, 83, 0.24));
    color: #fff3f3;
    border: 1px solid rgba(223, 94, 94, 0.372);
    box-shadow: 0 5px 14px rgba(0,0,0,0.52);
}

/* Dark theme: code-display and link-display with bright cyan/blue */
html[data-theme="dark"] .code-display,
html[data-theme="dark"] .link-display,
html[data-resolved-theme="dark"] .code-display,
html[data-resolved-theme="dark"] .link-display,
:root[data-theme="dark"] .code-display,
:root[data-theme="dark"] .link-display {
    color: #00d4d4;
    background: rgba(0, 212, 212, 0.06);
    border: 2px dashed rgba(0, 212, 212, 0.25);
}

html[data-theme="dark"] .code-display:hover,
html[data-theme="dark"] .link-display:hover,
html[data-resolved-theme="dark"] .code-display:hover,
html[data-resolved-theme="dark"] .link-display:hover,
:root[data-theme="dark"] .code-display:hover,
:root[data-theme="dark"] .link-display:hover {
    background: rgba(0, 212, 212, 0.10);
    border-color: rgba(0, 212, 212, 0.35);
}

