@import url("https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css");

:root {
    --bg: #f4f7f6;
    --surface: #ffffff;
    --surface-2: #eef5f3;
    --ink: #10201d;
    --muted: #66736f;
    --line: #dce7e4;
    --primary: #0f766e;
    --primary-dark: #0b5d56;
    --primary-soft: #dff5f1;
    --accent: #b45309;
    --danger: #b42318;
    --success: #067647;
    --warning: #b54708;
    --shadow: 0 20px 55px rgba(16, 32, 29, 0.10);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: Vazirmatn, IRANSans, "Segoe UI", Tahoma, Arial, sans-serif;
    font-size: 14px;
    letter-spacing: 0;
}

button,
input,
select,
textarea {
    font-family: inherit;
    letter-spacing: 0;
}

a {
    text-decoration: none;
}

.login-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.10), rgba(180, 83, 9, 0.08)),
        var(--bg);
}

.login-card {
    width: min(100%, 430px);
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.login-brand {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 26px;
}

.brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    color: #fff;
    background: var(--primary);
    border-radius: var(--radius);
    font-size: 22px;
    font-weight: 800;
}

.login-brand h1 {
    margin: 0;
    color: var(--ink);
    font-size: 24px;
    font-weight: 800;
}

.login-brand p {
    margin: 4px 0 0;
    color: var(--muted);
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 284px minmax(0, 1fr);
    background:
        linear-gradient(180deg, rgba(15, 118, 110, 0.05), rgba(180, 83, 9, 0.03)),
        var(--bg);
}

.app-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    background: #0f211e;
    color: #e7f4f1;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 4px 8px 18px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.10);
}

.sidebar-brand .brand-mark {
    background: #14b8a6;
}

.sidebar-brand strong,
.sidebar-brand span {
    display: block;
}

.sidebar-brand strong {
    font-size: 16px;
}

.sidebar-brand span {
    margin-top: 3px;
    color: #a7c8c1;
    font-size: 12px;
}

.nav-group {
    margin: 8px 0 12px;
}

.nav-group-title {
    padding: 7px 10px;
    color: #86aaa3;
    font-size: 12px;
    font-weight: 700;
}

.nav-button {
    width: 100%;
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 10px;
    color: #dcece8;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    text-align: right;
}

.nav-button:hover {
    background: rgba(255,255,255,0.08);
}

.nav-button.active {
    color: #08201c;
    background: #d9fbf5;
    border-color: rgba(255,255,255,0.16);
    font-weight: 800;
}

.nav-button small {
    color: inherit;
    opacity: 0.75;
}

.app-main {
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 22px;
    background: rgba(244, 247, 246, 0.86);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
}

.page-heading {
    min-width: 0;
}

.page-heading span {
    display: block;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
}

.page-heading h1 {
    margin: 3px 0 0;
    font-size: 22px;
    font-weight: 850;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.connection-badge {
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    color: var(--success);
    background: #ecfdf3;
    border: 1px solid #abefc6;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.connection-badge.offline {
    color: var(--warning);
    background: #fffaeb;
    border-color: #fedf89;
}

.user-chip {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    white-space: nowrap;
}

.user-chip span {
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
}

.user-chip a {
    color: var(--danger);
    font-size: 12px;
    font-weight: 800;
}

.icon-button {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.icon-button span,
.icon-button span::before,
.icon-button span::after {
    width: 18px;
    height: 2px;
    display: block;
    background: var(--ink);
    content: "";
}

.icon-button span::before {
    transform: translateY(-6px);
}

.icon-button span::after {
    transform: translateY(4px);
}

.workspace {
    min-height: 0;
    padding: 22px;
    overflow: auto;
}

.content-surface {
    max-width: 1500px;
    margin: 0 auto;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metric-card,
.panel,
.action-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(16, 32, 29, 0.06);
}

.metric-card {
    min-height: 122px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
}

.metric-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.metric-card strong {
    display: block;
    margin-top: 12px;
    color: var(--ink);
    font-size: 30px;
    font-weight: 900;
}

.metric-card small {
    color: var(--primary);
    font-weight: 800;
}

.main-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 14px;
}

.panel {
    overflow: hidden;
}

.panel-head {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.panel-head h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 850;
}

.panel-body {
    padding: 16px;
}

.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
}

.module-directory {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 10px;
}

.directory-search {
    max-width: 260px;
}

.action-card {
    min-height: 82px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding: 14px;
    color: var(--ink);
    border-color: transparent;
    text-align: right;
}

.action-card:hover {
    border-color: #99d8cf;
    background: #fbfffe;
}

.action-card strong {
    font-size: 14px;
    font-weight: 850;
}

.action-card span {
    color: var(--muted);
    font-size: 12px;
}

.table-card {
    min-height: 92px;
}

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

.toolbar .form-control,
.toolbar .form-select {
    width: auto;
    min-width: 180px;
}

.data-table {
    margin: 0;
    vertical-align: middle;
}

.data-table th {
    color: #40514d;
    background: #f7fbfa;
    border-bottom-color: var(--line);
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap;
}

.data-table td {
    font-size: 13px;
    white-space: nowrap;
}

.table-responsive {
    min-height: 260px;
}

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

.form-grid .wide {
    grid-column: 1 / -1;
}

.form-label {
    color: #334844;
    font-size: 12px;
    font-weight: 850;
}

.form-control,
.form-select {
    border-color: #cfdedb;
    border-radius: var(--radius);
}

.form-control:focus,
.form-select:focus {
    border-color: #58bdb2;
    box-shadow: 0 0 0 0.2rem rgba(15, 118, 110, 0.14);
}

.section-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.tab-pill {
    min-height: 36px;
    padding: 6px 12px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 999px;
    font-weight: 750;
}

.tab-pill.active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.empty-state,
.loading-state {
    min-height: 220px;
    display: grid;
    place-items: center;
    color: var(--muted);
}

.toast-area {
    position: fixed;
    z-index: 2000;
    left: 18px;
    bottom: 18px;
    display: grid;
    gap: 8px;
}

.app-toast {
    min-width: 260px;
    padding: 12px 14px;
    color: #fff;
    background: var(--primary-dark);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.app-toast.success {
    background: var(--success);
}

.app-toast.danger {
    background: var(--danger);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.legacy-window {
    overflow: visible;
    background: #fbfdff;
    border: 1px solid #9dc4ef;
    border-radius: var(--radius);
    box-shadow: 0 14px 36px rgba(25, 78, 120, 0.10);
}

.legacy-window form {
    min-width: 980px;
}

.legacy-titlebar {
    min-height: 34px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    color: #00549a;
    background: linear-gradient(180deg, #dbeeff, #c5def7);
    border-bottom: 1px solid #9dc4ef;
    font-weight: 850;
}

.legacy-titlebar span {
    color: #ff7a00;
    font-weight: 900;
}

.legacy-titlebar .legacy-check {
    justify-self: end;
}

.legacy-meta-grid {
    display: grid;
    grid-template-columns: 120px 130px 130px 190px minmax(260px, 1fr) 150px;
    gap: 8px;
    align-items: end;
    padding: 10px 12px;
    background: #f8fbff;
}

.legacy-field {
    min-width: 0;
    display: grid;
    gap: 4px;
    color: #00549a;
    font-size: 12px;
    font-weight: 850;
}

.legacy-field.wide {
    grid-column: span 2;
}

.legacy-field > span {
    white-space: nowrap;
}

.legacy-input {
    width: 100%;
    height: 28px;
    padding: 3px 8px;
    color: #0f2538;
    background: #fff;
    border: 1px solid #aabbd0;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 650;
}

.legacy-input:focus {
    border-color: #14a1ff;
    box-shadow: 0 0 0 2px rgba(20, 161, 255, 0.15);
    outline: none;
}

.legacy-select {
    padding-inline-end: 28px;
}

.legacy-input.number,
.legacy-input.ltr {
    direction: ltr;
    text-align: left;
}

.legacy-user {
    color: #00549a;
    font-size: 12px;
    font-weight: 850;
}

.legacy-user strong {
    margin-inline-start: 8px;
    color: #d3007d;
}

.legacy-check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    color: #7c0010;
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap;
}

.legacy-blue-line,
.legacy-pink-line {
    height: 4px;
}

.legacy-blue-line {
    background: #00a3e8;
}

.legacy-pink-line {
    background: #ff70b8;
}

.legacy-layout {
    display: grid;
    grid-template-columns: 330px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
}

.legacy-layout.dual {
    grid-template-columns: 320px minmax(0, 1fr);
}

.legacy-side {
    grid-column: 1;
    display: grid;
    align-content: start;
    gap: 10px;
}

.legacy-main {
    grid-column: 2;
    display: grid;
    gap: 10px;
}

.legacy-section,
.legacy-panel,
.legacy-status-strip {
    background: #fff;
    border: 1px solid #b9c8df;
    border-radius: 6px;
}

.legacy-section {
    padding: 12px;
}

.legacy-section.compact {
    padding: 10px;
}

.legacy-section h3 {
    margin: 0 0 10px;
    color: #00549a;
    font-size: 14px;
    font-weight: 900;
}

.legacy-section h3.green-title {
    color: #0f7d2b;
}

.legacy-section h3.red-title {
    color: #d30000;
}

.legacy-two-col,
.legacy-three-col,
.legacy-four-col {
    display: grid;
    gap: 10px;
    align-items: end;
}

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

.legacy-three-col {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.legacy-four-col {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.legacy-commission-row {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 120px 120px;
    gap: 8px;
    align-items: end;
    margin-bottom: 7px;
}

.legacy-panel-title {
    min-height: 27px;
    display: flex;
    align-items: center;
    padding: 4px 8px;
    color: #004b91;
    background: linear-gradient(180deg, #dbeeff, #c7e0fb);
    border-bottom: 1px solid #b9c8df;
    font-size: 12px;
    font-weight: 900;
}

.legacy-balance-host {
    min-height: 164px;
    overflow: auto;
}

.legacy-balance-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.legacy-balance-table th,
.legacy-balance-table td {
    height: 26px;
    padding: 4px 6px;
    border: 1px solid #d6dce6;
    white-space: nowrap;
}

.legacy-balance-table th {
    color: #003f7d;
    background: #edf5ff;
    font-weight: 900;
}

.legacy-balance-table td {
    background: #fff;
    text-align: left;
    direction: ltr;
}

.legacy-status-strip {
    min-height: 48px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
    align-items: center;
    padding: 8px;
}

.legacy-status-strip span {
    color: #00549a;
    font-weight: 850;
}

.legacy-status-strip strong {
    color: #555;
}

.mini-button {
    min-height: 28px;
    padding: 3px 10px;
    color: #16436f;
    background: linear-gradient(180deg, #fff, #e9eef5);
    border: 1px solid #bdcadb;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 750;
}

.legacy-attachments {
    min-height: 145px;
}

.legacy-attachment-actions {
    display: grid;
    gap: 8px;
    padding: 8px;
}

.legacy-file {
    width: 100%;
    font-size: 12px;
}

.legacy-attachment-list {
    display: grid;
    gap: 6px;
    padding: 0 8px 8px;
}

.legacy-attachment-link {
    display: grid;
    gap: 2px;
    padding: 6px;
    color: #003f7d;
    background: #f4f9ff;
    border: 1px solid #cbdcf2;
    border-radius: 4px;
    font-size: 12px;
}

.legacy-attachment-link small {
    color: #667085;
}

.legacy-footer-toolbar {
    position: sticky;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(9, minmax(82px, 1fr));
    gap: 1px;
    padding: 8px;
    background: #d7e7f7;
    border-top: 3px solid #00a3e8;
}

.legacy-tool {
    min-height: 42px;
    color: #003f7d;
    background: #e9f2fc;
    border: 1px solid #c7d7e8;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 850;
}

.legacy-tool.primary {
    color: #fff;
    background: #0f766e;
    border-color: #0f766e;
}

.legacy-tool.muted,
.legacy-tool:disabled {
    color: #9aa8b7;
    background: #edf1f5;
}

.tint-green {
    background: #f1ffef;
    color: #008000;
}

.tint-pink {
    background: #fff3f5;
    color: #d00000;
}

.mini-loading {
    padding: 14px;
    color: var(--muted);
    font-size: 12px;
}

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

    .main-grid {
        grid-template-columns: 1fr;
    }

    .legacy-window form {
        min-width: 860px;
    }

    .legacy-meta-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .legacy-field.wide {
        grid-column: span 2;
    }
}

@media (max-width: 991px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1000;
        width: min(86vw, 300px);
        transform: translateX(-100%);
        transition: transform 0.18s ease;
        box-shadow: var(--shadow);
    }

    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    .workspace {
        padding: 16px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .topbar-actions {
        gap: 6px;
    }

    .connection-badge,
    .user-chip span {
        display: none;
    }

    .legacy-window form {
        min-width: 760px;
    }

    .legacy-layout,
    .legacy-layout.dual {
        grid-template-columns: 1fr;
    }

    .legacy-side,
    .legacy-main {
        grid-column: 1;
    }

    .legacy-footer-toolbar {
        grid-template-columns: repeat(3, minmax(90px, 1fr));
    }
}

@media (max-width: 640px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .app-topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }

    .legacy-window form {
        min-width: 680px;
    }

    .legacy-meta-grid,
    .legacy-two-col,
    .legacy-three-col,
    .legacy-four-col,
    .legacy-commission-row {
        grid-template-columns: 1fr;
    }

    .legacy-field.wide {
        grid-column: auto;
    }
}
