:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --ink: #17202a;
    --muted: #6b7785;
    --line: #dce3ea;
    --blue: #1f6feb;
    --blue-dark: #1755b8;
    --green: #168a45;
    --red: #c73535;
    --amber: #a86a00;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 252px;
    background: #111827;
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.brand,
.login-heading {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--blue);
    color: #fff;
    font-weight: 700;
}

.brand small {
    display: block;
    color: #aab4c2;
    margin-top: 2px;
}

nav {
    display: grid;
    gap: 6px;
    margin-top: 32px;
}

nav a,
.logout-form button {
    color: #dbe4ef;
    text-decoration: none;
    border: 0;
    border-radius: 8px;
    background: transparent;
    padding: 12px;
    text-align: left;
    cursor: pointer;
    font: inherit;
}

nav a.active,
nav a:hover,
.logout-form button:hover {
    background: #1f2937;
    color: #fff;
}

.logout-form {
    margin-top: auto;
}

.main {
    margin-left: 252px;
    padding: 28px;
}

.login-shell {
    min-height: 100vh;
    margin-left: 0;
    display: grid;
    place-items: center;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 22px;
}

h1,
h2,
p {
    margin-top: 0;
}

.topbar h1 {
    margin-bottom: 4px;
    font-size: 28px;
}

.topbar p,
.login-heading p {
    color: var(--muted);
    margin-bottom: 0;
}

.quota,
.metrics article,
.panel,
.table-panel,
.login-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.quota {
    min-width: 128px;
    padding: 12px 16px;
    text-align: right;
}

.quota span,
.metrics span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.quota strong,
.metrics strong {
    display: block;
    margin-top: 4px;
    font-size: 24px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metrics article {
    padding: 18px;
}

.panel,
.table-panel,
.login-card {
    padding: 20px;
    margin-bottom: 18px;
}

.login-card {
    width: min(440px, calc(100vw - 32px));
}

.login-heading {
    margin-bottom: 22px;
}

.login-heading h1 {
    font-size: 22px;
    margin-bottom: 4px;
}

.form-grid,
.activation-form,
.filters {
    display: grid;
    gap: 14px;
}

.activation-form {
    grid-template-columns: minmax(220px, 1fr) auto;
    align-items: end;
}

.filters {
    grid-template-columns: repeat(2, minmax(180px, 220px)) auto;
    align-items: end;
}

label {
    display: grid;
    gap: 6px;
    color: #314052;
    font-weight: 700;
}

input {
    width: 100%;
    min-height: 42px;
    border: 1px solid #cfd8e3;
    border-radius: 8px;
    padding: 9px 11px;
    color: var(--ink);
    font: inherit;
}

.scan-input {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.scan-button,
.icon-button {
    min-height: 42px;
    border: 1px solid #cfd8e3;
    border-radius: 8px;
    background: #fff;
    color: var(--blue);
    padding: 0 14px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.scan-button:hover,
.icon-button:hover {
    border-color: var(--blue);
    background: #f3f7ff;
}

input:focus {
    outline: 2px solid rgba(31, 111, 235, 0.18);
    border-color: var(--blue);
}

button.primary {
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    background: var(--blue);
    color: #fff;
    padding: 0 18px;
    font-weight: 700;
    cursor: pointer;
}

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

button.full {
    width: 100%;
}

.alert {
    border-radius: 8px;
    border: 1px solid var(--line);
    padding: 12px 14px;
    margin-bottom: 18px;
    background: #fff;
}

.alert.success {
    border-color: #b8dfc8;
    color: var(--green);
    background: #f0fbf4;
}

.alert.error {
    border-color: #efc0c0;
    color: var(--red);
    background: #fff4f4;
}

.status-head {
    border-bottom: 1px solid var(--line);
    margin-bottom: 18px;
    padding-bottom: 16px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 700;
}

.status-pill.ok {
    background: #e8f7ee;
    color: var(--green);
}

.status-pill.pending {
    background: #fff4de;
    color: var(--amber);
}

.status-identifiers {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.status-identifiers div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.status-identifiers span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 5px;
}

.status-identifiers strong {
    display: block;
    overflow-wrap: anywhere;
}

.details {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 0;
}

.details div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.details dt {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 5px;
}

.details dd {
    margin: 0;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.table-panel {
    overflow-x: auto;
    padding: 0;
}

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

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

th {
    background: #f8fafc;
    color: #405064;
    font-size: 13px;
}

.empty {
    color: var(--muted);
    text-align: center;
}

.scanner-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(17, 24, 39, 0.72);
}

.scanner-modal.open {
    display: flex;
}

.scanner-dialog {
    width: min(720px, 100%);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
    overflow: hidden;
}

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

.scanner-header h2 {
    margin-bottom: 4px;
    font-size: 20px;
}

.scanner-header p,
.scanner-help {
    margin-bottom: 0;
    color: var(--muted);
}

.scanner-body {
    position: relative;
    background: #0b1220;
    aspect-ratio: 16 / 9;
}

.scanner-body video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-frame {
    position: absolute;
    left: 10%;
    right: 10%;
    top: 38%;
    height: 24%;
    border: 2px solid rgba(255, 255, 255, 0.92);
    border-radius: 8px;
    box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.18);
    pointer-events: none;
}

.scanner-help {
    padding: 12px 18px 16px;
}

@media (max-width: 840px) {
    .sidebar {
        position: static;
        width: auto;
    }

    .main {
        margin-left: 0;
        padding: 18px;
    }

    .topbar,
    .activation-form,
    .filters {
        grid-template-columns: 1fr;
        display: grid;
    }

    .quota {
        text-align: left;
    }

    .metrics,
    .details,
    .status-identifiers {
        grid-template-columns: 1fr;
    }

    .scan-input {
        grid-template-columns: 1fr;
    }
}
