:root {
    --bg: #f4f7fb;
    --bg-strong: #eaf0f7;
    --text: #152033;
    --muted: #718096;
    --card: #ffffff;
    --line: #e3e8f0;
    --primary: #123f3a;
    --primary-2: #0f766e;
    --accent: #d6a03d;
    --danger: #b42318;
    --danger-soft: #fff1f0;
    --success: #057a55;
    --success-soft: #ecfdf3;
    --shadow: 0 24px 60px rgba(15, 35, 55, .12);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, .15), transparent 34rem),
        linear-gradient(135deg, #f7fafc 0%, #edf4f8 100%);
    color: var(--text);
}

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

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

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-shell {
    width: min(1080px, 100%);
    min-height: 640px;
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    background: var(--card);
    border: 1px solid rgba(255,255,255,.75);
    border-radius: 34px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.brand-panel {
    position: relative;
    padding: clamp(36px, 6vw, 72px);
    color: #fff;
    background:
        linear-gradient(145deg, rgba(18,63,58,.96), rgba(15,118,110,.92)),
        url("data:image/svg+xml,%3Csvg width='140' height='140' viewBox='0 0 140 140' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' stroke='%23ffffff' stroke-opacity='.14'%3E%3Cpath d='M0 20h140M0 60h140M0 100h140M20 0v140M60 0v140M100 0v140'/%3E%3C/g%3E%3C/svg%3E");
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.brand-panel::after {
    content: "";
    position: absolute;
    inset: auto 10% 8% auto;
    width: 220px;
    height: 220px;
    border-radius: 999px;
    background: rgba(214, 160, 61, .23);
    filter: blur(4px);
}

.brand-mark {
    width: 76px;
    height: 76px;
    display: grid;
    place-items: center;
    border-radius: 24px;
    background: linear-gradient(135deg, var(--accent), #f1c768);
    color: #1e293b;
    font-weight: 900;
    font-size: 26px;
    letter-spacing: -1px;
    box-shadow: 0 16px 35px rgba(0,0,0,.18);
}

.brand-mark.small {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    font-size: 16px;
}

.eyebrow {
    margin: 28px 0 10px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .18em;
    color: var(--accent);
    font-weight: 800;
}

.brand-panel h1 {
    margin: 0;
    font-size: clamp(38px, 6vw, 68px);
    line-height: .98;
    letter-spacing: -0.055em;
    max-width: 580px;
}

.brand-panel p:not(.eyebrow) {
    max-width: 500px;
    font-size: 18px;
    line-height: 1.6;
    color: rgba(255,255,255,.82);
}

.login-highlights {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 24px;
    z-index: 1;
}

.login-highlights span {
    padding: 10px 12px;
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    backdrop-filter: blur(12px);
    font-size: 13px;
}

.login-card {
    padding: clamp(28px, 5vw, 62px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.mobile-brand {
    display: none;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.login-card h2,
.panel h2 {
    margin: 0;
    font-size: clamp(28px, 4vw, 38px);
    letter-spacing: -.04em;
}

.muted,
.panel-header p {
    color: var(--muted);
    margin: 8px 0 0;
    line-height: 1.5;
}

.stack-form {
    display: grid;
    gap: 18px;
    margin-top: 28px;
}

label {
    display: grid;
    gap: 7px;
    font-weight: 700;
    color: #334155;
    font-size: 14px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(15, 118, 110, .75);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, .10);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 14px;
    padding: 11px 16px;
    cursor: pointer;
    font-weight: 800;
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
    white-space: nowrap;
}

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

.btn.primary {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    box-shadow: 0 12px 28px rgba(15, 118, 110, .28);
}

.btn.ghost {
    background: #eef4f6;
    color: #1f3f3b;
}

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

.btn.small {
    padding: 8px 10px;
    border-radius: 11px;
    font-size: 12px;
}

.btn.full {
    width: 100%;
    min-height: 48px;
}

.hint {
    margin-top: 22px;
    color: var(--muted);
    font-size: 13px;
    background: #f8fafc;
    border: 1px dashed var(--line);
    border-radius: 14px;
    padding: 12px;
}

.alert {
    padding: 13px 16px;
    border-radius: 16px;
    margin: 18px 0;
    font-weight: 700;
    border: 1px solid transparent;
}

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

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

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px;
    background: rgba(255, 255, 255, .82);
    border-right: 1px solid var(--line);
    backdrop-filter: blur(22px);
    display: flex;
    flex-direction: column;
    gap: 28px;
}

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

.brand-line span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-top: 2px;
}

.nav-tabs {
    display: grid;
    gap: 8px;
}

.nav-tabs a,
.logout-link {
    padding: 12px 14px;
    border-radius: 14px;
    color: #475569;
    font-weight: 800;
}

.nav-tabs a.active,
.nav-tabs a:hover {
    background: #e8f5f3;
    color: var(--primary-2);
}

.logout-link {
    margin-top: auto;
    background: #f8fafc;
    color: #991b1b;
    text-align: center;
}

.content {
    padding: clamp(20px, 4vw, 42px);
    min-width: 0;
}

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

.topbar h1 {
    margin: 0;
    font-size: clamp(34px, 5vw, 58px);
    letter-spacing: -.055em;
}

.user-pill {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255,255,255,.74);
}

.user-pill span {
    font-weight: 900;
}

.user-pill small {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(140px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255,255,255,.86);
    box-shadow: 0 10px 28px rgba(20, 38, 62, .06);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
    letter-spacing: -.04em;
}

.stat-card.warn strong {
    color: #b45309;
}

.panel {
    background: rgba(255,255,255,.9);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 24px;
    border-bottom: 1px solid var(--line);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.table-search {
    min-width: min(320px, 100%);
}

.filters-panel {
    display: grid;
    grid-template-columns: 1.2fr repeat(2, minmax(150px, .7fr)) 1.2fr auto;
    gap: 14px;
    align-items: end;
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(135deg, rgba(15, 118, 110, .06), rgba(214, 160, 61, .08));
}

.filters-panel[hidden] {
    display: none;
}

.entries-filters {
    grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
}

.filters-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.table-summary {
    padding: 12px 24px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    background: #fbfdff;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

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

.data-table th,
.data-table td {
    text-align: left;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.data-table th {
    background: #f8fafc;
    color: #475569;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    white-space: nowrap;
}

.data-table tr:hover td {
    background: rgba(15, 118, 110, .035);
}

.stock-badge {
    display: inline-flex;
    min-width: 74px;
    justify-content: center;
    padding: 5px 8px;
    border-radius: 999px;
    color: #155e35;
    background: #dcfce7;
    font-weight: 900;
}

.stock-badge.low {
    color: #9a3412;
    background: #ffedd5;
}

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

.inline-form {
    display: inline;
}

.modal {
    width: min(760px, calc(100vw - 24px));
    border: 0;
    padding: 0;
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.modal::backdrop {
    background: rgba(15, 23, 42, .48);
    backdrop-filter: blur(4px);
}

.modal-card {
    padding: 24px;
    background: #fff;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.modal-header h3 {
    margin: 0;
    font-size: 26px;
    letter-spacing: -.04em;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    border: 0;
    background: #f1f5f9;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}


.searchable-select {
    display: grid;
    gap: 10px;
}

.item-search {
    background: #f8fafc;
}

.field-hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

input[readonly] {
    background: #f8fafc;
    color: #475569;
    cursor: not-allowed;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

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

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

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

    .filters-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 860px) {
    .login-shell {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .brand-panel {
        display: none;
    }

    .mobile-brand {
        display: flex;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        padding: 16px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .nav-tabs {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        overflow-x: auto;
    }

    .nav-tabs a {
        text-align: center;
        font-size: 13px;
    }

    .logout-link {
        margin: 0;
    }

    .topbar {
        flex-direction: column;
    }

    .user-pill {
        width: 100%;
        align-items: flex-start;
    }

    .panel-header {
        flex-direction: column;
    }

    .toolbar {
        justify-content: stretch;
    }

    .toolbar > * {
        width: 100%;
    }

    .filters-panel {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    .filters-actions .btn {
        width: 100%;
    }

    .data-table {
        min-width: 0;
    }

    .data-table thead {
        display: none;
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tr {
        margin: 12px;
        border: 1px solid var(--line);
        border-radius: 18px;
        background: #fff;
        overflow: hidden;
    }

    .data-table td {
        display: grid;
        grid-template-columns: 135px 1fr;
        gap: 12px;
        padding: 12px 14px;
        border-bottom: 1px solid var(--line);
    }

    .data-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 900;
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: .08em;
    }

    .actions {
        justify-content: flex-start;
    }
}

@media (max-width: 620px) {
    body {
        background: var(--bg);
    }

    .login-page {
        padding: 12px;
    }

    .login-shell {
        border-radius: 24px;
    }

    .login-card,
    .content {
        padding: 18px;
    }

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

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

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

    .span-2 {
        grid-column: auto;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions .btn {
        width: 100%;
    }

    .data-table td {
        grid-template-columns: 1fr;
    }
}

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

.status-badge,
.permission-tags span {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 900;
}

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

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

.permission-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.permission-tags span {
    color: #334155;
    background: #eef4f6;
}

.checkbox-line {
    display: flex;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    font-weight: 800;
}

.checkbox-line input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-2);
}

.permissions-box {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 16px;
    background: #f8fafc;
}

.permissions-box strong {
    display: block;
    margin-bottom: 4px;
}

.permissions-box p {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

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

@media (max-width: 860px) {
    .topbar-actions {
        width: 100%;
        justify-content: stretch;
    }

    .topbar-actions > .btn,
    .topbar-actions .user-pill {
        width: 100%;
    }

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