* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: #f3f6fb;
    color: #162033;
    font-family: Inter, Arial, sans-serif;
}

a { text-decoration: none; }
button, input, select { font: inherit; }

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at top left, #dbeafe 0, transparent 35%),
        radial-gradient(circle at bottom right, #dcfce7 0, transparent 35%),
        #eef4fb;
}

.login-shell {
    width: 100%;
    max-width: 460px;
    padding: 24px;
}

.login-panel {
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.7);
    border-radius: 28px;
    padding: 28px;
    box-shadow: 0 20px 60px rgba(31, 41, 55, 0.12);
}

.brand-badge {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    background: #0f172a;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 18px;
}

.login-panel h1 {
    margin: 0 0 8px;
    font-size: 30px;
}

.muted {
    color: #64748b;
    margin: 0 0 20px;
}

.login-form {
    display: grid;
    gap: 14px;
}

.login-form input {
    height: 50px;
    border-radius: 16px;
    border: 1px solid #d7e0ec;
    padding: 0 16px;
    background: #fff;
}

.login-form button {
    height: 52px;
    border: 0;
    border-radius: 16px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.mobile-topbar {
    display: none;
}

.app-shell {
    display: grid;
    grid-template-columns: 270px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, #0f172a, #111827);
    color: #fff;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    font-weight: 800;
    font-size: 20px;
}

.brand-title {
    font-size: 18px;
    font-weight: 700;
}

.brand-subtitle {
    color: rgba(255,255,255,0.68);
    font-size: 13px;
}

.sidebar-nav {
    display: grid;
    gap: 8px;
}

.sidebar-nav a {
    color: rgba(255,255,255,0.86);
    padding: 12px 14px;
    border-radius: 14px;
    transition: 0.2s;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.08);
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 12px;
}

.role-chip {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 700;
}

.role-chip.admin {
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
}

.role-chip.user {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
}

.logout-btn {
    display: inline-block;
    background: rgba(255,255,255,0.08);
    color: #fff;
    padding: 12px 14px;
    border-radius: 14px;
    text-align: center;
    border: 0;
}

.main-content {
    padding: 28px;
}

.topbar h1 {
    margin: 0;
    font-size: 32px;
}

.page-subtitle {
    margin: 8px 0 0;
    color: #64748b;
}

.alert {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    font-weight: 600;
}

.alert.success {
    background: #dcfce7;
    color: #166534;
}

.alert.error {
    background: #fee2e2;
    color: #991b1b;
}

.stats-grid {
    margin-top: 22px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

.metric-card {
    background: #fff;
    border-radius: 24px;
    padding: 22px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
    border: 1px solid #e9eef5;
}

.metric-label {
    color: #64748b;
    font-size: 14px;
}

.metric-value {
    margin-top: 8px;
    font-size: 34px;
    font-weight: 800;
}

.content-grid {
    margin-top: 22px;
    display: grid;
    grid-template-columns: 1.35fr 0.95fr;
    gap: 20px;
}

.admin-grid {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.panel,
.subpanel {
    background: #fff;
    border-radius: 24px;
    padding: 22px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
    border: 1px solid #e9eef5;
}

.compact-panel {
    margin-top: 20px;
}

.panel-large {
    min-height: 100%;
}

.panel-head,
.subpanel-head,
.location-block-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.panel-head h2,
.subpanel-head h3,
.location-block-head h3 {
    margin: 0;
}

.panel-note {
    color: #64748b;
    font-size: 13px;
}

.smart-form {
    display: grid;
    gap: 14px;
}

.field {
    display: grid;
    gap: 8px;
}

.field label {
    font-size: 14px;
    font-weight: 700;
    color: #334155;
}

.field input,
.field select {
    width: 100%;
    min-height: 48px;
    border-radius: 14px;
    border: 1px solid #dbe4ef;
    background: #f8fbff;
    padding: 12px 14px;
    color: #0f172a;
}

.btn {
    min-height: 46px;
    border: 0;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    cursor: pointer;
    font-weight: 700;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
}

.btn-soft {
    background: #eef4ff;
    color: #1d4ed8;
}

.btn-danger {
    background: #b91c1c;
    color: #fff;
}

.location-blocks {
    display: grid;
    gap: 18px;
}

.location-block {
    border: 1px solid #e6edf7;
    border-radius: 20px;
    padding: 16px;
    background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.location-block-head span {
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
}

.stock-list {
    display: grid;
    gap: 12px;
}

.stock-row {
    border: 1px solid #e8eef6;
    border-radius: 18px;
    padding: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    background: #fff;
}

.stock-row.low {
    border-color: #fecaca;
    background: #fff7f7;
}

.stock-row-main {
    min-width: 0;
}

.stock-name {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 4px;
    word-break: break-word;
}

.stock-meta {
    color: #64748b;
    font-size: 13px;
    line-height: 1.4;
}

.stock-row-side {
    text-align: right;
    display: grid;
    gap: 8px;
    justify-items: end;
}

.stock-qty {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
}

.stock-badge {
    padding: 7px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.stock-badge.ok {
    background: #dcfce7;
    color: #166534;
}

.stock-badge.low {
    background: #fee2e2;
    color: #991b1b;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
}

.modern-table th,
.modern-table td {
    padding: 14px 12px;
    border-bottom: 1px solid #edf2f7;
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

.modern-table th {
    color: #64748b;
    font-size: 13px;
    font-weight: 700;
    background: #f8fbff;
}

.inline-edit-form {
    display: grid;
    grid-template-columns: 170px 80px 100px 100px;
    gap: 8px;
    align-items: center;
}

.filter-bar {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

.filter-bar input,
.filter-bar select {
    min-height: 46px;
    border-radius: 14px;
    border: 1px solid #dbe4ef;
    background: #f8fbff;
    padding: 12px 14px;
}

.report-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 18px;
}

.report-location-box {
    margin-top: 14px;
    border: 1px solid #e6edf7;
    border-radius: 18px;
    overflow: hidden;
}

.report-location-title {
    background: #f8fbff;
    padding: 12px 14px;
    font-weight: 800;
    border-bottom: 1px solid #e6edf7;
}

.empty-box {
    padding: 22px;
    border: 1px dashed #cbd5e1;
    border-radius: 18px;
    color: #64748b;
    text-align: center;
    background: #f8fbff;
}

@media (max-width: 1280px) {
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .content-grid,
    .report-grid {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        grid-template-columns: repeat(3, 1fr);
    }

    .inline-edit-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    .mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 12px 14px;
        background: #0f172a;
        color: #fff;
        position: sticky;
        top: 0;
        z-index: 50;
    }

    .mobile-brand {
        font-weight: 800;
        font-size: 16px;
    }

    .mobile-logout {
        padding: 10px 12px;
        font-size: 13px;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .main-content {
        padding: 14px;
    }

    .topbar h1 {
        font-size: 24px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .metric-card {
        border-radius: 18px;
        padding: 18px;
    }

    .panel,
    .subpanel {
        border-radius: 18px;
        padding: 16px;
    }

    .filter-bar {
        grid-template-columns: 1fr;
    }

    .stock-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .stock-row-side {
        width: 100%;
        justify-items: start;
        text-align: left;
    }

    .stock-qty {
        font-size: 24px;
    }

    .modern-table {
        min-width: 620px;
    }
}

@media (max-width: 640px) {
    .login-shell {
        padding: 14px;
    }

    .login-panel {
        padding: 22px;
        border-radius: 22px;
    }

    .page-subtitle {
        font-size: 14px;
    }

    .panel-head,
    .subpanel-head,
    .location-block-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .stock-name {
        font-size: 15px;
    }

    .field input,
    .field select,
    .btn {
        min-height: 44px;
    }

    .modern-table th,
    .modern-table td {
        padding: 12px 10px;
    }
}