:root {
    --bg: #f5f4f1;
    --surface: #ffffff;
    --surface-subtle: #fbfaf7;
    --surface-muted: #f0efeb;

    --border: #ded8cc;
    --border-strong: #beb5a6;

    --text: #15171a;
    --text-soft: #363a40;
    --muted: #6f6a60;
    --muted-light: #9b9488;

    --primary: #2b2f36;
    --primary-hover: #171a1f;
    --primary-soft: #f0efeb;

    --accent: #8a6f3d;
    --accent-hover: #6f5629;
    --accent-soft: #f7f2e8;
    --accent-border: #d8c7a1;

    --green: #166534;
    --green-soft: #f0fdf4;

    --danger: #991b1b;
    --danger-soft: #fef2f2;

    --radius-sm: 2px;
    --radius-md: 3px;
    --radius-lg: 4px;

    --shadow-sm: 0 1px 2px rgba(31, 35, 41, 0.04);
    --shadow-md: 0 7px 18px rgba(31, 35, 41, 0.06);
    --shadow-focus: 0 0 0 2px rgba(138, 111, 61, 0.18);

    --container: 1520px;
    --header-height: 54px;

    --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(180deg, #faf9f6 0%, var(--bg) 100%);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.42;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

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

button {
    cursor: pointer;
}

/* APP FRAME */

.app-header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(14px);
}

.app-header__inner {
    max-width: var(--container);
    height: 100%;
    margin: 0 auto;
    padding: 0 28px;
    display: flex;
    align-items: center;
    gap: 28px;
}

.app-brand {
    flex: 0 0 auto;
}

.app-brand__name {
    font-size: 14px;
    font-weight: 740;
    letter-spacing: -0.015em;
    color: var(--text);
}

.app-brand__name:hover {
    color: var(--accent-hover);
}

.app-nav {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 2px;
    min-width: 0;
}

.app-nav a {
    height: 30px;
    padding: 0 10px;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
    font-weight: 610;
    border: 1px solid transparent;
    transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.app-nav a:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.app-nav a.is-active {
    background: var(--accent-soft);
    color: var(--accent-hover);
    border-color: var(--accent-border);
}

.app-account {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.app-account__text {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.15;
}

.app-account__text strong {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}

.app-account__text span {
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
}

.app-account__logout {
    padding-left: 12px;
    border-left: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
    font-weight: 610;
    transition: color 0.12s ease;
}

.app-account__logout:hover {
    color: var(--danger);
}

.app-main {
    max-width: var(--container);
    margin: 0 auto;
    padding: 26px 28px;
}

.app-footer {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 28px 28px;
}

.app-footer__inner {
    display: flex;
    justify-content: space-between;
    color: var(--muted-light);
    font-size: 12px;
}

/* PAGE */

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

.page-kicker {
    display: block;
    margin-bottom: 6px;
    color: var(--accent-hover);
    font-size: 11px;
    font-weight: 720;
    letter-spacing: 0.075em;
    text-transform: uppercase;
}

.page-header h1 {
    margin: 0;
    font-size: 23px;
    line-height: 1.18;
    letter-spacing: -0.035em;
    font-weight: 750;
    color: var(--text);
}

.page-header p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 7px;
}

/* GRID */

.layout-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 14px;
}

.grid-span-12 {
    grid-column: span 12;
}

.grid-span-8 {
    grid-column: span 8;
}

.grid-span-6 {
    grid-column: span 6;
}

.grid-span-4 {
    grid-column: span 4;
}

/* CONTAINER */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    min-width: 0;
}

.panel:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-md);
}

.panel-header {
    min-height: 48px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #ffffff 0%, var(--surface-subtle) 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.panel-header h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 720;
    letter-spacing: -0.01em;
    color: var(--text);
}

.panel-header p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.panel-body {
    padding: 14px;
}

/* BUTTONS */

.btn {
    height: 32px;
    padding: 0 12px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 650;
    white-space: nowrap;
    transition:
        background 0.12s ease,
        border-color 0.12s ease,
        color 0.12s ease,
        box-shadow 0.12s ease;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary-hover);
    color: #ffffff;
    box-shadow: none;
}

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

.btn-secondary {
    background: #ffffff;
    border-color: var(--border-strong);
    color: var(--text-soft);
    box-shadow: none;
}

.btn-secondary:hover {
    background: var(--accent-soft);
    border-color: var(--accent-border);
    color: var(--accent-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.btn-danger {
    background: #ffffff;
    border-color: #efb5b5;
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-soft);
    border-color: #dc2626;
}

/* TABLES */

.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table thead th {
    height: 36px;
    padding: 0 12px;
    background: var(--surface-subtle);
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    text-align: left;
    font-size: 11px;
    font-weight: 720;
    text-transform: uppercase;
    letter-spacing: 0.055em;
    white-space: nowrap;
}

.table tbody td {
    height: 39px;
    padding: 0 12px;
    border-bottom: 1px solid #ebe6dc;
    color: var(--text-soft);
    white-space: nowrap;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover td {
    background: #fbfaf6;
}

.table td:first-child {
    color: var(--text);
    font-weight: 650;
}

.text-right {
    text-align: right !important;
}

/* FORMS */

.form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 13px;
}

.form-field {
    grid-column: span 6;
}

.form-field.full {
    grid-column: span 12;
}

.form-field.third {
    grid-column: span 4;
}

.form-field label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 650;
}

.input,
.select,
.textarea {
    width: 100%;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: #ffffff;
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition:
        border-color 0.12s ease,
        box-shadow 0.12s ease,
        background 0.12s ease;
}

.input,
.select {
    height: 34px;
    padding: 0 9px;
}

.textarea {
    min-height: 88px;
    padding: 8px 9px;
    resize: vertical;
}

.input:hover,
.select:hover,
.textarea:hover {
    border-color: var(--accent-border);
    background: #ffffff;
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: var(--accent);
    box-shadow: var(--shadow-focus);
    background: #ffffff;
}

.input::placeholder,
.textarea::placeholder {
    color: var(--muted-light);
}

/* BADGES */

.badge {
    min-height: 20px;
    padding: 0 7px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    border: 1px solid transparent;
}

.badge-neutral {
    background: var(--surface-muted);
    color: var(--text-soft);
    border-color: var(--border);
}

.badge-blue {
    background: var(--accent-soft);
    color: var(--accent-hover);
    border-color: var(--accent-border);
}

.badge-green {
    background: var(--green-soft);
    color: var(--green);
    border-color: #bbf7d0;
}

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

/* HELPERS */

.stack {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

/* LOGIN */

.login-layout {
    min-height: calc(100vh - 80px);
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-box {
    width: 390px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 26px;
}

.login-head {
    margin-bottom: 20px;
}

.login-head h1 {
    margin: 0;
    font-size: 21px;
    letter-spacing: -0.035em;
}

.login-head p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.form-row {
    margin-bottom: 14px;
}

.form-row label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 650;
}

.form-row input {
    width: 100%;
    height: 34px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 0 9px;
    outline: none;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.form-row input:hover {
    border-color: var(--accent-border);
}

.form-row input:focus {
    border-color: var(--accent);
    box-shadow: var(--shadow-focus);
}

.alert-error {
    margin-bottom: 15px;
    padding: 9px 11px;
    border-radius: var(--radius-md);
    border: 1px solid #fecaca;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 13px;
    font-weight: 650;
}

/* RESPONSIVE */

@media (max-width: 980px) {
    .app-header {
        height: auto;
    }

    .app-header__inner {
        padding: 14px 18px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .app-nav {
        flex-wrap: wrap;
    }

    .app-account {
        width: 100%;
        justify-content: space-between;
    }

    .app-account__text {
        align-items: flex-start;
    }

    .app-main {
        padding: 20px 18px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .grid-span-8,
    .grid-span-6,
    .grid-span-4 {
        grid-column: span 12;
    }

    .form-field,
    .form-field.third {
        grid-column: span 12;
    }
}

/* DASHBOARD */

.dashboard-kpis {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    padding: 0;
}

.kpi-item {
    padding: 16px;
    border-right: 1px solid var(--border);
}

.kpi-item:last-child {
    border-right: none;
}

.kpi-item span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-item strong {
    display: block;
    font-size: 24px;
    line-height: 1.1;
    letter-spacing: -0.04em;
    color: var(--text);
    margin-bottom: 5px;
}

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

.finance-list {
    padding: 0;
}

.finance-row {
    height: 48px;
    padding: 0 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.finance-row:last-child {
    border-bottom: none;
}

.finance-row span {
    color: var(--muted);
    font-size: 13px;
}

.finance-row strong {
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}

.finance-row.danger strong {
    color: var(--danger);
}

.task-list,
.activity-list {
    padding: 0;
}

.task-row {
    min-height: 58px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.task-row:last-child {
    border-bottom: none;
}

.task-row strong {
    display: block;
    margin-bottom: 3px;
    font-size: 13px;
    color: var(--text);
}

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

.activity-row {
    min-height: 58px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 72px 1fr;
    align-items: center;
    gap: 12px;
}

.activity-row:last-child {
    border-bottom: none;
}

.activity-row > span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.activity-row strong {
    display: block;
    margin-bottom: 3px;
    font-size: 13px;
    color: var(--text);
}

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

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

    .kpi-item {
        border-bottom: 1px solid var(--border);
    }
}
/* TOOLBAR */

.toolbar {
    min-height: 52px;
    margin-bottom: 14px;
    padding: 0 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box {
    width: 260px;
    position: relative;
}

.search-box input {
    width: 100%;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: #ffffff;
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.search-box input:hover {
    border-color: var(--accent-border);
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: var(--shadow-focus);
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
}

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

/* QUICK STATS */

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

.quick-stat {
    min-height: 82px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.quick-stat span {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.quick-stat strong {
    display: block;
    margin-bottom: 5px;
    color: var(--text);
    font-size: 22px;
    line-height: 1.1;
    letter-spacing: -0.04em;
}

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

/* SIDELIST */

.side-list {
    padding: 0;
}

.side-list-row {
    min-height: 56px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.side-list-row:last-child {
    border-bottom: none;
}

.side-list-row strong {
    display: block;
    margin-bottom: 3px;
    font-size: 13px;
    color: var(--text);
}

.side-list-row span {
    color: var(--muted);
    font-size: 12px;
}

.side-list-row small {
    color: var(--muted-light);
    font-size: 11px;
}

/* SECTION TITLE */

.section-title {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.section-title h2 {
    margin: 0;
    color: var(--text);
    font-size: 15px;
    font-weight: 720;
    letter-spacing: -0.02em;
}

.section-title p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12px;
}

/* EMPTY STATE */

.empty-state {
    padding: 28px 20px;
    text-align: center;
}

.empty-state strong {
    display: block;
    margin-bottom: 6px;
    color: var(--text);
    font-size: 14px;
}

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

/* TABLE ACTIONS */

.table-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.table-link {
    color: var(--accent-hover);
    font-size: 12px;
    font-weight: 700;
}

.table-link:hover {
    text-decoration: underline;
}

/* STATUS DOT */

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    display: inline-block;
    margin-right: 7px;
    vertical-align: middle;
}

.status-dot.green {
    background: #22c55e;
}

.status-dot.red {
    background: #ef4444;
}

.status-dot.orange {
    background: #f59e0b;
}

.status-dot.gray {
    background: #9ca3af;
}

/* RESPONSIVE */

@media (max-width: 1200px) {

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

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

@media (max-width: 780px) {

    .toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
    }

    .toolbar-left,
    .toolbar-right {
        width: 100%;
        flex-wrap: wrap;
    }

    .search-box {
        width: 100%;
    }

    .quick-stats {
        grid-template-columns: 1fr;
    }

    .dashboard-kpis {
        grid-template-columns: 1fr;
    }

    .kpi-item {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
}
