:root {
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #172033;
    background: #f4f6f9;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: #f4f6f9;
}

button,
input,
select,
textarea {
    font: inherit;
}

.container {
    width: min(1120px, calc(100% - 32px));
    margin-inline: auto;
}

.app-header {
    background: #ffffff;
    border-bottom: 1px solid #dfe4ec;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 28px;
    min-height: 68px;
}

.brand,
.main-nav a,
.table-action a,
.device-card a,
.pagination a,
.back-link {
    color: #172033;
    text-decoration: none;
}

.brand {
    font-size: 1.1rem;
    font-weight: 750;
    white-space: nowrap;
}

.main-nav {
    display: flex;
    gap: 20px;
    margin-right: auto;
}

.main-nav a {
    font-weight: 650;
}

.user-summary {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 0.84rem;
}

.user-summary span,
.muted {
    color: #68758a;
}

.hero {
    padding: 72px 0 36px;
    max-width: 760px;
}

.eyebrow {
    margin: 0 0 12px;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #44556f;
}

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

h1 {
    margin: 0;
    font-size: clamp(2.1rem, 5vw, 3.7rem);
    line-height: 1.05;
}

h2,
h3 {
    margin-top: 0;
}

.lead,
.page-intro {
    color: #526078;
}

.lead {
    margin-top: 22px;
    font-size: 1.12rem;
    line-height: 1.7;
}

.status-grid,
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.status-grid {
    padding-bottom: 64px;
}

.status-card,
.panel,
.device-card,
.empty-card,
.form-card,
.table-card {
    background: #ffffff;
    border: 1px solid #dfe4ec;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgb(24 36 56 / 6%);
}

.status-card,
.panel,
.device-card,
.empty-card {
    padding: 24px;
}

.status-card h2 {
    margin: 18px 0 10px;
    font-size: 1.15rem;
}

.status-card p,
.device-card p,
.panel p {
    margin-bottom: 0;
    line-height: 1.55;
    color: #5c687c;
}

.status-badge {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    background: #e8f5ed;
    color: #21633a;
    font-size: 0.78rem;
    font-weight: 800;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    padding: 54px 0 28px;
}

.narrow-header {
    max-width: 820px;
}

.page-header h1 {
    font-size: clamp(2rem, 4vw, 3rem);
}

.page-intro {
    margin: 12px 0 0;
    line-height: 1.55;
}

.back-link {
    display: inline-block;
    margin-bottom: 22px;
    font-weight: 650;
}

.button-group,
.form-actions,
.section-heading {
    display: flex;
    align-items: center;
    gap: 12px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border: 1px solid #cfd6e2;
    border-radius: 9px;
    background: #ffffff;
    color: #172033;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.button:hover,
.table-action a:hover,
.device-card a:hover,
.main-nav a:hover {
    text-decoration: underline;
}

.button-primary {
    border-color: #173b78;
    background: #173b78;
    color: #ffffff;
}

.button-light {
    background: #f4f6f9;
}

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 22px;
}

.search-bar input {
    flex: 1;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid #cfd6e2;
    border-radius: 9px;
    background: #ffffff;
}

.table-card {
    overflow-x: auto;
}

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

th,
td {
    padding: 16px 18px;
    border-bottom: 1px solid #e6eaf0;
    text-align: left;
    vertical-align: top;
}

th {
    background: #f8f9fb;
    color: #536177;
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

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

td span {
    display: block;
    margin-top: 3px;
}

.table-action {
    text-align: right;
}

.table-action a,
.device-card a {
    font-weight: 700;
}

.inline-delete-form {
    display: inline;
    margin-left: 10px;
}

.danger-link {
    color: #b42318;
    font-weight: 700;
}

.empty-state,
.empty-card {
    color: #647188;
    text-align: center;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 24px 0 48px;
}

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

.detail-list {
    margin: 0;
}

.detail-list div {
    display: grid;
    grid-template-columns: minmax(130px, 0.8fr) minmax(0, 1.2fr);
    gap: 14px;
    padding: 10px 0;
    border-bottom: 1px solid #edf0f4;
}

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

.detail-list dt {
    color: #68758a;
    font-size: 0.88rem;
}

.detail-list dd {
    margin: 0;
    font-weight: 600;
}

.detail-list.compact div {
    grid-template-columns: 120px 1fr;
}

.panel-spaced,
.section-block {
    margin-top: 24px;
}

.section-block {
    padding-bottom: 54px;
}

.section-heading {
    justify-content: space-between;
    margin-bottom: 18px;
}

.section-heading h2 {
    margin-bottom: 0;
}

.device-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.device-card h3 {
    margin: 14px 0 18px;
    font-size: 1.1rem;
}

.form-card {
    max-width: 820px;
    padding: 28px;
    margin-bottom: 54px;
}

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

.form-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.form-field-wide {
    grid-column: 1 / -1;
}

.accessories-fieldset {
    min-width: 0;
    margin: 0;
    padding: 18px;
    border: 1px solid #cbd3df;
    border-radius: 10px;
    background: #f8f9fb;
}

.accessories-fieldset legend {
    padding: 0 8px;
    color: #172033;
    font-size: 1rem;
    font-weight: 800;
}

.accessories-help {
    margin: 0 0 14px;
    color: #526078;
    font-size: 0.88rem;
    line-height: 1.45;
}

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

.form-field label {
    font-size: 0.88rem;
    font-weight: 750;
}

.form-control,
.form-select {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid #cbd3df;
    border-radius: 8px;
    background: #ffffff;
    color: #172033;
}

textarea.form-control {
    resize: vertical;
}

.form-control:focus,
.form-select:focus,
.search-bar input:focus {
    outline: 3px solid rgb(44 104 196 / 18%);
    border-color: #2c68c4;
}

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
}

.checkbox-field input {
    width: 18px;
    height: 18px;
}

.field-error {
    color: #a12929;
    font-size: 0.84rem;
    font-weight: 650;
}

.form-actions {
    justify-content: flex-end;
    margin-top: 26px;
    padding-top: 20px;
    border-top: 1px solid #e5e9ef;
}

.messages {
    padding-top: 18px;
}

.alert {
    padding: 13px 16px;
    border: 1px solid #cfd6e2;
    border-radius: 9px;
    background: #ffffff;
}

.alert-success {
    border-color: #a8d4b7;
    background: #eef8f1;
    color: #215d35;
}

.alert-error {
    border-color: #e0b1b1;
    background: #fff2f2;
    color: #8b2424;
}

.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;
}

@media (max-width: 760px) {
    .header-content,
    .page-header,
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-content {
        padding: 14px 0;
        gap: 12px;
    }

    .main-nav {
        margin-right: 0;
    }

    .user-summary {
        align-items: flex-start;
    }

    .page-header {
        padding-top: 36px;
    }

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

    .form-field-wide {
        grid-column: auto;
    }

    .search-bar {
        flex-wrap: wrap;
    }

    .search-bar input {
        flex-basis: 100%;
    }

    .button-group,
    .form-actions {
        flex-wrap: wrap;
    }

    .detail-list div,
    .detail-list.compact div {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}
