:root {
    --background: #f5f5f7;
    --surface: #ffffff;
    --surface-secondary: #f9f9fb;

    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-tertiary: #8e8e93;

    --border: rgba(60, 60, 67, 0.14);
    --border-strong: rgba(60, 60, 67, 0.22);

    --accent: #0071e3;
    --accent-hover: #0077ed;
    --accent-soft: rgba(0, 113, 227, 0.1);

    --success: #248a3d;
    --success-soft: rgba(52, 199, 89, 0.12);

    --warning: #b36b00;
    --warning-soft: rgba(255, 159, 10, 0.14);

    --danger: #d70015;
    --danger-soft: rgba(255, 59, 48, 0.11);

    --sidebar-width: 250px;
    --navbar-height: 86px;

    --radius-small: 8px;
    --radius-medium: 14px;
    --radius-large: 20px;

    --shadow-small:
        0 1px 2px rgba(0, 0, 0, 0.04),
        0 4px 14px rgba(0, 0, 0, 0.04);

    --shadow-modal:
        0 24px 70px rgba(0, 0, 0, 0.18);

    --transition: 180ms ease;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text-primary);
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "SF Pro Text",
        "SF Pro Display",
        "Helvetica Neue",
        Arial,
        sans-serif;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

button {
    cursor: pointer;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: var(--sidebar-width);
    border-right: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(18px);
}

.sidebar-inner {
    display: flex;
    min-height: 100vh;
    padding: 24px 18px;
    flex-direction: column;
}

.brand {
    display: flex;
    padding: 4px 8px 30px;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 11px;
    background: var(--text-primary);
    color: #ffffff;
    font-size: 13px;
    font-weight: 650;
    letter-spacing: -0.02em;
}

.brand-name,
.brand-subtitle,
.user-name,
.user-role {
    margin: 0;
}

.brand-name {
    font-size: 14px;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.brand-subtitle {
    margin-top: 2px;
    color: var(--text-tertiary);
    font-size: 12px;
}

.sidebar-navigation {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    position: relative;
    display: flex;
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    align-items: center;
    gap: 10px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    text-align: left;
    transition:
        background var(--transition),
        color var(--transition);
}

.nav-item:hover {
    background: rgba(118, 118, 128, 0.08);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 550;
}

.nav-indicator {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.72;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    padding: 8px;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 50%;
    background: var(--surface-secondary);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.user-name {
    font-size: 13px;
    font-weight: 550;
}

.user-role {
    margin-top: 2px;
    color: var(--text-tertiary);
    font-size: 11px;
}

.app-main {
    width: calc(100% - var(--sidebar-width));
    margin-left: var(--sidebar-width);
}

.navbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: var(--navbar-height);
    border-bottom: 1px solid var(--border);
    background: rgba(245, 245, 247, 0.82);
    backdrop-filter: blur(20px);
}

.navbar-content {
    display: flex;
    min-height: var(--navbar-height);
    padding: 18px 34px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.navbar-title {
    margin: 0;
    font-size: 23px;
    font-weight: 650;
    letter-spacing: -0.035em;
}

.navbar-subtitle {
    margin: 5px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.current-date {
    color: var(--text-secondary);
    font-size: 13px;
}

.navbar-actions { display: flex; align-items: center; gap: 14px; }
.branch-field { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 12px; }
.branch-field select { min-height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.logout-button { min-height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text-secondary); }

.app-content {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 34px;
}

.page {
    animation: page-in 180ms ease;
}

@keyframes page-in {
    from {
        opacity: 0;
        transform: translateY(3px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.page-title {
    margin: 0;
    font-size: 26px;
    font-weight: 650;
    letter-spacing: -0.04em;
}

.page-description {
    max-width: 600px;
    margin: 7px 0 0;
    color: var(--text-secondary);
    line-height: 1.5;
}

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius-large);
    background: var(--surface);
    box-shadow: var(--shadow-small);
}

.card-header {
    display: flex;
    padding: 20px 22px;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 620;
    letter-spacing: -0.015em;
}

.card-description {
    margin: 5px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.card-body {
    padding: 22px;
}

.button {
    display: inline-flex;
    min-height: 38px;
    padding: 0 15px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 550;
    transition:
        background var(--transition),
        border-color var(--transition),
        color var(--transition),
        transform var(--transition);
}

.button:active {
    transform: scale(0.98);
}

.button-primary {
    background: var(--accent);
    color: #ffffff;
}

.button-primary:hover {
    background: var(--accent-hover);
}

.button-secondary {
    border-color: var(--border-strong);
    background: var(--surface);
    color: var(--text-primary);
}

.button-secondary:hover {
    background: var(--surface-secondary);
}

.button-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.icon-button {
    display: grid;
    width: 36px;
    height: 36px;
    padding: 0;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 21px;
}

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

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

.form-field.full {
    grid-column: 1 / -1;
}

.form-label {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 550;
}

.form-help {
    color: var(--text-tertiary);
    font-size: 12px;
}

.input,
.select,
.textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    outline: none;
    background: var(--surface);
    color: var(--text-primary);
    transition:
        border-color var(--transition),
        box-shadow var(--transition);
}

.textarea {
    min-height: 90px;
    resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.input::placeholder,
.textarea::placeholder {
    color: var(--text-tertiary);
}

.form-actions {
    display: flex;
    margin-top: 22px;
    justify-content: flex-end;
    gap: 10px;
}

.search-input {
    width: min(360px, 100%);
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table td {
    padding: 17px 18px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

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

.data-table tbody tr {
    transition: background var(--transition);
}

.data-table tbody tr:hover {
    background: rgba(118, 118, 128, 0.035);
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-link {
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--accent);
    font-size: 13px;
    font-weight: 550;
}

.status {
    display: inline-flex;
    min-height: 25px;
    padding: 0 9px;
    align-items: center;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 550;
    white-space: nowrap;
}

.status-neutral {
    background: rgba(118, 118, 128, 0.1);
    color: var(--text-secondary);
}

.status-blue {
    background: var(--accent-soft);
    color: var(--accent);
}

.status-warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.status-success {
    background: var(--success-soft);
    color: var(--success);
}

.status-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.message {
    display: none;
    margin-bottom: 18px;
    padding: 13px 15px;
    border-radius: 10px;
    font-size: 13px;
}

.message.visible {
    display: block;
}

.message.success {
    background: var(--success-soft);
    color: var(--success);
}

.message.error {
    background: var(--danger-soft);
    color: var(--danger);
}

.empty-state,
.loading-state {
    padding: 44px 20px;
    color: var(--text-secondary);
    text-align: center;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    padding: 24px;
    place-items: center;
    background: rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(8px);
}

.modal-dialog {
    width: min(620px, 100%);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow-modal);
}

.modal-header {
    display: flex;
    padding: 22px 24px;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    letter-spacing: -0.025em;
}

.modal-header p {
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.modal-body {
    padding: 24px;
}

.hidden {
    display: none !important;
}

.money {
    font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
    :root {
        --sidebar-width: 210px;
    }

    .app-content,
    .navbar-content {
        padding-right: 22px;
        padding-left: 22px;
    }

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

@media (max-width: 720px) {
    .sidebar {
        position: static;
        width: 100%;
    }

    .sidebar-inner {
        min-height: auto;
    }

    .sidebar-footer {
        display: none;
    }

    .app-shell {
        display: block;
    }

    .app-main {
        width: 100%;
        margin-left: 0;
    }

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

    .navbar {
        position: static;
    }

    .page-header,
    .card-header {
        align-items: stretch;
        flex-direction: column;
    }

    .app-content {
        padding: 20px 14px;
    }
}
