:root {
    color-scheme: light;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --line: #d9dde5;
    --text: #1f2933;
    --muted: #627080;
    --accent: #166c7d;
    --accent-dark: #0f5260;
    --success-bg: #e7f5ed;
    --success-text: #1f6b43;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
}

button,
select,
input {
    font: inherit;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 72px;
    padding: 16px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.product-name {
    font-size: 18px;
    font-weight: 700;
}

.page-subtitle {
    margin-top: 3px;
    color: var(--muted);
}

.settings-layout {
    width: min(1180px, calc(100% - 32px));
    margin: 24px auto 48px;
}

.tabs {
    display: flex;
    gap: 6px;
    border-bottom: 1px solid var(--line);
}

.tab {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 0 14px;
    color: var(--muted);
    text-decoration: none;
    border: 1px solid transparent;
    border-bottom: 0;
}

.tab.active {
    color: var(--text);
    background: var(--surface);
    border-color: var(--line);
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 0;
}

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

.panel-header h1 {
    margin: 0;
    font-size: 22px;
}

.panel-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.alert {
    margin: 16px 24px 0;
    padding: 10px 12px;
    color: var(--success-text);
    background: var(--success-bg);
    border: 1px solid #b8e2c8;
}

.error-alert {
    color: #8a1f1f;
    background: #fdecec;
    border-color: #f1b8b8;
}

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

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

th,
td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.role-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

select,
input[type="text"] {
    min-width: 112px;
    height: 36px;
    padding: 0 10px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
}

.items-table th,
.items-table td,
.categories-table th,
.categories-table td {
    padding: 12px 14px;
}

.primary-button,
.secondary-button {
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid transparent;
    cursor: pointer;
}

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

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

.secondary-button {
    color: var(--text);
    background: #fff;
    border-color: var(--line);
}

.secondary-button:hover {
    background: #eef1f5;
}

.actions-column {
    width: 120px;
}

.icon-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.icon-actions form {
    margin: 0;
}

.icon-button {
    display: inline-grid;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
}

.icon-button:hover {
    color: var(--accent);
    background: #eef6f8;
    border-color: #c8e2e8;
}

.icon-button svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
}

.icon-button-with-letter {
    position: relative;
}

.icon-button-with-letter span {
    position: absolute;
    right: 4px;
    bottom: 2px;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}

.empty-state {
    padding: 28px 16px;
    color: var(--muted);
    text-align: center;
}

.modal {
    width: min(680px, calc(100% - 32px));
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--line);
}

.modal::backdrop {
    background: rgb(31 41 51 / 45%);
}

.modal-content {
    margin: 0;
}

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

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

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

.form-grid label {
    display: grid;
    gap: 6px;
}

.form-grid label span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.form-grid input[type="text"] {
    width: 100%;
}

.form-grid-wide {
    grid-column: 1 / -1;
}

.checkbox-label {
    display: inline-flex !important;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 8px !important;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 22px 22px;
    border-top: 1px solid var(--line);
}

.guest-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

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

.login-panel {
    width: min(440px, 100%);
    padding: 34px;
    background: var(--surface);
    border: 1px solid var(--line);
}

.login-panel h1 {
    margin: 0 0 16px;
    font-size: 28px;
}

.login-panel p {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.5;
}

.google-button {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 16px;
    color: #fff;
    background: var(--accent);
    text-decoration: none;
}

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

.guest-message {
    width: min(520px, 100%);
    padding: 34px;
    background: var(--surface);
    border: 1px solid var(--line);
}

.guest-message h1 {
    margin: 0 0 16px;
    font-size: 28px;
}

.guest-message p {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 16px;
    line-height: 1.5;
}

@media (max-width: 760px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 16px;
    }

    .settings-layout {
        width: 100%;
        margin: 0;
    }

    .panel-header {
        padding: 18px 16px;
    }

    .role-form {
        align-items: flex-start;
        flex-direction: column;
    }

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