:root {
    --bg: #efe8dc;
    --bg-2: #f7f3ec;
    --ink: #221c16;
    --muted: #74685c;
    --line: #e3d8c8;
    --card: #fffdf9;
    --sidebar: #1a1613;
    --accent: #e25b2a;
    --accent-dark: #c4471b;
    --accent-soft: #fff1e8;
    --ok: #0f7a45;
    --ok-bg: #e5f6ec;
    --err: #a32626;
    --err-bg: #fdeaea;
    --shadow: 0 16px 40px rgba(48, 28, 12, 0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Vazirmatn, Tahoma, sans-serif;
    background:
        radial-gradient(circle at 100% 0, rgba(226, 91, 42, 0.12), transparent 28%),
        var(--bg);
    color: var(--ink);
}

a { color: inherit; }
button, input, select { font-family: inherit; }

.shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 272px 1fr;
}

.sidebar {
    background: var(--sidebar);
    color: #f6efe6;
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px; }
.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, #ff8a55, var(--accent));
    color: #fff;
    font-weight: 800;
}
.brand strong { display: block; font-size: 16px; }
.brand small, .sidebar-user small { color: #c9b8a6; display: block; margin-top: 2px; }

.sidebar nav { display: flex; flex-direction: column; gap: 6px; }
.sidebar nav a {
    text-decoration: none;
    color: #f3eadf;
    padding: 12px 12px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar nav a svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.sidebar nav a.active {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); }

.sidebar-user {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 10px 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-user { align-items: flex-start; }
.user-links { display: flex; flex-direction: column; gap: 6px; }
.user-links a {
    color: #ffd0bc;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 8px 10px;
    text-align: center;
}
.user-links a.active { background: rgba(255, 255, 255, 0.14); }
.password-card { max-width: 460px; }

.content { min-width: 0; padding: 28px 32px 56px; overflow-x: clip; }
.topbar { margin-bottom: 20px; }
.topbar h1 { margin: 0; font-size: 30px; letter-spacing: -0.03em; }
.lead { margin: 8px 0 0; color: var(--muted); line-height: 1.8; }

.cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}
.card, .panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 22px;
    box-shadow: var(--shadow);
}
.stat {
    padding: 18px 18px 16px;
    text-decoration: none;
    display: block;
    min-height: 132px;
}
.stat:hover { transform: translateY(-2px); }
.stat-kicker { color: var(--muted); font-size: 13px; }
.stat strong {
    display: block;
    margin: 10px 0 6px;
    font-size: 34px;
    letter-spacing: -0.04em;
}
.stat p { margin: 0; color: #8a7b6c; font-size: 13px; line-height: 1.7; }
.stat-honar { background: linear-gradient(180deg, #fff7f2, #fffdf9); }
.stat-iran { background: linear-gradient(180deg, #f3f7ff, #fffdf9); }
.stat-melo { background: linear-gradient(180deg, #f3fff7, #fffdf9); }

.panel { padding: 20px; }
.panel h2 { margin: 0 0 6px; font-size: 20px; }
.muted { color: var(--muted); line-height: 1.8; }

.source-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.source-card {
    text-decoration: none;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
    display: grid;
    gap: 4px;
}
.source-card strong { font-size: 16px; }
.source-card span { color: var(--muted); font-size: 13px; }
.source-card.active {
    border-color: #f0b89a;
    background: var(--accent-soft);
    box-shadow: inset 0 0 0 1px var(--accent);
}

.dropzone {
    margin-top: 16px;
    border: 1.5px dashed #e2b79a;
    background: #fff8f3;
    border-radius: 18px;
    min-height: 168px;
    display: grid;
    place-items: center;
    text-align: center;
    padding: 24px;
    cursor: pointer;
}
.dropzone.drag { background: #ffe8d8; border-color: var(--accent); }
.dropzone strong { font-size: 18px; }
.dropzone span { color: var(--muted); }
.file-input { display: none; }
.file-list { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.file-list li {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
}
.file-list small { color: var(--muted); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
button, .btn {
    border: 0;
    background: var(--accent);
    color: #fff;
    border-radius: 12px;
    padding: 12px 16px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}
button.secondary, .btn.secondary { background: #efe4d6; color: var(--ink); }
button:hover, .btn:hover { background: var(--accent-dark); }
button.secondary:hover, .btn.secondary:hover { background: #e6d5c2; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.alert { border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; line-height: 1.8; }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-err { background: var(--err-bg); color: var(--err); }

.filter-bar {
    display: grid;
    gap: 18px;
    background: #f7f1e8;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 18px;
    margin-bottom: 16px;
}
.filter-group {
    display: grid;
    gap: 12px;
    background: #fff;
    border: 1px solid #eadfD0;
    border-radius: 16px;
    padding: 14px;
}
.filter-group header h2 {
    margin: 0;
    font-size: 15px;
}
.filter-group header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 12px;
}
.search-row,
.filter-grid {
    display: grid;
    gap: 12px 14px;
}
.search-row { grid-template-columns: 1fr 1fr 1.1fr; }
.filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.field label,
label {
    display: block;
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: #3f352c;
}
input[type="text"], input[type="password"], input[type="search"], select {
    width: 100%;
    height: 46px;
    border: 1px solid #ddd2c3;
    background-color: #fff;
    border-radius: 12px;
    padding: 0 14px;
    color: var(--ink);
}
input[type="search"] { outline-offset: 2px; }
.filter-bar select {
    appearance: none;
    cursor: pointer;
    padding-left: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236f675c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    background-size: 16px;
}
.filter-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.filter-foot .actions { margin-top: 0; flex-wrap: wrap; }

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 8px 0 4px;
}
.count-pill {
    background: var(--accent-soft);
    color: var(--accent-dark);
    border-radius: 999px;
    padding: 6px 12px;
    font-weight: 700;
}

.table-wrap {
    overflow: hidden;
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 16px;
}
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td {
    text-align: right;
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
    white-space: normal;
    overflow-wrap: anywhere;
    font-size: 12.5px;
    line-height: 1.6;
    vertical-align: top;
}
th { color: #6d6256; font-weight: 700; background: #faf6f0; position: sticky; top: 0; }
tbody tr:hover td { background: #fff8f3; }
.empty { text-align: center; color: var(--muted); padding: 28px !important; }
.cell-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }

.badge { border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 700; }
.badge-on { background: var(--ok-bg); color: var(--ok); }
.badge-off { background: #f3eee6; color: var(--muted); }

.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
}
.pager-pages { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.pager-nav, .pager-page, .pager-gap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: #fff;
    text-decoration: none;
}
.pager-gap { border: 0; background: transparent; min-width: 24px; }
.pager-page.is-current {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
    font-weight: 700;
}
.pager-nav.is-disabled { opacity: 0.4; }
@media (max-width: 860px) {
    .pager { flex-wrap: wrap; justify-content: center; }
}

.auth-wrap {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
}
.auth-wrap.single {
    grid-template-columns: 1fr;
    place-items: center;
    padding: 24px;
}
.auth-side {
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background:
        linear-gradient(160deg, rgba(26, 22, 19, 0.2), rgba(26, 22, 19, 0.72)),
        radial-gradient(circle at 20% 20%, #ffb088, transparent 30%),
        #c4471b;
    color: #fff;
}
.auth-side h2 { margin: 0 0 8px; font-size: 40px; }
.auth-side p { margin: 0; max-width: 420px; line-height: 1.9; color: #ffe8dc; }
.auth-main { display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(440px, 100%); padding: 28px; }
.auth-card h1 { margin: 0 0 6px; }
.auth-card .sub { color: var(--muted); margin: 0 0 8px; }
.stack { display: grid; gap: 12px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.8; }

@media (max-width: 1100px) {
    .search-row, .filter-grid { grid-template-columns: 1fr 1fr; }
    .auth-wrap { grid-template-columns: 1fr; }
    .auth-side { min-height: 180px; padding: 28px; }
}
@media (max-width: 860px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .cards, .source-grid, .search-row, .filter-grid { grid-template-columns: 1fr; }
    .filter-foot { flex-direction: column; align-items: stretch; }
    .content { padding: 16px; }
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    table {
        min-width: 920px;
        table-layout: auto;
    }
    th, td {
        white-space: nowrap;
        overflow-wrap: normal;
    }
}
