:root {
    --bg: #f6f3ee;
    --bg-strong: #eef2f6;
    --card: #ffffff;
    --ink: #1f2933;
    --muted: #667085;
    --brand: #0f766e;
    --brand-strong: #0b5f59;
    --accent: #f59e0b;
    --danger: #dc2626;
    --border: #e3e7ee;
    --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
    --radius: 16px;
    --radius-sm: 10px;
}

* { box-sizing: border-box; }

body {
    font-family: 'IRANSans', 'Vazirmatn', Tahoma, sans-serif;
    margin: 0;
    background: linear-gradient(135deg, #f6f3ee 0%, #eef2f6 55%, #f7f2e9 100%);
    color: var(--ink);
    min-height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 12% 10%, rgba(15, 118, 110, 0.08), transparent 35%),
        radial-gradient(circle at 85% 0%, rgba(245, 158, 11, 0.12), transparent 40%),
        radial-gradient(circle at 90% 75%, rgba(15, 118, 110, 0.06), transparent 40%);
    z-index: -1;
    pointer-events: none;
}

img { max-width: 100%; }

a { color: inherit; text-decoration: none; }

.page {
    max-width: 1200px;
    margin: 2.5rem auto;
    padding: 0 1.2rem 4rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.page-title {
    margin: 0;
    font-size: 1.7rem;
}

.page-subtitle {
    margin: 0.4rem 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.topbar,
.top-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 1.4rem;
    background: linear-gradient(90deg, #0f766e, #1f8f83);
    color: #fff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
}

.topbar__brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.brand-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.16);
}

.brand-logo {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px;
}

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

.nav-link {
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    color: #fff;
    font-size: 0.9rem;
    opacity: 0.8;
    transition: all 0.2s ease;
}

.nav-link:hover { opacity: 1; background: rgba(255, 255, 255, 0.18); }

.nav-link.is-active {
    background: #fff;
    color: #0f766e;
    opacity: 1;
    font-weight: 700;
}

.topbar__actions {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.btn,
button,
input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: none;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    padding: 0.7rem 1.4rem;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: 0 8px 18px rgba(15, 118, 110, 0.2);
}

.btn:hover,
button:hover,
input[type="submit"]:hover {
    background: var(--brand-strong);
    transform: translateY(-1px);
}

.btn-secondary { background: #e2e8f0; color: #1f2933; box-shadow: none; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-ghost { background: transparent; border: 1px solid rgba(255, 255, 255, 0.4); box-shadow: none; }
.btn-danger { background: var(--danger); box-shadow: 0 8px 18px rgba(220, 38, 38, 0.2); }
.small-btn { padding: 0.45rem 0.9rem; font-size: 0.85rem; box-shadow: none; }

.card,
.panel {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.5rem 1.8rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card h3 { margin: 0; font-size: 0.95rem; color: var(--muted); }
.card .value { font-size: 2rem; font-weight: 700; margin-top: 0.4rem; }

.section {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 1rem 1.4rem;
    background: #fff;
    margin-bottom: 1.2rem;
}

details.section { padding: 0; overflow: hidden; }
details.section > summary {
    list-style: none;
    cursor: pointer;
    padding: 1rem 1.4rem;
    font-weight: 700;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::after {
    content: '+';
    font-size: 1rem;
    color: var(--brand);
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: #e2e8f0;
}
details.section[open] > summary::after { content: '–'; }
details.section .section-body { padding: 1.1rem 1.4rem 1.4rem; }

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0.6rem 0.8rem;
}
.feature-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.65rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 0.9rem;
}
.feature-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
    margin-bottom: 1.4rem;
}

.stat-card {
    background: #fff;
    border-radius: 16px;
    padding: 1rem 1.2rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.stat-label { font-size: 0.85rem; color: var(--muted); }
.stat-value { font-size: 1.9rem; font-weight: 700; }
.stat-meta { font-size: 0.78rem; color: var(--muted); }
.stat-card.stat-ok .stat-value { color: #059669; }
.stat-card.stat-danger .stat-value { color: #b91c1c; }
.stat-card.stat-warn .stat-value { color: #b45309; }

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.8rem;
}
.section-title h2 { margin: 0; font-size: 1.1rem; }
.section-meta { font-size: 0.85rem; color: var(--muted); }

.notice-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.notice-bar .form-note { margin: 0; }

.grid-tight { gap: 0.6rem 1rem; }

.weather-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem 1.6rem;
    align-items: start;
}

.autocomplete-wrapper { position: relative; }
.autocomplete-list {
    position: absolute;
    inset-inline-start: 0;
    inset-inline-end: 0;
    top: 100%;
    margin-top: 4px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
    max-height: 220px;
    overflow-y: auto;
    z-index: 20;
    display: none;
    padding: 6px 0;
}
.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
}
.autocomplete-item:hover { background: #f3f4f6; }
.autocomplete-sub { color: var(--muted); font-size: 0.85rem; }

.weather-note { color: var(--muted); font-size: 0.9rem; margin-top: 0.6rem; }

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

label { display: block; margin-top: 0.6rem; font-weight: 600; color: var(--ink); }

input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #f8fafc;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="file"] { padding: 0.5rem 0.3rem; }

textarea { min-height: 120px; resize: vertical; }

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
    background: #fff;
}

.helper,
small,
.form-note {
    color: var(--muted);
    font-size: 0.85rem;
}

.muted-label { opacity: 0.8; }
.text-success { color: #059669; }
.text-danger { color: #b91c1c; }
.mt-0 { margin-top: 0; }
.mt-xs { margin-top: 0.3rem; }
.mt-sm { margin-top: 0.6rem; }
.mt-md { margin-top: 1rem; }
.mt-lg { margin-top: 1.5rem; }
.mb-xs { margin-bottom: 0.3rem; }
.mb-sm { margin-bottom: 0.6rem; }
.mb-md { margin-bottom: 1rem; }
.my-xs { margin: 0.2rem 0; }
.note-tight { margin-top: 0.2rem; }

.qr-preview { margin: 0.4rem 0; }
.preview-img {
    max-width: 180px;
    border: 1px solid #e5e7eb;
    background: #fff;
    padding: 4px;
}
.flag-preview { width: 32px; height: 20px; margin-top: 4px; }
.input-narrow { width: 80px; }
.file-input { padding: 0.4rem 0.6rem; }
.col-actions { min-width: 180px; }
.input-wide { min-width: 220px; }
.lang-name { min-width: 160px; }
.center-cell { text-align: center; }
.lang-table td { vertical-align: middle; }
.check-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    justify-content: center;
    font-size: 0.85rem;
}
.check-pill input[type="checkbox"] {
    width: 16px;
    height: 16px;
}
.file-input {
    font-size: 0.85rem;
    background: #f8fafc;
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 0.35rem 0.45rem;
}
.file-input::file-selector-button {
    border: none;
    border-radius: 8px;
    padding: 0.35rem 0.65rem;
    background: #e2e8f0;
    color: #1f2933;
    cursor: pointer;
    margin-inline-end: 0.5rem;
}

.lang-table {
    table-layout: fixed;
}
.lang-table input[type="text"] {
    padding: 0.45rem 0.6rem;
    font-size: 0.88rem;
}

.flag-details {
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 0.5rem 0.6rem;
    background: #f8fafc;
}
.flag-summary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--muted);
}
.flag-summary::-webkit-details-marker { display: none; }
.flag-summary::after {
    content: 'ویرایش';
    margin-inline-start: auto;
    color: var(--brand);
    font-weight: 700;
    font-size: 0.8rem;
}
.flag-preview-wrap {
    width: 34px;
    height: 24px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.flag-preview {
    width: 24px;
    height: 16px;
    margin: 0;
}
.flag-placeholder {
    width: 24px;
    height: 16px;
    background: #e2e8f0;
    border-radius: 4px;
}
.flag-fields {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-weight: 600;
}
.alert--success { background: #ecfdf3; color: #0d6832; border: 1px solid #bbf7d0; }
.alert--error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecdd3; }
.alert--info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

.table-wrap { width: 100%; overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.8rem;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
}
th, td {
    border: 1px solid #e5e7eb;
    padding: 0.65rem;
    text-align: center;
    font-size: 0.92rem;
}
th { background: #f8fafc; font-weight: 700; color: #334155; }
tr:nth-child(even) { background: #fafbfc; }
.table-compact tr.is-selected { background: #ecfdf3; }

.table-compact th,
.table-compact td {
    padding: 0.45rem 0.55rem;
    vertical-align: middle;
}

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

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 0 0 1.2rem;
}
.tab-link {
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--ink);
    background: #fff;
    transition: all 0.2s ease;
}
.tab-link:hover { border-color: var(--brand); color: var(--brand); }
.tab-link.is-active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 700;
}

.camera-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.8rem 1.2rem;
    margin-bottom: 1rem;
    padding: 1rem 1.2rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #f8fafc;
}
.camera-row > div label { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.2rem; }
.checkbox-group { display: flex; align-items: center; gap: 0.4rem; }

.search-input {
    max-width: 320px;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}
.badge--green { background: #ecfdf3; color: #0d6832; }
.badge--gray { background: #e5e7eb; color: #334155; }
.badge--red { background: #fee2e2; color: #b91c1c; }

.status-chip {
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.status-chip--ok { background: #ecfdf3; color: #0d6832; }
.status-chip--warn { background: #fff7ed; color: #9a3412; }
.status-chip--off { background: #fee2e2; color: #b91c1c; }

.ltr { direction: ltr; text-align: left; font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace; font-size: 0.85rem; }
.mono { font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace; }

.inline-actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
}
.inline-actions select {
    width: auto;
    min-width: 110px;
}
.inline-actions button {
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
    box-shadow: none;
}

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; box-shadow: none; }

.status-form {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
}
.status-form select { min-width: 110px; }

.actions-cell { min-width: 190px; vertical-align: middle; }
.actions-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    justify-content: center;
}
.actions-link { font-size: 0.85rem; color: var(--muted); }

.details-card { scroll-margin-top: 110px; }

.save-bar {
    position: sticky;
    bottom: 0.8rem;
    display: none;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1.2rem;
    border-radius: 999px;
    background: #111827;
    color: #fff;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.2);
    margin-top: 1.5rem;
}

.url-cell { direction: ltr; font-size: 0.82rem; word-break: break-word; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
}
.modal-card {
    background: #fff;
    border-radius: 16px;
    padding: 1.4rem 1.6rem;
    width: min(92vw, 540px);
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
}
.modal-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: flex-end;
    margin-top: 1rem;
}
.modal-close {
    float: left;
    cursor: pointer;
    color: var(--muted);
    font-weight: 700;
}

.save-bar.is-visible { display: flex; }

.save-status { font-size: 0.85rem; opacity: 0.85; }

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.login-card {
    width: min(420px, 100%);
    border-radius: 20px;
    padding: 2.2rem;
    background: #fff;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
    border: 1px solid var(--border);
}

.login-card h1 { margin: 0 0 1.2rem; text-align: center; }
.login-card .brand-dot { margin: 0 auto 0.8rem; }

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

@media (max-width: 900px) {
    .page-header { flex-direction: column; align-items: flex-start; }
    .topbar { flex-direction: column; align-items: flex-start; }
    .topbar__actions { width: 100%; justify-content: flex-end; }
}
