:root {
    color-scheme: light;
    --ink: #172033;
    --ink-strong: #0b1220;
    --muted: #667085;
    --muted-strong: #475467;
    --line: #e4e7ec;
    --line-strong: #d0d5dd;
    /* Brand coral from ardakara.net (theme-color #ff8c61). The bright hue is
       used decoratively; interactive text/CTAs use the deeper, AA-contrast
       coral so white or dark text stays legible. */
    --brand: #ff8c61;
    --brand-strong: #ec6a3d;
    --accent: #b8481a;
    --accent-dark: #9a3b14;
    --accent-soft: #fff2ec;
    --accent-ink: #8a3412;
    --danger: #d92d20;
    --danger-soft: #fef3f2;
    --success: #067647;
    --success-soft: #ecfdf3;
    --warning: #b54708;
    --warning-soft: #fffaeb;
    --bg: #fafafa;
    --card: #ffffff;
    --header: rgba(255, 255, 255, 0.92);
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 10px 30px rgba(16, 24, 40, 0.08);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
}

* {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
}

html {
    min-width: 320px;
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 8% -12%, rgba(255, 140, 97, 0.10), transparent 26rem),
        var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select {
    font: inherit;
}

a {
    color: var(--accent);
}

:focus-visible {
    outline: 3px solid rgba(255, 140, 97, 0.38);
    outline-offset: 2px;
}

.skip-link {
    position: fixed;
    z-index: 100;
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.65rem 0.85rem;
    color: #fff;
    background: var(--ink-strong);
    border-radius: var(--radius-sm);
    transform: translateY(-150%);
    transition: transform 0.15s ease;
}

.skip-link:focus {
    transform: translateY(0);
}

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

.topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    background: var(--header);
    border-bottom: 1px solid rgba(208, 213, 221, 0.8);
    backdrop-filter: blur(16px);
}

.topbar-inner {
    max-width: 1180px;
    min-height: 68px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.4rem;
}

.brand {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 0.7rem;
    color: var(--ink-strong);
    font-size: 1rem;
    font-weight: 750;
    letter-spacing: -0.015em;
    text-decoration: none;
}

.brand-mark {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(145deg, #ffa274, #ec6a3d);
    border-radius: 10px;
    box-shadow: 0 6px 16px rgba(236, 106, 61, 0.28);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.nav {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-right: auto;
}

.nav a,
.admin-link {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.7rem;
    color: var(--muted-strong);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

.nav a:hover,
.nav a.active,
.admin-link:hover,
.admin-link.active {
    color: var(--accent-ink);
    background: var(--accent-soft);
}

.header-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--muted);
}

.user-name {
    max-width: 180px;
    overflow: hidden;
    font-size: 0.85rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user form {
    margin: 0;
}

.content {
    max-width: 1180px;
    width: 100%;
    flex: 1;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
}

.footer {
    padding: 1.25rem 1.5rem 2rem;
    color: var(--muted);
    font-size: 0.8rem;
    text-align: center;
}

h1,
h2,
h3,
p {
    overflow-wrap: break-word;
}

h1 {
    margin: 0;
    color: var(--ink-strong);
    font-size: clamp(1.65rem, 2.5vw, 2.1rem);
    line-height: 1.2;
    letter-spacing: -0.035em;
}

h2 {
    margin: 0 0 0.75rem;
    color: var(--ink-strong);
    font-size: 1.05rem;
    line-height: 1.35;
    letter-spacing: -0.015em;
}

h3 {
    margin: 0;
    color: var(--ink-strong);
    font-size: 1rem;
}

.content > h1 {
    margin-bottom: 1rem;
}

.page-header {
    margin-bottom: 1.6rem;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
}

.page-heading {
    max-width: 680px;
}

.eyebrow {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--accent);
    font-size: 0.74rem;
    font-weight: 750;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.page-intro {
    margin: 0.55rem 0 0;
    color: var(--muted);
    font-size: 0.98rem;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
    color: var(--muted-strong);
    font-size: 0.86rem;
    font-weight: 600;
    text-decoration: none;
}

.breadcrumb:hover {
    color: var(--accent);
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 0.85rem;
}

.btn {
    min-height: 40px;
    padding: 0.55rem 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    color: var(--ink);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 650;
    line-height: 1.15;
    text-align: center;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease,
        box-shadow 0.15s ease, transform 0.15s ease;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.btn-primary {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 1px 2px rgba(194, 82, 31, 0.20);
}

.btn-primary:hover:not(:disabled) {
    color: #fff;
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    box-shadow: 0 5px 14px rgba(194, 82, 31, 0.24);
}

.btn-outline {
    color: var(--ink);
    background: var(--card);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-sm);
}

.btn-outline:hover:not(:disabled) {
    color: var(--accent-ink);
    background: var(--accent-soft);
    border-color: #ffc2a3;
}

.btn-danger {
    color: var(--danger);
    background: var(--card);
    border-color: #fecdca;
}

.btn-danger:hover:not(:disabled) {
    color: #b42318;
    background: var(--danger-soft);
    border-color: #fda29b;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 1rem;
}

.card {
    position: relative;
    min-width: 0;
    display: block;
    padding: 1.2rem;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

a.card:hover {
    border-color: #ffc2a3;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-head {
    margin-bottom: 0.8rem;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.card-title {
    display: grid;
    gap: 0.15rem;
}

.card-title strong {
    color: var(--ink-strong);
    font-size: 1.02rem;
}

.card-body {
    display: grid;
    gap: 0.45rem;
    font-size: 0.9rem;
}

.card-footer {
    margin-top: 1rem;
    padding-top: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    color: var(--accent);
    border-top: 1px solid var(--line);
    font-size: 0.84rem;
    font-weight: 650;
}

.meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.meta-row span:last-child {
    color: var(--ink);
    font-weight: 600;
    text-align: right;
}

.usage {
    display: grid;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.usage-label {
    display: flex;
    justify-content: space-between;
    color: var(--muted);
    font-size: 0.78rem;
}

.usage-track {
    height: 6px;
    overflow: hidden;
    background: #eef0f4;
    border-radius: 999px;
}

.usage-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffb088, #ec6a3d);
    border-radius: inherit;
}

.badge {
    max-width: 100%;
    padding: 0.22rem 0.55rem;
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    color: var(--muted-strong);
    background: #f2f4f7;
    font-size: 0.7rem;
    font-weight: 750;
    letter-spacing: 0.045em;
    line-height: 1.35;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-active {
    color: var(--success);
    background: var(--success-soft);
}

.badge-pastdue,
.badge-graceperiod,
.badge-cancelledatperiodend {
    color: var(--warning);
    background: var(--warning-soft);
}

.badge-suspended,
.badge-revoked,
.badge-expired,
.badge-cancelled {
    color: #b42318;
    background: var(--danger-soft);
}

.summary-grid {
    margin-bottom: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 0.75rem;
}

.summary-item {
    min-width: 0;
    padding: 0.9rem 1rem;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.summary-label {
    display: block;
    margin-bottom: 0.15rem;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 650;
}

.summary-value {
    display: block;
    overflow: hidden;
    color: var(--ink-strong);
    font-size: 0.95rem;
    font-weight: 700;
    text-overflow: ellipsis;
}

.panel {
    margin: 1rem 0;
    padding: 1.35rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

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

.panel-head h2 {
    margin-bottom: 0.25rem;
}

.panel-head p {
    margin: 0;
}

.key-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.key {
    min-width: 0;
    padding: 0.65rem 0.8rem;
    color: var(--ink-strong);
    background: #f8f9fc;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    letter-spacing: 0.035em;
    user-select: all;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

table.devices {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

table.devices th,
table.devices td {
    padding: 0.75rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

table.devices th {
    color: var(--muted-strong);
    background: #f9fafb;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.025em;
    text-transform: uppercase;
    white-space: nowrap;
}

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

table.devices tbody tr:hover td {
    background: #fcfcfd;
}

tr.inactive td {
    color: var(--muted);
}

.empty {
    padding: 3.4rem 1.25rem;
    display: grid;
    justify-items: center;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.72);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    text-align: center;
}

.empty-mark {
    width: 48px;
    height: 48px;
    margin-bottom: 0.8rem;
    display: grid;
    place-items: center;
    color: var(--accent-ink);
    background: var(--accent-soft);
    border-radius: 14px;
    font-size: 1.15rem;
    font-weight: 800;
}

.empty h2,
.empty p {
    margin: 0;
}

.empty p + p,
.empty p + .btn,
.empty h2 + p {
    margin-top: 0.4rem;
}

.empty .btn {
    margin-top: 1rem;
}

.loading {
    min-height: 180px;
    display: grid;
    place-items: center;
    color: var(--muted);
}

.alert {
    margin: 0.85rem 0;
    padding: 0.75rem 0.85rem;
    color: #b42318;
    background: var(--danger-soft);
    border: 1px solid #fecdca;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
}

.alert-ok {
    color: var(--success);
    background: var(--success-soft);
    border-color: #abefc6;
}

/* Login */
.login-wrap {
    min-height: 100vh;
    padding: 2rem 1rem;
    display: grid;
    place-items: center;
    background: #fafafa;
}

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

.login-brand {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    color: var(--ink-strong);
    font-weight: 750;
}

.login-brand .brand-mark {
    background: linear-gradient(145deg, #ffa274, #ec6a3d);
}

.login-card {
    width: 100%;
    padding: 2rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
}

.login-card h1 {
    margin-top: 0;
}

.login-card label {
    display: block;
    margin: 1rem 0 0.35rem;
    color: var(--muted-strong);
    font-size: 0.84rem;
    font-weight: 650;
}

.login-card input {
    width: 100%;
}

.login-card .btn-primary {
    width: 100%;
    margin-top: 1.25rem;
}

.login-help {
    margin: 1.25rem 0 0;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

/* Forms and admin */
input,
select {
    min-height: 42px;
    max-width: 100%;
    padding: 0.55rem 0.7rem;
    color: var(--ink);
    background: var(--card);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:hover,
select:hover {
    border-color: #98a2b3;
}

input:focus,
select:focus {
    border-color: #ff8c61;
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 140, 97, 0.22);
}

select:disabled,
input:disabled {
    color: var(--muted);
    background: #f2f4f7;
}

.admin-link {
    color: var(--accent-ink);
}

.stats {
    margin-bottom: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 0.75rem;
}

.stat {
    min-width: 0;
    padding: 1rem;
    display: grid;
    gap: 0.2rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.stat-value {
    color: var(--ink-strong);
    font-size: 1.55rem;
    font-weight: 760;
    line-height: 1.15;
    letter-spacing: -0.035em;
}

.stat-label {
    color: var(--muted);
    font-size: 0.78rem;
}

.stat-warn .stat-value {
    color: var(--warning);
}

.stat-bad .stat-value {
    color: var(--danger);
}

.search-row {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.search-row input {
    min-width: 220px;
    flex: 1;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.action {
    min-width: 0;
    display: grid;
    gap: 0.4rem;
    align-content: start;
}

.action label {
    color: var(--muted-strong);
    font-size: 0.82rem;
    font-weight: 650;
}

.action input,
.action select {
    width: 100%;
}

.action input[type="checkbox"] {
    width: auto;
    min-height: auto;
    margin-right: 0.4rem;
    vertical-align: -1px;
}

.action label:has(input[type="checkbox"]) {
    color: var(--ink);
    font-size: 0.9rem;
}

.action-buttons {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.panel h2 + .action-grid,
.panel table + .action-grid,
.panel .table-wrap + .action-grid {
    margin-top: 1rem;
}

.admin-shortcuts {
    margin-bottom: 1.25rem;
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.catalogue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.catalogue-card {
    display: flex;
    flex-direction: column;
}

.catalogue-card .card-footer {
    margin-top: auto;
}

.catalogue-description {
    min-height: 2.6em;
    margin: 0 0 0.9rem;
}

.catalogue-metrics {
    padding: 0.75rem 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    color: var(--muted);
    border-top: 1px solid var(--line);
    font-size: 0.75rem;
    text-align: center;
}

.catalogue-metrics strong {
    display: block;
    color: var(--ink-strong);
    font-size: 1.05rem;
}

.workflow-focus {
    border-color: #ffd6c2;
    box-shadow: 0 10px 35px rgba(236, 106, 61, 0.10);
}

.workflow-nav {
    margin: 0 0 1.25rem;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow: hidden;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.workflow-nav-compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.workflow-step {
    min-width: 0;
    min-height: 68px;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--muted-strong);
    background: transparent;
    border: 0;
    border-right: 1px solid var(--line);
    cursor: pointer;
    text-align: left;
}

.workflow-step:last-child {
    border-right: 0;
}

.workflow-step:hover:not(:disabled) {
    background: #f9fafb;
}

.workflow-step.active {
    color: var(--accent-ink);
    background: var(--accent-soft);
    box-shadow: inset 0 -3px 0 var(--brand);
}

.workflow-step:disabled {
    cursor: wait;
    opacity: 0.65;
}

.workflow-step > span:last-child {
    min-width: 0;
    display: grid;
}

.workflow-step strong,
.workflow-step small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.workflow-step strong {
    font-size: 0.84rem;
}

.workflow-step small {
    color: var(--muted);
    font-size: 0.7rem;
}

.workflow-number {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: var(--muted-strong);
    background: #f2f4f7;
    border-radius: 50%;
    font-size: 0.72rem;
    font-weight: 750;
}

.workflow-step.active .workflow-number {
    color: #fff;
    background: var(--accent);
}

.readiness-list {
    margin: 1rem 0;
    display: grid;
    gap: 0.55rem;
}

.readiness-item {
    width: 100%;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--ink);
    background: #fcfcfd;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
}

.readiness-item:hover {
    border-color: #ffc2a3;
    background: var(--accent-soft);
}

.readiness-item > span:last-child {
    display: grid;
}

.readiness-item strong {
    font-size: 0.88rem;
}

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

.readiness-mark {
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: var(--warning);
    background: var(--warning-soft);
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 800;
}

.readiness-item.complete .readiness-mark {
    color: var(--success);
    background: var(--success-soft);
}

.danger-confirm,
.notice {
    margin-top: 1rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-radius: var(--radius-sm);
}

.danger-confirm {
    color: #912018;
    background: var(--danger-soft);
    border: 1px solid #fecdca;
}

.notice {
    color: var(--muted-strong);
    background: #f8f9fc;
    border: 1px solid var(--line);
}

.danger-confirm > div:first-child,
.notice > span {
    min-width: 0;
}

.danger-confirm p {
    margin: 0.2rem 0 0;
    font-size: 0.82rem;
}

.danger-confirm .action-buttons {
    flex: 0 0 auto;
    margin-top: 0;
}

.notice strong,
.notice span {
    display: block;
}

.notice span {
    flex: 1;
    font-size: 0.82rem;
}

.configuration-list {
    margin-bottom: 1rem;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}

.configuration-row {
    min-width: 0;
    padding: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--card);
    border-bottom: 1px solid var(--line);
}

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

.configuration-row.current {
    background: var(--success-soft);
}

.configuration-row > div:first-child {
    min-width: 0;
    display: grid;
}

.configuration-row strong,
.configuration-row span {
    overflow-wrap: anywhere;
}

.configuration-row > div:first-child > span,
.configuration-meta {
    color: var(--muted);
    font-size: 0.78rem;
}

.configuration-meta {
    max-width: 45%;
    text-align: right;
}

.configuration-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.subform {
    margin-top: 1.15rem;
    padding-top: 1.15rem;
    border-top: 1px solid var(--line);
}

.subform h3 {
    margin-bottom: 0.8rem;
}

.field-help {
    display: block;
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.76rem;
}

.field-warning {
    color: var(--warning);
}

.settings-group {
    padding: 1rem 0;
    border-bottom: 1px solid var(--line);
}

.settings-group:first-of-type {
    padding-top: 0;
}

.settings-group:last-of-type {
    border-bottom: 0;
}

.settings-group-head {
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.switch-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--ink) !important;
}

.switch-label input {
    width: auto;
    min-height: auto;
}

.entitlement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 0.75rem;
}

.entitlement-option {
    padding: 0.8rem;
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    background: #fcfcfd;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.entitlement-option:has(input:checked) {
    background: var(--accent-soft);
    border-color: #ffc2a3;
}

.entitlement-option input {
    width: auto;
    min-height: auto;
    margin-top: 0.2rem;
}

.entitlement-option > span {
    min-width: 0;
    display: grid;
}

.entitlement-option strong {
    font-size: 0.86rem;
}

.entitlement-option small {
    color: var(--muted);
    font-size: 0.74rem;
    overflow-wrap: anywhere;
}

.plan-card .card-body {
    min-height: 145px;
}

.plan-card .btn {
    width: 100%;
    margin-top: auto;
}

.feature-list {
    margin: 0.35rem 0;
    padding: 0;
    display: grid;
    gap: 0.35rem;
    color: var(--muted-strong);
    font-size: 0.84rem;
    list-style: none;
}

.feature-list li::before {
    content: "✓";
    margin-right: 0.4rem;
    color: var(--success);
    font-weight: 800;
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.88em;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

@media (max-width: 880px) {
    .topbar-inner {
        padding: 0.65rem 1rem;
        flex-wrap: wrap;
        gap: 0.45rem 0.75rem;
    }

    .brand {
        margin-right: auto;
    }

    .nav {
        width: 100%;
        order: 3;
        overflow-x: auto;
        padding-bottom: 0.15rem;
        scrollbar-width: none;
    }

    .nav::-webkit-scrollbar {
        display: none;
    }

    .user-name {
        display: none;
    }

    .content {
        padding-top: 1.75rem;
    }

    .workflow-nav {
        grid-template-columns: none;
        grid-auto-flow: column;
        grid-auto-columns: minmax(155px, 1fr);
        overflow-x: auto;
    }

    .workflow-step {
        border-right: 1px solid var(--line);
    }
}

@media (max-width: 640px) {
    .topbar-inner {
        padding-inline: 0.8rem;
    }

    .brand-text {
        font-size: 0.92rem;
    }

    .header-actions {
        gap: 0.25rem;
    }

    .admin-link {
        padding-inline: 0.55rem;
    }

    .user .btn {
        min-height: 36px;
        padding: 0.45rem 0.65rem;
    }

    .content {
        padding: 1.4rem 0.9rem 3rem;
    }

    .page-header {
        margin-bottom: 1.25rem;
        align-items: stretch;
        flex-direction: column;
        gap: 0.9rem;
    }

    .page-actions .btn {
        flex: 1;
    }

    .cards,
    .action-grid,
    .catalogue-grid,
    .entitlement-grid {
        grid-template-columns: 1fr;
    }

    .panel {
        padding: 1rem;
    }

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

    .table-wrap {
        border-right: 0;
        border-left: 0;
        border-radius: 0;
    }

    table.devices {
        min-width: 620px;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .key {
        width: 100%;
        font-size: 0.82rem;
        white-space: normal;
        word-break: break-all;
    }

    .key-row {
        align-items: stretch;
    }

    .key-row .btn {
        width: 100%;
    }

    .action-buttons {
        align-items: stretch;
        flex-direction: column;
    }

    .action-buttons .btn {
        width: 100%;
    }

    .login-wrap {
        padding: 1rem;
    }

    .login-card {
        padding: 1.35rem;
    }

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

    .search-row input,
    .search-row .btn {
        width: 100%;
    }

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

    .danger-confirm,
    .notice,
    .configuration-row {
        align-items: stretch;
        flex-direction: column;
    }

    .configuration-meta {
        max-width: none;
        text-align: left;
    }

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

    .configuration-actions .btn {
        width: 100%;
    }

    .danger-confirm .action-buttons {
        width: 100%;
    }
}

@media (max-width: 400px) {
    .brand-text {
        display: none;
    }

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