@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg: #090a0f;
    --bg-soft: #121521;
    --surface: rgba(255, 255, 255, 0.96);
    --surface-soft: rgba(247, 249, 255, 0.92);
    --text: #0f172a;
    --muted: #475569;
    --border: #d9e0ef;
    --primary: #7c5f14;
    --primary-2: #c9a74b;
    --primary-soft: #fff3cd;
    --danger: #b42318;
    --danger-soft: #fee4e2;
    --warn: #b54708;
    --warn-soft: #ffead5;
    --ok: #087443;
    --ok-soft: #d1fadf;
    --radius: 16px;
    --shadow: 0 14px 42px rgba(2, 6, 23, 0.18);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Vazirmatn', Tahoma, 'Segoe UI', sans-serif;
    color: var(--text);
    background:
        radial-gradient(1200px 700px at 8% -8%, #2a2f4a 0%, transparent 50%),
        radial-gradient(900px 600px at 100% 0%, #4a3b17 0%, transparent 46%),
        linear-gradient(140deg, #0b0e17 0%, #111827 46%, #0e111b 100%);
    min-height: 100vh;
}

a {
    color: #124fd6;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 18px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    backdrop-filter: blur(8px);
}

.grid {
    display: grid;
    gap: 12px;
}

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

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

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

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.title {
    margin: 0;
    font-size: 21px;
    line-height: 1.35;
    letter-spacing: -0.2px;
}

.subtitle {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 13px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 13px;
    color: var(--text);
    transition: all 0.2s ease;
}

.tab:hover {
    text-decoration: none;
    border-color: #bdc7de;
}

.tab.active {
    background: linear-gradient(135deg, #fff5cf 0%, #ffe9b8 100%);
    border-color: #efcd7a;
    color: #5e4605;
    font-weight: 700;
}

.stat {
    border: 1px solid #dbe3f2;
    border-radius: 14px;
    padding: 13px;
    background: var(--surface-soft);
}

.stat .label {
    color: var(--muted);
    font-size: 12px;
}

.stat .value {
    margin-top: 6px;
    font-size: 21px;
    font-weight: 800;
    color: #0b1324;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    min-width: 720px;
}

th,
td {
    border: 1px solid #e2e8f4;
    padding: 10px;
    text-align: right;
    font-size: 13px;
    vertical-align: top;
}

th {
    background: #f4f7ff;
    color: #1e293b;
    font-weight: 700;
}

tr:nth-child(even) td {
    background: #fbfcff;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

input,
select,
textarea,
button {
    width: 100%;
    border: 1px solid #cfd8ea;
    border-radius: 12px;
    padding: 10px 11px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #d4ad4f;
    box-shadow: 0 0 0 4px rgba(212, 173, 79, 0.15);
}

textarea {
    min-height: 90px;
}

button {
    cursor: pointer;
    background: linear-gradient(135deg, #1f2538 0%, #111827 100%);
    color: #fff;
    border-color: #111827;
    font-weight: 700;
    transition: transform 0.12s ease, box-shadow 0.2s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(17, 24, 39, 0.28);
}

button.secondary {
    background: #fff;
    color: #111827;
}

button.danger {
    background: linear-gradient(135deg, #d92d20 0%, #b42318 100%);
    border-color: #b42318;
}

.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.actions > * {
    width: auto;
}

.badge {
    display: inline-flex;
    align-items: center;
    border: 1px solid #dbe3f0;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 11px;
    background: #fff;
    color: #334155;
}

.badge.ok {
    border-color: #9de3b6;
    background: var(--ok-soft);
    color: var(--ok);
}

.badge.warn {
    border-color: #f4bf8a;
    background: var(--warn-soft);
    color: var(--warn);
}

.badge.danger {
    border-color: #f3b1ae;
    background: var(--danger-soft);
    color: var(--danger);
}

.alert {
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    font-size: 13px;
}

.alert.success {
    background: var(--ok-soft);
    border-color: #9de3b6;
    color: var(--ok);
}

.alert.error {
    background: var(--danger-soft);
    border-color: #f3b1ae;
    color: var(--danger);
}

.alert.info {
    background: #e8f1ff;
    border-color: #b9d4ff;
    color: #1849a9;
}

.small {
    font-size: 12px;
    color: var(--muted);
}

.login-wrap,
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-card,
.auth-card {
    width: min(520px, 100%);
}

.auth-card {
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(140deg, rgba(255, 223, 147, 0.14) 0%, transparent 42%, rgba(171, 193, 255, 0.11) 100%);
    pointer-events: none;
}

.auth-header {
    position: relative;
    z-index: 1;
    margin-bottom: 12px;
}

.auth-mode {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

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

.perm-item {
    border: 1px solid #dbe3f0;
    border-radius: 12px;
    padding: 8px;
    background: #fff;
}

.perm-item label {
    margin: 0;
    font-size: 13px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.perm-item input[type='checkbox'] {
    width: auto;
    margin: 0;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: end;
}

.inline-form > div {
    flex: 1;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #dfe6f4;
    border-radius: 12px;
    background: #fff;
}

.table-wrap > table {
    border: none;
    border-radius: 0;
}

.table-wrap th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.num-pos {
    color: #087443;
    font-weight: 700;
}

.num-neg {
    color: #b42318;
    font-weight: 700;
}

.num-zero {
    color: #475569;
    font-weight: 600;
}

.fifo-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.fifo-legend .badge {
    background: #fff8e4;
    border-color: #f1d082;
    color: #6f5307;
}

.fifo-table {
    min-width: 1260px;
}

.fifo-cell {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.fifo-meta strong {
    font-size: 14px;
}

.fifo-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.fifo-key {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.fifo-value {
    font-weight: 700;
    color: #0f172a;
}

.fifo-block {
    border: 1px dashed #d9e1f0;
    border-radius: 10px;
    padding: 8px;
    background: #f9fbff;
}

.fifo-ref-title {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.fifo-ref-box {
    border: 1px solid #dde5f3;
    border-radius: 10px;
    background: #f7faff;
    padding: 7px 8px;
    line-height: 1.7;
    white-space: normal;
    word-break: break-word;
}

code {
    background: #edf2ff;
    border: 1px solid #d5deef;
    color: #0f172a;
    padding: 2px 6px;
    border-radius: 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
}

@media (max-width: 960px) {
    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .container {
        padding: 12px;
    }

    .card {
        padding: 12px;
    }

    table {
        min-width: 620px;
    }
}
