:root {
    color-scheme: light;
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-soft: #f8f9fa;
    --border: #dde1e6;
    --border-strong: #c6cbd2;
    --text: #20242a;
    --muted: #68707c;
    --accent: #c4272f;
    --accent-dark: #9f1f26;
    --success: #237a4b;
    --success-bg: #edf8f1;
    --danger: #b4232c;
    --danger-bg: #fff0f1;
    --focus: #376ea6;
    --shadow: 0 10px 30px rgba(27, 31, 36, 0.08);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    letter-spacing: 0;
}

* {
    box-sizing: border-box;
    letter-spacing: 0;
}

html,
body {
    min-height: 100%;
    margin: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(55, 110, 166, 0.22);
    outline-offset: 1px;
}

.login-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background: #edf0f2;
}

.login-shell {
    width: 100%;
    max-width: 390px;
}

.login-panel {
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.brand-mark {
    display: grid;
    width: 48px;
    height: 48px;
    place-items: center;
    border-radius: 6px;
    background: var(--accent);
    color: #ffffff;
    font-size: 18px;
    font-weight: 750;
}

.brand-mark-small {
    width: 36px;
    height: 36px;
    font-size: 13px;
}

.login-panel h1 {
    margin: 20px 0 24px;
    font-size: 22px;
    line-height: 1.3;
}

.login-form {
    display: grid;
    gap: 10px;
}

.login-form label,
.field-group label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}

input {
    min-width: 0;
    height: 44px;
    border: 1px solid var(--border-strong);
    border-radius: 5px;
    background: #ffffff;
    color: var(--text);
    padding: 0 12px;
}

input:hover {
    border-color: #9da5af;
}

input:focus {
    border-color: var(--focus);
}

.login-form .button {
    margin-top: 10px;
}

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 5px;
    padding: 0 18px;
    background: #ffffff;
    color: var(--text);
    font-weight: 650;
    white-space: nowrap;
}

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

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

.button-secondary {
    border-color: var(--border-strong);
    background: var(--surface);
}

.button-secondary:hover {
    background: var(--surface-soft);
}

.button-danger {
    border-color: #e4b7ba;
    background: var(--danger-bg);
    color: var(--danger);
}

.button-copy {
    min-height: 36px;
    border-color: #bad7c6;
    background: #ffffff;
    color: var(--success);
}

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

.button-block {
    width: 100%;
}

.topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.96);
}

.topbar-inner {
    display: flex;
    width: min(1180px, calc(100% - 40px));
    min-height: 64px;
    align-items: center;
    justify-content: space-between;
    margin: 0 auto;
}

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

.product-name {
    font-size: 15px;
    font-weight: 750;
}

.operator-name {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.dashboard {
    width: min(1180px, calc(100% - 40px));
    margin: 32px auto 60px;
}

.alert {
    margin-bottom: 16px;
    border: 1px solid;
    border-radius: 5px;
    padding: 11px 14px;
    line-height: 1.5;
}

.alert-success {
    border-color: #b9dec8;
    background: var(--success-bg);
    color: #1f6942;
}

.alert-error {
    border-color: #e6b9bd;
    background: var(--danger-bg);
    color: #932029;
}

.generator-section,
.records-section {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.generator-section {
    padding: 24px;
}

.records-section {
    margin-top: 20px;
    overflow: hidden;
}

.section-heading,
.records-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.section-kicker {
    display: block;
    margin-bottom: 5px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 750;
}

.section-heading h1,
.records-toolbar h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.35;
}

.record-total {
    color: var(--muted);
    font-size: 13px;
}

.generator-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 150px auto;
    align-items: end;
    gap: 14px;
    margin-top: 24px;
}

.field-group {
    display: grid;
    gap: 7px;
}

.field-device input,
code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.field-device input {
    text-transform: uppercase;
}

.generate-button {
    height: 44px;
}

.result-strip {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 18px;
    margin-top: 20px;
    border-left: 3px solid var(--success);
    background: var(--success-bg);
    padding: 14px 16px;
}

.result-main {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 14px;
}

.result-label,
.result-meta {
    color: var(--muted);
    font-size: 12px;
}

.result-main code {
    overflow: hidden;
    color: #164f32;
    font-size: 18px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.records-toolbar {
    min-height: 82px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

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

.search-field input {
    width: 250px;
    height: 36px;
    background: var(--surface-soft);
    font-size: 13px;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

th,
td {
    padding: 13px 16px;
    border-bottom: 1px solid #eceef1;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

th {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

td {
    font-size: 13px;
}

tbody tr:hover {
    background: #fafbfc;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.actions-column {
    width: 120px;
}

.device-code,
.license-code {
    color: var(--text);
    font-size: 13px;
}

.license-code {
    font-weight: 700;
}

.row-actions form,
.toolbar-actions form,
.topbar form {
    margin: 0;
}

.text-button {
    border: 0;
    background: transparent;
    color: #2b67a0;
    padding: 5px 4px;
    font-size: 13px;
}

.text-button:hover {
    text-decoration: underline;
}

.text-button-danger {
    color: var(--danger);
}

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

.hidden {
    display: none !important;
}

.copy-helper {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

@media (max-width: 760px) {
    .topbar-inner,
    .dashboard {
        width: min(100% - 24px, 1180px);
    }

    .dashboard {
        margin-top: 18px;
    }

    .generator-section {
        padding: 18px;
    }

    .generator-form {
        grid-template-columns: minmax(0, 1fr) 110px;
    }

    .generate-button {
        grid-column: 1 / -1;
    }

    .result-strip {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .result-meta {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .records-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .toolbar-actions,
    .search-field,
    .search-field input {
        width: 100%;
    }

    .toolbar-actions form {
        flex: 0 0 auto;
    }
}

@media (max-width: 430px) {
    .login-body {
        padding: 14px;
    }

    .login-panel {
        padding: 24px 20px;
    }

    .section-heading {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

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

    .generate-button {
        grid-column: auto;
    }

    .result-strip {
        grid-template-columns: 1fr;
    }

    .result-main {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .result-main code {
        width: 100%;
        font-size: 16px;
    }

    .result-meta {
        grid-column: auto;
        grid-row: auto;
    }

    .button-copy {
        width: 100%;
    }
}
