:root {
    --bg: #f4f6f8;
    --bg-2: #e9eef2;
    --panel: #ffffff;
    --panel-soft: #f8fafb;
    --ink: #17202a;
    --muted: #687385;
    --faint: #9aa4b2;
    --line: #d9e0e7;
    --line-strong: #c8d2dc;
    --primary: #0d9488;
    --primary-dark: #0f766e;
    --primary-soft: #d8f5f1;
    --accent: #2563eb;
    --danger: #c2410c;
    --danger-soft: #fff3ed;
    --warning: #a16207;
    --warning-soft: #fff7d6;
    --success: #047857;
    --success-soft: #dcfce7;
    --sidebar: #101820;
    --sidebar-2: #162330;
    --sidebar-ink: #f5f8fb;
    --radius: 8px;
    --shadow: 0 18px 42px rgba(16, 24, 32, .08);
    --shadow-soft: 0 8px 24px rgba(16, 24, 32, .06);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    min-height: 100vh;
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        linear-gradient(180deg, rgba(255,255,255,.62), rgba(255,255,255,0) 340px),
        linear-gradient(135deg, #eef5f6 0%, var(--bg) 44%, #eef1f4 100%);
    font-size: 15px;
    line-height: 1.45;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--primary-dark); }
p, h1, h2, h3 { margin-top: 0; }
p { color: var(--muted); }

.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 278px;
    padding: 22px 16px;
    background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
    color: var(--sidebar-ink);
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid rgba(255,255,255,.08);
}

.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    min-height: 48px;
    padding: 4px 6px;
    color: #fff;
}
.brand:hover { color: #fff; }
.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    background: linear-gradient(135deg, #22d3c5, #60a5fa);
    color: #07232c;
    font-weight: 900;
    letter-spacing: 0;
    box-shadow: 0 10px 24px rgba(20, 184, 166, .24);
    flex: 0 0 auto;
}
.brand span:last-child { font-weight: 850; font-size: 18px; }

nav {
    display: grid;
    gap: 6px;
}
nav a,
.logout button {
    border: 1px solid transparent;
    width: 100%;
    min-height: 42px;
    text-align: left;
    padding: 10px 12px;
    border-radius: 8px;
    color: #c7d1dc;
    background: transparent;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}
nav a::before,
.logout button::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #526170;
    box-shadow: 0 0 0 4px rgba(255,255,255,.03);
}
nav a.active,
nav a:hover,
.logout button:hover {
    background: rgba(255,255,255,.08);
    border-color: rgba(255,255,255,.08);
    color: #fff;
}
nav a.active::before,
nav a:hover::before { background: #22d3c5; }
.logout { margin-top: auto; }
.logout button::before { background: #f59e0b; }

.main {
    flex: 1;
    min-width: 0;
    padding: 30px;
}
.auth-main {
    display: grid;
    place-items: center;
    padding: 24px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    min-height: 72px;
    margin-bottom: 22px;
    padding: 0 2px;
}
h1 {
    font-size: 30px;
    line-height: 1.12;
    margin-bottom: 7px;
    letter-spacing: 0;
}
h2 {
    font-size: 18px;
    line-height: 1.25;
    margin-bottom: 0;
    letter-spacing: 0;
}
.topbar p,
.panel-head p,
.auth-header p {
    color: var(--muted);
    margin-bottom: 0;
}

.auth-card,
.panel,
.stats-grid article {
    background: rgba(255,255,255,.94);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}
.auth-card {
    width: min(452px, calc(100vw - 32px));
    padding: 30px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.auth-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 5px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
}
.auth-header {
    text-align: center;
    margin-bottom: 24px;
}
.auth-header .brand-mark {
    margin: 0 auto 16px;
}
.auth-header h1 { font-size: 27px; }

.stack { display: grid; gap: 14px; }
label {
    display: grid;
    gap: 7px;
    color: #334155;
    font-weight: 750;
    font-size: 14px;
}
input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 11px 12px;
    color: var(--ink);
    background: #fff;
    font: inherit;
    min-height: 42px;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
textarea { min-height: 96px; resize: vertical; }
input:hover,
select:hover,
textarea:hover { border-color: #aebdca; }
input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(13, 148, 136, .16);
    border-color: var(--primary);
}
input::placeholder,
textarea::placeholder { color: #a1acb8; }

button,
.button {
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    padding: 10px 14px;
    cursor: pointer;
    font: inherit;
    font-weight: 750;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    white-space: nowrap;
    transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease, background .14s ease;
}
button:hover,
.button:hover {
    color: var(--ink);
    border-color: #aebdca;
    box-shadow: 0 8px 18px rgba(16, 24, 32, .08);
    transform: translateY(-1px);
}
button:active,
.button:active { transform: translateY(0); }
.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: var(--primary-dark);
    color: #fff;
    box-shadow: 0 10px 20px rgba(13, 148, 136, .22);
}
.primary:hover { color: #fff; background: linear-gradient(135deg, #14a79b, #0d6b65); }
.danger-button {
    border-color: #fed7c3;
    background: var(--danger-soft);
    color: var(--danger);
}
.danger-button:hover { color: var(--danger); border-color: #fdba8c; }
.small {
    padding: 6px 10px;
    min-height: 32px;
    font-size: 13px;
}

.alert {
    border: 1px solid #9be8da;
    background: #e8fbf7;
    color: #075e54;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-soft);
    font-weight: 700;
}
.alert.danger {
    border-color: #fecaca;
    background: #fff1f2;
    color: #b91c1c;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}
.stats-grid article {
    min-height: 116px;
    padding: 18px;
    display: grid;
    align-content: space-between;
    position: relative;
    overflow: hidden;
}
.stats-grid article::after {
    content: "";
    position: absolute;
    right: 16px;
    top: 16px;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(13,148,136,.16), rgba(37,99,235,.12));
}
.stats-grid strong {
    display: block;
    font-size: 32px;
    line-height: 1;
    letter-spacing: 0;
}
.stats-grid span {
    color: var(--muted);
    font-weight: 750;
}

.panel {
    padding: 18px;
    margin-bottom: 18px;
}
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}
.panel-head > div { min-width: 0; }
.filters {
    display: grid;
    grid-template-columns: minmax(190px, 1fr) minmax(136px, .55fr) minmax(150px, .6fr) auto auto auto;
    gap: 8px;
    align-items: center;
    width: min(900px, 100%);
}
.grid {
    display: grid;
    gap: 18px;
    margin-bottom: 18px;
}
.grid.two {
    grid-template-columns: minmax(300px, 430px) minmax(0, 1fr);
    align-items: start;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}
th,
td {
    padding: 13px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: #f8fbfc; }
th {
    color: #64748b;
    background: #f7fafc;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0;
    font-weight: 850;
}
td a:not(.button) {
    color: var(--primary-dark);
    font-weight: 800;
}
.muted-cell {
    color: var(--muted);
    text-align: center;
    padding: 34px 10px;
    font-weight: 700;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 850;
    background: #eef2f6;
    color: #475569;
    text-transform: capitalize;
}
.pill::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
}
.pill.active { background: var(--success-soft); color: var(--success); }
.pill.suspended,
.pill.disabled { background: var(--warning-soft); color: var(--warning); }
.pill.expired { background: #fee2e2; color: #b91c1c; }

.inline-form {
    display: inline-flex;
    gap: 8px;
    align-items: center;
}
.details-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.details-grid div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: var(--panel-soft);
}
.details-grid span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
    margin-bottom: 6px;
}
.details-grid strong { overflow-wrap: anywhere; }
.notes {
    margin: 16px 0 0;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #334155;
}
.danger-zone {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}
.pagination {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    color: var(--muted);
    padding-top: 14px;
    font-weight: 700;
}
.code-block,
pre {
    border: 1px solid var(--line);
    background: #f8fafc;
    border-radius: 8px;
    padding: 12px;
    overflow-x: auto;
}
pre {
    margin: 0;
    font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}
.clean-list {
    margin: 0;
    padding-left: 18px;
    color: #334155;
}
.clean-list li + li { margin-top: 10px; }
.empty-state {
    text-align: center;
    padding: 46px;
    color: var(--muted);
    font-weight: 700;
}
code {
    background: #eef2f6;
    color: #334155;
    padding: 3px 6px;
    border-radius: 6px;
    font-size: 13px;
    overflow-wrap: anywhere;
}

@media (max-width: 1020px) {
    .shell { display: block; }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 14px;
        padding: 14px;
    }
    nav {
        display: flex;
        flex-wrap: wrap;
        flex: 1 1 420px;
    }
    nav a,
    .logout button { width: auto; }
    .logout { margin-top: 0; margin-left: auto; }
    .main { padding: 22px; }
    .grid.two { grid-template-columns: 1fr; }
    .filters { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
    body { font-size: 14px; }
    .main,
    .auth-main { padding: 16px; }
    .topbar,
    .panel-head,
    .inline-form {
        align-items: stretch;
        flex-direction: column;
    }
    .auth-card,
    .panel { padding: 16px; }
    .stats-grid,
    .details-grid,
    .filters { grid-template-columns: 1fr; }
    .pagination {
        align-items: stretch;
        flex-direction: column;
    }
    .sidebar { display: block; }
    .brand { margin-bottom: 14px; }
    nav { display: grid; }
    nav a,
    .logout button { width: 100%; }
    .logout { margin-top: 12px; }
    h1 { font-size: 25px; }
    .button,
    button { width: 100%; }
}

.license-toolbar {
    align-items: flex-start;
}
.toolbar-actions {
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
    min-width: min(100%, 720px);
}
.compact-filters {
    grid-template-columns: minmax(180px, 1fr) minmax(130px, .55fr) auto auto;
    width: min(620px, 100%);
}
.licenses-table { min-width: 980px; }
.row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.row-actions form { margin: 0; }
button:disabled,
button:disabled:hover {
    cursor: not-allowed;
    opacity: .48;
    transform: none;
    box-shadow: none;
}
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(16, 24, 32, .48);
    backdrop-filter: blur(6px);
}
.modal-backdrop[hidden] { display: none; }
.modal {
    width: min(460px, 100%);
    max-height: min(720px, calc(100vh - 36px));
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 28px 80px rgba(16, 24, 32, .24);
    padding: 18px;
}
.icon-button {
    width: 36px;
    min-height: 36px;
    padding: 0;
    font-weight: 900;
    text-transform: uppercase;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 4px;
}

@media (max-width: 1020px) {
    .toolbar-actions {
        justify-content: stretch;
        width: 100%;
    }
    .compact-filters { width: 100%; }
}

@media (max-width: 680px) {
    .toolbar-actions,
    .modal-actions,
    .row-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }
    .compact-filters { grid-template-columns: 1fr; }
}
