:root {
    --bg: #f3f4f6;
    --panel: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --soft: #f9fafb;
    --dark: #111827;
    --danger: #b91c1c;
    --success: #047857;
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
    font: inherit;
}

a {
    color: inherit;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 28px;
    background: rgba(255,255,255,.88);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.topbar strong {
    display: block;
    font-size: 16px;
}

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

.topbar nav {
    display: flex;
    gap: 10px;
}

.topbar nav a {
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    text-decoration: none;
    font-size: 13px;
}

.page {
    width: min(1220px, calc(100% - 40px));
    margin: 28px auto;
}

.page.narrow {
    width: min(720px, calc(100% - 40px));
}

.panel {
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: 0 18px 60px rgba(17,24,39,.06);
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.panel-head h1 {
    margin: 0;
    font-size: 26px;
    letter-spacing: -.03em;
}

.panel-head p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 15px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    transition: .15s ease;
}

.button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(17,24,39,.08);
}

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

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

.button.full {
    width: 100%;
}

.button.small {
    min-height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 13px;
}

.icon-button {
    white-space: nowrap;
}

.plus-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    background: rgba(255,255,255,.14);
    font-size: 20px;
    line-height: 1;
}

.alert {
    margin: 14px 0;
    padding: 12px 14px;
    border-radius: 13px;
    border: 1px solid var(--line);
    background: var(--soft);
    font-size: 14px;
}

.alert.success {
    border-color: rgba(4,120,87,.24);
    background: #ecfdf5;
    color: var(--success);
}

.alert.danger {
    border-color: rgba(185,28,28,.24);
    background: #fef2f2;
    color: var(--danger);
}

.search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.search-row input {
    flex: 1;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    outline: none;
}

input {
    height: 42px;
    padding: 0 13px;
}

textarea {
    padding: 12px 13px;
    resize: vertical;
}

input:focus,
textarea:focus {
    border-color: #111827;
    box-shadow: 0 0 0 3px rgba(17,24,39,.08);
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 16px;
}

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

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

.data-table th {
    background: var(--soft);
    color: #374151;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

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

.data-table td strong {
    display: block;
    font-weight: 800;
}

.data-table td small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.actions-col {
    width: 150px;
}

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

.table-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
}

.table-icon.print {
    border-color: #111827;
    background: #111827;
    color: #fff;
    font-size: 17px;
}

.table-icon.edit {
    font-size: 16px;
}

.table-icon.delete {
    color: var(--danger);
    font-size: 20px;
}

.inline-delete {
    margin: 0;
}

.empty-cell {
    padding: 34px !important;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--muted);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(17,24,39,.48);
}

.modal-backdrop.active {
    display: flex;
}

.modal-card {
    width: min(760px, 100%);
    max-height: min(820px, calc(100vh - 40px));
    overflow: auto;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 30px 90px rgba(0,0,0,.28);
}

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

.modal-head h2 {
    margin: 0;
    font-size: 22px;
}

.modal-close {
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    cursor: pointer;
    font-size: 20px;
}

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

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

.form-grid label span {
    display: block;
    margin-bottom: 7px;
    color: #374151;
    font-size: 13px;
    font-weight: 700;
}

.form-grid hr {
    width: 100%;
    border: 0;
    border-top: 1px solid var(--line);
}

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

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 6px;
}

.settings-form {
    margin-top: 10px;
}

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    width: min(430px, 100%);
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 24px 80px rgba(17,24,39,.1);
}

.install-card {
    width: min(560px, 100%);
}

.brand-block {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 22px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: #111827;
    color: #fff;
    font-weight: 900;
}

.brand-block h1 {
    margin: 0;
    font-size: 22px;
    letter-spacing: -.03em;
}

.brand-block p {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.code-box {
    width: 100%;
    min-height: 240px;
    margin: 10px 0 16px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}

@media (max-width: 720px) {
    .topbar {
        padding: 0 16px;
    }

    .page {
        width: calc(100% - 24px);
        margin: 14px auto;
    }

    .panel {
        padding: 16px;
    }

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

    .search-row {
        flex-direction: column;
    }

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

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

    .empty-state {
        flex-direction: column;
    }
}
