:root {
    --bg: #f4f7f3;
    --bg-accent: radial-gradient(circle at top right, rgba(40, 167, 146, 0.18), transparent 28%), radial-gradient(circle at left bottom, rgba(244, 162, 97, 0.18), transparent 24%), #f4f7f3;
    --panel: rgba(255, 255, 255, 0.86);
    --panel-strong: #ffffff;
    --text: #15352f;
    --muted: #658078;
    --line: rgba(21, 53, 47, 0.1);
    --primary: #0f8f78;
    --primary-dark: #0a6e5d;
    --secondary: #e9f3ef;
    --danger: #d25555;
    --shadow: 0 24px 60px rgba(21, 53, 47, 0.10);
    --radius: 22px;
    --radius-sm: 14px;
    --font: "Vazirmatn", "IRANSansX", Tahoma, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg-accent);
    color: var(--text);
    font-family: var(--font);
}

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

button,
input,
select,
textarea {
    font: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    padding: 28px 20px;
    backdrop-filter: blur(18px);
    background: rgba(9, 37, 31, 0.92);
    color: #ecf7f4;
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-badge {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #15b392, #f4a261);
    color: #08352d;
    font-weight: 800;
}

.brand small,
.muted {
    color: var(--muted);
}

.sidebar .muted,
.sidebar small {
    color: rgba(236, 247, 244, 0.68);
}

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

.menu-group-label {
    margin-top: 10px;
    padding: 6px 8px 2px;
    color: rgba(236, 247, 244, 0.55);
    font-size: 0.78rem;
}

.menu a {
    padding: 12px 14px;
    border-radius: 14px;
    color: rgba(236, 247, 244, 0.86);
    transition: 0.2s ease;
}

.menu a.active,
.menu a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.main-panel {
    padding: 24px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.topbar h1,
.auth-card h1,
.section-head h2 {
    margin: 0;
}

.topbar h1 {
    font-size: 1.8rem;
}

.topbar-user {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.content {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.card,
.stat-card {
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    backdrop-filter: blur(18px);
}

.card {
    padding: 22px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 16px;
}

.stat-card {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-card strong {
    font-size: 2rem;
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.module-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.table-chip {
    min-width: 140px;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(233, 243, 239, 0.92);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(15, 143, 120, 0.08);
}

.table-chip strong {
    color: var(--primary-dark);
}

.module-metrics {
    display: flex;
    gap: 12px;
    color: var(--muted);
}

.entity-card {
    min-width: 190px;
    padding: 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.entity-card small {
    color: var(--muted);
}

.entity-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 20px;
}

.entity-header h2 {
    margin: 0 0 8px;
}

.entity-header-stats {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.entity-stat-box {
    min-width: 140px;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(15, 143, 120, 0.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.entity-stat-box small {
    color: var(--muted);
}

.entity-stat-box strong {
    font-size: 1.05rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.detail-item {
    padding: 14px;
    border-radius: 16px;
    background: rgba(233, 243, 239, 0.55);
    border: 1px solid rgba(15, 143, 120, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-item span {
    color: var(--muted);
    font-size: 0.9rem;
}

.detail-item strong {
    word-break: break-word;
    font-size: 0.95rem;
}

.entity-list-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.entity-list-card {
    padding: 18px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(15, 143, 120, 0.08);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.entity-list-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.entity-list-head h3 {
    margin: 0 0 6px;
    font-size: 1.02rem;
}

.entity-list-head p,
.entity-snippet {
    margin: 0;
    color: var(--muted);
    line-height: 1.8;
}

.entity-list-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    color: var(--muted);
    font-size: 0.92rem;
}

.entity-kpi-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.entity-kpi-row div {
    padding: 12px 13px;
    border-radius: 16px;
    background: rgba(233, 243, 239, 0.72);
    border: 1px solid rgba(15, 143, 120, 0.06);
}

.entity-kpi-row small {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
}

.entity-kpi-row strong {
    font-size: 0.96rem;
}

.entity-card-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 82px;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 0.82rem;
    background: rgba(21, 53, 47, 0.08);
    color: var(--text);
}

.status-badge.active,
.status-badge.success,
.status-badge.completed,
.status-badge.resolved {
    background: rgba(15, 143, 120, 0.12);
    color: #0b715f;
}

.status-badge.failed,
.status-badge.blocked,
.status-badge.rejected {
    background: rgba(210, 85, 85, 0.12);
    color: #9f2a2a;
}

.status-badge.pending,
.status-badge.processing,
.status-badge.in_progress,
.status-badge.warning {
    background: rgba(244, 162, 97, 0.16);
    color: #9a5a16;
}

.status-badge.info,
.status-badge.user,
.status-badge.assistant,
.status-badge.system {
    background: rgba(42, 157, 143, 0.12);
    color: #17695f;
}

.empty-state {
    padding: 28px;
    border-radius: 18px;
    text-align: center;
    color: var(--muted);
    background: rgba(233, 243, 239, 0.6);
}

.chat-thread {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-bubble {
    max-width: 88%;
    padding: 16px 18px;
    border-radius: 20px;
    background: rgba(233, 243, 239, 0.78);
    border: 1px solid rgba(15, 143, 120, 0.08);
}

.chat-bubble.user {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.86);
}

.chat-bubble.assistant {
    align-self: flex-end;
    background: rgba(15, 143, 120, 0.10);
}

.chat-bubble.system {
    align-self: center;
    background: rgba(21, 53, 47, 0.08);
}

.chat-bubble-head,
.chat-bubble-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 0.86rem;
}

.chat-bubble-body {
    margin: 10px 0;
    line-height: 1.9;
    white-space: normal;
    word-break: break-word;
}

.message-panel {
    padding: 18px;
    border-radius: 18px;
    background: rgba(233, 243, 239, 0.6);
    line-height: 1.9;
}

.message-panel p {
    margin: 10px 0 0;
}

.report-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.report-box {
    padding: 18px;
    border-radius: 18px;
    line-height: 1.9;
}

.report-box span {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 0.88rem;
}

.report-box p {
    margin: 0;
}

.report-box.user {
    background: rgba(255, 255, 255, 0.85);
}

.report-box.assistant {
    background: rgba(15, 143, 120, 0.10);
}

.report-box.notes {
    background: rgba(244, 162, 97, 0.12);
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.quick-card {
    padding: 18px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(15, 143, 120, 0.10), rgba(244, 162, 97, 0.10));
    border: 1px solid rgba(15, 143, 120, 0.08);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-card small {
    color: var(--muted);
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.bar-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.bar-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bar-meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.bar-track {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: rgba(21, 53, 47, 0.08);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 999px;
}

.hero-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    background: linear-gradient(135deg, rgba(15, 143, 120, 0.12), rgba(244, 162, 97, 0.12));
}

.hero-copy {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hero-copy h2 {
    margin: 0;
}

.hero-metrics {
    display: flex;
    gap: 14px;
}

.hero-metric {
    min-width: 120px;
    padding: 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    text-align: center;
}

.hero-metric strong {
    display: block;
    font-size: 1.8rem;
}

.profile-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px;
    border-radius: 18px;
    background: rgba(233, 243, 239, 0.72);
    margin-bottom: 18px;
}

.profile-banner span {
    color: var(--muted);
}

.profile-stats {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.profile-stats div {
    min-width: 90px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.82);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-stats small {
    color: var(--muted);
}

.section-head,
.pagination,
.filters,
.actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.filters {
    flex-wrap: wrap;
    margin-top: 14px;
}

.section-copy {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.section-copy p,
.section-copy h3 {
    margin: 0;
}

.entity-filters {
    display: grid;
    grid-template-columns: minmax(240px, 1.6fr) repeat(3, minmax(160px, 1fr)) auto;
    gap: 14px;
    padding: 18px;
    margin: 18px 0 6px;
    border-radius: 20px;
    background: rgba(233, 243, 239, 0.56);
    border: 1px solid rgba(15, 143, 120, 0.08);
}

.search-field {
    display: flex;
    flex-direction: column;
}

.filter-select {
    gap: 8px;
}

.filter-select span {
    font-size: 0.85rem;
    color: var(--muted);
}

.table-wrap {
    overflow: auto;
    margin-top: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
}

th,
td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

tr:hover td {
    background: rgba(15, 143, 120, 0.04);
}

.button {
    border: 0;
    border-radius: 14px;
    padding: 12px 18px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s ease;
}

.button.small {
    padding: 8px 12px;
    border-radius: 12px;
}

.button.primary {
    background: linear-gradient(135deg, var(--primary), #14b79a);
    color: #fff;
}

.button.secondary {
    background: var(--secondary);
    color: var(--primary-dark);
}

.button.ghost {
    background: transparent;
    color: inherit;
    border: 1px solid var(--line);
}

.button.danger {
    background: rgba(210, 85, 85, 0.12);
    color: var(--danger);
}

.button:hover {
    transform: translateY(-1px);
}

.logout-form {
    margin-top: auto;
}

.alert {
    padding: 14px 16px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.alert.success {
    background: rgba(21, 179, 146, 0.12);
    color: #0b715f;
}

.alert.error {
    background: rgba(210, 85, 85, 0.12);
    color: #9f2a2a;
}

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-grid.two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label span {
    font-size: 0.95rem;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
    padding: 13px 15px;
    color: var(--text);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(15, 143, 120, 0.55);
    box-shadow: 0 0 0 4px rgba(15, 143, 120, 0.10);
}

.inline-check,
.check-card {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.check-card {
    padding: 14px;
    border-radius: 18px;
    background: rgba(233, 243, 239, 0.75);
    border: 1px solid rgba(15, 143, 120, 0.09);
}

.check-card input {
    width: auto;
    margin-top: 4px;
}

.online-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.online-item,
.info-banner {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    background: rgba(233, 243, 239, 0.72);
    border-radius: 16px;
}

.auth-shell {
    display: grid;
    place-items: center;
    padding: 26px;
}

.auth-card {
    width: min(540px, 100%);
    padding: 30px;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
}

.auth-wide {
    width: min(920px, 100%);
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 26px;
    align-items: center;
}

.eyebrow {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(15, 143, 120, 0.10);
    color: var(--primary-dark);
    margin-bottom: 14px;
}

.full-width {
    grid-column: 1 / -1;
}

@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .entity-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .app-shell,
    .auth-wide,
    .panel-grid,
    .module-grid,
    .quick-grid,
    .chart-grid,
    .entity-list-grid,
    .detail-grid,
    .checkbox-grid,
    .form-grid.two-col,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        padding-bottom: 18px;
    }

    .topbar,
    .entity-header,
    .section-head,
    .pagination {
        flex-direction: column;
        align-items: stretch;
    }

    .hero-card,
    .profile-banner {
        flex-direction: column;
        align-items: stretch;
    }

    .entity-kpi-row,
    .entity-filters {
        grid-template-columns: 1fr;
    }

    .topbar-user {
        align-items: flex-start;
    }

    .chat-bubble {
        max-width: 100%;
    }
}
