:root {
    color-scheme: light;
    --ink: #202431;
    --muted: #858b9a;
    --line: #eceef2;
    --surface: #fff;
    --canvas: #f7f8fb;
    --accent: #6258d9;
    --accent-dark: #5146ca;
    --green: #22976b;
    --red: #d34e5b;
    font-family: 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    min-width: 320px;
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
}

button, input { font: inherit; }
button { cursor: pointer; }

.shell { max-width: 1440px; margin: 0 auto; padding: 48px 56px 64px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 32px; }
.eyebrow { margin: 0 0 7px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: .14em; }
h1, h2, p { margin-top: 0; }
h1, h2 { font-family: 'Segoe UI', Arial, sans-serif; letter-spacing: -.035em; }
h1 { margin-bottom: 5px; font-size: clamp(29px, 3vw, 36px); font-weight: 800; }
.subtitle { margin-bottom: 0; color: var(--muted); font-size: 14px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 17px; border: 0; border-radius: 9px; font-size: 13px; font-weight: 700; transition: background .15s, transform .15s; }
.button:active { transform: translateY(1px); }
.button-primary { background: var(--accent); color: #fff; box-shadow: 0 5px 12px #6258d929; }
.button-primary:hover { background: var(--accent-dark); }
.button-quiet { border: 1px solid var(--line); background: white; color: #555b69; }
.button-quiet:hover { background: #f5f6fa; }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 25px; }
.summary-card { display: flex; align-items: center; gap: 15px; min-height: 108px; padding: 20px; border: 1px solid #eff0f4; border-radius: 13px; background: var(--surface); box-shadow: 0 2px 6px #20243105; }
.summary-card p { margin-bottom: 7px; color: var(--muted); font-size: 12px; font-weight: 500; }
.summary-card strong { font-family: 'Segoe UI', Arial, sans-serif; font-size: 24px; font-weight: 800; letter-spacing: -.04em; }
.summary-icon { display: grid; flex: 0 0 43px; width: 43px; height: 43px; place-items: center; border-radius: 12px; font-size: 20px; font-weight: 700; }
.icon-violet { color: #6258d9; background: #f0efff; }
.icon-blue { color: #3982d8; background: #edf5ff; }
.icon-amber { color: #d18a1f; background: #fff6e8; }
.icon-green { color: #24936a; background: #eaf8f1; }

.inventory-panel { overflow: hidden; border: 1px solid #eff0f4; border-radius: 14px; background: #fff; box-shadow: 0 3px 12px #20243106; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 24px 25px 20px; }
.panel-heading h2 { margin: 0 0 5px; font-size: 18px; font-weight: 800; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.search-form { display: flex; align-items: center; gap: 9px; width: min(100%, 290px); height: 39px; padding: 0 11px; border: 1px solid #e8eaf0; border-radius: 8px; color: #969baa; }
.search-form:focus-within { border-color: #aaa4ed; box-shadow: 0 0 0 3px #6258d914; }
.search-form > span { font-size: 20px; line-height: 1; }
.search-form input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 12px; }
.search-form input::placeholder { color: #a4a8b3; }
.clear-search { color: var(--accent); font-size: 11px; text-decoration: none; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
thead { background: #fafbfc; }
th { padding: 12px 17px; color: #8c91a0; font-size: 10px; font-weight: 700; letter-spacing: .055em; text-transform: uppercase; white-space: nowrap; }
td { padding: 16px 17px; border-top: 1px solid #f0f1f4; color: #4a5060; font-size: 12px; white-space: nowrap; }
th:first-child, td:first-child { padding-left: 25px; }
th:last-child, td:last-child { padding-right: 25px; }
.product-name, .product-id { display: block; }
.product-name { margin-bottom: 4px; color: #282d3a; font-size: 12px; font-weight: 700; }
.product-id { color: #9a9eaa; font-size: 10px; }
.category-pill { display: inline-block; padding: 5px 9px; border-radius: 6px; background: #f3f4f8; color: #6f7482; font-size: 10px; }
.stock-form { display: flex; align-items: center; gap: 5px; }
.stock-input { width: 66px; height: 29px; padding: 0 6px; border: 1px solid #e9ebf0; border-radius: 6px; color: #343948; font-size: 11px; }
.stock-save { width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; color: var(--accent); background: #f0efff; font-size: 15px; }
.stock-save:hover { background: #e5e3ff; }
.stock-status { display: inline-flex; margin-top: 5px; font-size: 10px; }
.status-in { color: var(--green); }
.status-empty { color: var(--red); }
.actions-heading { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.delete-form { display: inline-flex; }
.icon-button { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid #eceef2; border-radius: 7px; background: white; color: #777d8c; font-size: 15px; }
.icon-button:hover { border-color: #d8d5fa; color: var(--accent); background: #f8f7ff; }
.delete-button:hover { border-color: #f5d6d9; color: var(--red); background: #fff8f8; }
.empty-state { padding: 54px 20px; color: var(--muted); text-align: center; white-space: normal; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 15px 25px; border-top: 1px solid #f0f1f4; color: var(--muted); font-size: 11px; }
.pagination { display: flex; align-items: center; gap: 12px; }
.pagination a, .pagination .disabled { display: grid; width: 27px; height: 27px; place-items: center; border: 1px solid #e9ebf0; border-radius: 6px; color: #666b79; font-size: 18px; text-decoration: none; }
.pagination a:hover { border-color: #d6d2fb; color: var(--accent); }
.pagination .disabled { color: #c6c8cf; }
.page-current { color: #5e6370; }
.notice { margin-bottom: 20px; padding: 12px 15px; border: 1px solid; border-radius: 9px; font-size: 13px; }
.notice-success { border-color: #c7ead9; background: #effaf4; color: #21744e; }
.notice-error { border-color: #f2d1d4; background: #fff5f5; color: #a93442; }

.product-modal { width: min(510px, calc(100% - 28px)); max-height: min(90vh, 760px); padding: 0; overflow: auto; border: 0; border-radius: 15px; background: #fff; color: var(--ink); box-shadow: 0 25px 90px #20243138; }
.product-modal::backdrop { background: #1d20304d; backdrop-filter: blur(2px); }
.modal-form { display: grid; gap: 15px; padding: 25px; }
.modal-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 3px; }
.modal-heading h2 { margin: 0; font-size: 22px; }
.modal-close { width: 30px; height: 30px; border: 0; border-radius: 7px; background: #f4f5f8; color: #6d7280; font-size: 21px; line-height: 1; }
.modal-form label { display: grid; gap: 6px; color: #555b68; font-size: 12px; font-weight: 600; }
.modal-form input { width: 100%; min-height: 39px; padding: 8px 10px; border: 1px solid #e5e7ed; border-radius: 7px; outline: 0; color: #292e3a; background: #fff; font-size: 13px; }
.modal-form input:focus { border-color: #aaa4ed; box-shadow: 0 0 0 3px #6258d914; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.editing-id { margin: -5px 0 0; color: var(--muted); font-size: 12px; }
.editing-id strong { color: #4f5360; }
.auto-id-note { margin: -5px 0 0; color: var(--muted); font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); border: 0; }

@media (max-width: 1050px) {
    .shell { padding: 38px 28px 48px; }
    .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 650px) {
    .shell { padding: 26px 15px 35px; }
    .topbar { align-items: flex-start; margin-bottom: 23px; }
    .topbar .button { min-height: 38px; padding: 0 11px; font-size: 11px; white-space: nowrap; }
    .subtitle { max-width: 220px; font-size: 12px; line-height: 1.5; }
    .summary-grid { gap: 10px; margin-bottom: 17px; }
    .summary-card { min-height: 91px; gap: 10px; padding: 13px 10px; }
    .summary-icon { flex-basis: 34px; width: 34px; height: 34px; border-radius: 10px; font-size: 16px; }
    .summary-card p { margin-bottom: 5px; font-size: 10px; }
    .summary-card strong { font-size: clamp(17px, 5vw, 22px); }
    .panel-heading { align-items: stretch; flex-direction: column; padding: 19px 16px 15px; }
    .search-form { width: 100%; }
    .table-wrap { overflow: visible; }
    table, tbody { display: block; }
    thead { display: none; }
    tbody { padding: 0 12px; }
    tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 8px; margin: 0; padding: 15px 3px; border-top: 1px solid #f0f1f4; }
    tbody td { display: block; min-width: 0; padding: 0 !important; border: 0; white-space: normal; }
    tbody td::before { display: block; margin-bottom: 6px; color: #969baa; content: attr(data-label); font-size: 9px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
    tbody td:first-child { grid-column: 1 / -1; }
    tbody td:last-child { grid-column: 1 / -1; }
    tbody td.empty-state { grid-column: 1 / -1; padding: 35px 10px !important; }
    .row-actions { justify-content: flex-start; }
    .table-footer { padding: 13px 16px; font-size: 10px; }
    .form-grid { grid-template-columns: 1fr; }
    .modal-form { padding: 21px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
