:root {
    color-scheme: light;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    color: #20252b;
    background: #f4f6f5;
    --ink: #20252b;
    --muted: #69737a;
    --line: #dce2df;
    --surface: #ffffff;
    --soft: #f7f9f8;
    --primary: #087f6b;
    --primary-dark: #086a5a;
    --green: #23845a;
    --green-soft: #e9f6ef;
    --amber: #a46008;
    --amber-soft: #fff3d9;
    --red: #b33b3b;
    --red-soft: #fcebec;
    --violet: #7354a6;
    --shadow: 0 18px 48px rgba(32, 37, 43, 0.18);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    background: #f4f6f5;
    color: var(--ink);
}

button,
input,
select {
    font: inherit;
    letter-spacing: 0;
}

button,
a,
input,
select {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
    text-decoration: none;
}

code {
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.75rem;
    color: #69737a;
    overflow-wrap: anywhere;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

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

.topbar-inner,
.page-shell {
    width: min(1440px, calc(100% - 48px));
    margin: 0 auto;
}

.topbar-inner {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand,
.account,
.server-state,
.row-actions,
.form-actions,
.section-title {
    display: flex;
    align-items: center;
}

.brand {
    gap: 12px;
}

.brand > span:last-child {
    display: grid;
    gap: 2px;
}

.brand strong {
    font-size: 0.96rem;
}

.brand small,
.account-name,
.metric-cell small,
.section-title p,
.page-heading p,
.empty-state span,
.login-copy {
    color: var(--muted);
}

.brand small {
    font-size: 0.76rem;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 7px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: #20252b;
    color: #fff;
    font-size: 0.77rem;
    font-weight: 800;
}

.account {
    gap: 14px;
}

.account form,
.row-actions form,
.section-title form {
    margin: 0;
}

.server-state {
    gap: 7px;
    color: var(--green);
    font-size: 0.8rem;
    font-weight: 700;
}

.server-state i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2fb276;
    box-shadow: 0 0 0 4px var(--green-soft);
}

.account-name {
    font-size: 0.84rem;
}

.page-shell {
    padding: 38px 0 64px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.page-heading h1,
.dialog-header h2,
.login-panel h1,
.section-title h2,
.section-title h3 {
    margin: 0;
    letter-spacing: 0;
}

.page-heading h1 {
    font-size: 2rem;
    line-height: 1.15;
}

.page-heading p:last-child {
    margin: 8px 0 0;
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0;
}

.button {
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.84rem;
    font-weight: 700;
    white-space: nowrap;
    transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}

.button:focus-visible,
.icon-button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(8, 127, 107, 0.2);
    outline-offset: 2px;
}

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

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

.button-secondary {
    border-color: #cfd8d4;
    background: #fff;
    color: #3a444a;
}

.button-secondary:hover,
.button-quiet:hover {
    background: #eef2f0;
}

.button-quiet {
    border-color: transparent;
    background: transparent;
    color: #536068;
}

.button-danger {
    border-color: #efcccc;
    background: #fff;
    color: var(--red);
}

.button-danger:hover,
.button-danger-quiet:hover {
    background: var(--red-soft);
}

.button-danger-quiet {
    border-color: transparent;
    background: transparent;
    color: var(--red);
}

.button-positive {
    border-color: #bedfce;
    background: var(--green-soft);
    color: #176d49;
}

.button-full {
    width: 100%;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stats-grid article {
    min-height: 126px;
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    display: grid;
    align-content: space-between;
}

.stats-grid span {
    color: #58646b;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.stats-grid strong {
    font-size: 2rem;
    line-height: 1;
}

.stats-grid small {
    color: var(--muted);
    font-size: 0.76rem;
}

.toolbar {
    min-height: 64px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

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

input,
select {
    width: 100%;
    min-height: 40px;
    border: 1px solid #cfd8d4;
    border-radius: 6px;
    padding: 8px 11px;
    background: #fff;
    color: var(--ink);
}

input::placeholder {
    color: #929ba0;
}

.search-field {
    width: min(360px, 38vw);
}

.result-count {
    color: var(--muted);
    font-size: 0.82rem;
}

.license-list {
    border: 1px solid var(--line);
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    background: var(--surface);
}

.license-head,
.license-row {
    display: grid;
    grid-template-columns: minmax(220px, 1.35fr) 120px 110px 120px minmax(170px, 1fr) minmax(210px, auto);
    gap: 18px;
    align-items: center;
}

.license-head {
    min-height: 42px;
    padding: 0 18px;
    border-bottom: 1px solid var(--line);
    background: var(--soft);
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
}

.license-row {
    min-height: 96px;
    padding: 16px 18px;
    border-bottom: 1px solid #e8ecea;
}

.license-row:last-child {
    border-bottom: 0;
}

.license-customer,
.metric-cell {
    min-width: 0;
    display: grid;
    gap: 5px;
}

.license-customer strong,
.license-customer span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.license-customer span,
.metric-cell small {
    font-size: 0.76rem;
}

.metric-cell strong {
    font-size: 0.86rem;
}

.status {
    width: fit-content;
    min-width: 82px;
    border-radius: 999px;
    padding: 6px 9px;
    display: inline-flex;
    justify-content: center;
    font-size: 0.74rem;
    font-weight: 800;
}

.status-active {
    background: var(--green-soft);
    color: #176d49;
}

.status-revoked {
    background: var(--red-soft);
    color: #9c3030;
}

.status-expired {
    background: var(--amber-soft);
    color: #8c5208;
}

.row-actions {
    justify-content: flex-end;
    gap: 7px;
}

.mobile-label {
    display: none;
}

.empty-state {
    min-height: 180px;
    display: grid;
    place-content: center;
    gap: 7px;
    text-align: center;
}

.activity-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.activity-panel {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.section-title {
    min-height: 74px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    justify-content: space-between;
    gap: 20px;
}

.section-title h2 {
    font-size: 1rem;
}

.section-title h3 {
    font-size: 0.94rem;
}

.section-title p {
    margin: 5px 0 0;
    font-size: 0.76rem;
}

.event-list {
    max-height: 440px;
    overflow: auto;
}

.event-list > div {
    min-height: 54px;
    padding: 10px 18px;
    border-bottom: 1px solid #edf0ef;
    display: grid;
    grid-template-columns: 10px minmax(120px, 1fr) minmax(120px, 1fr) auto;
    gap: 10px;
    align-items: center;
    font-size: 0.76rem;
}

.event-list > div:last-child {
    border-bottom: 0;
}

.event-list strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-list span,
.event-list time {
    color: var(--muted);
}

.event-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.event-ok {
    background: #2cae73;
}

.event-denied {
    background: #d04a4a;
}

.event-admin {
    background: var(--violet);
}

.alert {
    margin-bottom: 16px;
    border: 1px solid;
    border-radius: 6px;
    padding: 12px 14px;
    font-size: 0.84rem;
}

.alert-success {
    border-color: #bcdcca;
    background: var(--green-soft);
    color: #176d49;
}

.alert-error {
    border-color: #eccaca;
    background: var(--red-soft);
    color: #973434;
}

.alert-warning {
    border-color: #ebd19d;
    background: var(--amber-soft);
    color: #80500e;
}

.dialog {
    width: min(620px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    border: 0;
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
    background: #fff;
    color: var(--ink);
    box-shadow: var(--shadow);
}

.dialog-wide {
    width: min(920px, calc(100vw - 32px));
}

.dialog::backdrop {
    background: rgba(23, 28, 31, 0.58);
    backdrop-filter: blur(2px);
}

.dialog-header {
    min-height: 78px;
    padding: 17px 20px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.dialog-header h2 {
    font-size: 1.2rem;
}

.dialog-body {
    max-height: calc(100vh - 126px);
    padding: 20px;
    overflow: auto;
}

.icon-button {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #5b666d;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
}

.icon-button:hover {
    background: #eef2f0;
}

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

.grid-form label,
.stack-form label,
.key-field {
    display: grid;
    gap: 7px;
    color: #4a565c;
    font-size: 0.78rem;
    font-weight: 700;
}

.zone-fieldset {
    grid-column: 1 / -1;
    margin: 0;
    border: 0;
    padding: 0;
}

.zone-fieldset legend {
    margin-bottom: 8px;
    color: #4a565c;
    font-size: 0.78rem;
    font-weight: 700;
}

.check-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 7px;
}

.check-grid label {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--soft);
    cursor: pointer;
}

.check-grid input {
    width: 16px;
    min-height: 16px;
    margin: 0;
}

.form-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    gap: 8px;
}

.detail-section {
    margin-top: 24px;
    border-top: 1px solid var(--line);
}

.detail-section .section-title {
    padding-left: 0;
    padding-right: 0;
}

.installation-row {
    min-height: 62px;
    border-bottom: 1px solid #edf0ef;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
}

.installation-row > div {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.installation-row > div:last-child {
    text-align: right;
}

.installation-row span,
.installation-row small {
    color: var(--muted);
    font-size: 0.76rem;
}

.compact {
    max-height: 300px;
}

.compact > div {
    padding-left: 0;
    padding-right: 0;
}

.muted-box {
    margin: 0;
    padding: 18px;
    color: var(--muted);
    font-size: 0.8rem;
    text-align: center;
}

.key-field input {
    font-family: "SFMono-Regular", Consolas, monospace;
}

.login-page {
    background: #eef2f0;
}

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

.login-panel {
    width: min(420px, 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 32px;
    background: #fff;
    box-shadow: 0 16px 38px rgba(32, 37, 43, 0.1);
}

.login-panel .brand-mark {
    margin-bottom: 24px;
}

.login-panel h1 {
    font-size: 1.55rem;
}

.login-copy {
    margin: 8px 0 24px;
    font-size: 0.9rem;
}

.stack-form {
    display: grid;
    gap: 16px;
}

@media (max-width: 1100px) {
    .license-head {
        display: none;
    }

    .license-row {
        grid-template-columns: minmax(220px, 1.5fr) repeat(2, minmax(110px, 0.7fr)) minmax(180px, 1fr);
    }

    .license-row > div:nth-child(4) {
        display: none;
    }

    .row-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .mobile-label {
        display: block;
        margin-bottom: 5px;
        color: var(--muted);
        font-size: 0.68rem;
        font-weight: 700;
        text-transform: uppercase;
    }
}

@media (max-width: 780px) {
    .topbar-inner,
    .page-shell {
        width: min(100% - 24px, 1440px);
    }

    .topbar-inner {
        min-height: 62px;
    }

    .brand small,
    .server-state,
    .account-name {
        display: none;
    }

    .page-shell {
        padding-top: 24px;
    }

    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .page-heading .button {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .toolbar,
    .filter-form {
        align-items: stretch;
        flex-direction: column;
    }

    .search-field {
        width: 100%;
    }

    .result-count {
        padding-left: 2px;
    }

    .license-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }

    .license-customer {
        grid-column: 1 / -1;
    }

    .license-row > div:nth-child(4) {
        display: grid;
    }

    .license-row > div:nth-child(5) {
        grid-column: 1 / -1;
    }

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

    .event-list > div {
        grid-template-columns: 10px minmax(0, 1fr) auto;
    }

    .event-list > div > span:nth-child(3) {
        grid-column: 2 / -1;
    }

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

    .check-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .installation-row {
        grid-template-columns: 1fr;
        padding: 12px 0;
    }

    .installation-row > div:last-child {
        text-align: left;
    }
}

@media (max-width: 430px) {
    .brand strong {
        font-size: 0.84rem;
    }

    .page-heading h1 {
        font-size: 1.65rem;
    }

    .stats-grid article {
        min-height: 112px;
        padding: 15px;
    }

    .stats-grid strong {
        font-size: 1.7rem;
    }

    .stats-grid small {
        line-height: 1.25;
    }

    .row-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .row-actions .button,
    .row-actions form {
        width: 100%;
    }

    .login-panel {
        padding: 24px;
    }

    .dialog-header,
    .dialog-body {
        padding-left: 16px;
        padding-right: 16px;
    }
}
