:root {
    color-scheme: light;
    --bg: #f5f7fa;
    --panel: #ffffff;
    --ink: #18202f;
    --muted: #647084;
    --line: #d8dee8;
    --accent: #0f766e;
    --accent-strong: #115e59;
    --blue: #2563eb;
    --danger: #b42318;
    --danger-soft: #fee4e2;
    --warning: #b54708;
    --warning-soft: #fef0c7;
    --success: #067647;
    --success-soft: #dcfae6;
    --shadow: 0 10px 30px rgba(24, 32, 47, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    font-size: 16px;
}

body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

label {
    color: var(--ink);
    font-weight: 650;
}

input,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.65rem 0.75rem;
    background: #fff;
    color: var(--ink);
}

input:focus,
select:focus,
button:focus,
a:focus {
    outline: 3px solid rgba(37, 99, 235, 0.22);
    outline-offset: 2px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

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

th {
    color: var(--muted);
    font-size: 0.78rem;
    letter-spacing: 0;
    text-transform: uppercase;
    white-space: nowrap;
}

td {
    color: var(--ink);
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: center;
    min-height: 68px;
    padding: 0.75rem clamp(1rem, 3vw, 2rem);
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.app-brand {
    display: inline-flex;
    gap: 0.65rem;
    align-items: center;
    color: var(--ink);
    font-weight: 750;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
}

.app-nav {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    scrollbar-width: none;
}

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

.app-nav a,
.user-menu a,
.user-menu button {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0.45rem 0.7rem;
    border-radius: 8px;
    color: var(--muted);
    white-space: nowrap;
}

.app-nav a:hover,
.user-menu a:hover,
.user-menu button:hover {
    background: #edf2f7;
    color: var(--ink);
    text-decoration: none;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.user-menu form {
    margin: 0;
}

.user-menu button {
    border: 0;
    background: transparent;
}

.app-main {
    width: min(1240px, 100%);
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2rem);
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.page-heading h1 {
    margin: 0;
    font-size: clamp(1.7rem, 4vw, 2.4rem);
    line-height: 1.05;
}

.eyebrow {
    margin: 0 0 0.35rem;
    color: var(--accent-strong);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.heading-actions,
.button-row,
.panel-subhead,
.inline-form {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.metric-card,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric-card {
    display: grid;
    gap: 0.35rem;
    min-height: 132px;
    padding: 1rem;
    color: var(--ink);
}

.metric-card:hover {
    border-color: rgba(15, 118, 110, 0.5);
    text-decoration: none;
}

.metric-card strong {
    font-size: 2rem;
    line-height: 1;
}

.metric-label,
.subtle {
    color: var(--muted);
    font-size: 0.88rem;
}

.subtle {
    display: block;
    margin-top: 0.2rem;
}

.two-column {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel {
    padding: 1rem;
    margin-bottom: 1rem;
}

.narrow-panel {
    max-width: 760px;
}

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

.panel-heading h2 {
    margin: 0;
    font-size: 1.05rem;
}

.compact-list {
    display: grid;
    gap: 0.55rem;
}

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

.diagnostic-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem;
    background: #fff;
}

.list-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--line);
}

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

.diagnostic-row {
    align-items: flex-start;
}

.list-row span:not(.status-pill) {
    display: block;
    margin-top: 0.15rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 750;
    white-space: nowrap;
}

.status-pill.success {
    background: var(--success-soft);
    color: var(--success);
}

.status-pill.warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.status-pill.danger {
    background: var(--danger-soft);
    color: var(--danger);
}

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

.vm-table {
    min-width: 780px;
    table-layout: fixed;
}

.vm-table .vm-name-col {
    width: auto;
}

.vm-table .vm-host-col {
    width: 140px;
}

.vm-table .vm-state-col {
    width: 96px;
}

.vm-table .vm-uptime-col {
    width: 170px;
}

.vm-table .vm-status-col {
    width: 130px;
}

.vm-table .vm-actions-col {
    width: 130px;
}

.vm-table .vm-name-cell {
    overflow-wrap: anywhere;
    word-break: normal;
}

.vm-table .host-name-cell {
    white-space: nowrap;
}

.vm-table .state-cell,
.vm-table .uptime-cell {
    white-space: nowrap;
}

.vm-table .status-cell {
    overflow-wrap: break-word;
}

.vm-table .actions-cell .button-row {
    align-items: stretch;
}

.vm-table .actions-cell button {
    width: 100%;
}

.pending-updates-table {
    min-width: 0;
    table-layout: fixed;
}

.pending-updates-table th:first-child,
.pending-updates-table td:first-child {
    width: auto;
    overflow-wrap: anywhere;
}

.pending-updates-table th:nth-child(2),
.pending-updates-table td:nth-child(2) {
    width: 7.5rem;
}

.pending-updates-table th:nth-child(3),
.pending-updates-table td:nth-child(3) {
    width: 5.5rem;
}

.action-column {
    width: 1%;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0.55rem 0.8rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font-weight: 750;
    white-space: nowrap;
}

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

.primary-button:hover {
    background: var(--accent-strong);
    text-decoration: none;
}

.secondary-button,
.icon-button {
    background: #fff;
    border-color: var(--line);
    color: var(--ink);
}

.secondary-button:hover,
.icon-button:hover {
    background: #edf2f7;
    text-decoration: none;
}

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

.danger-button:hover {
    background: #8f1d16;
}

.stack {
    display: grid;
    gap: 0.7rem;
}

.inline-form {
    margin-bottom: 1rem;
}

.inline-form select {
    max-width: 340px;
}

.update-query-form select {
    flex: 1 1 420px;
    max-width: min(680px, 100%);
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
}

.target-group-label {
    margin: 0.65rem 0 0.2rem;
    padding-top: 0.15rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.restart-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem 0.75rem;
}

.option-row {
    min-height: 34px;
}

.mini-field {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) 92px;
    gap: 0.65rem;
    align-items: center;
    color: var(--ink);
    font-weight: 650;
}

.mini-field input {
    min-height: 40px;
}

.update-target-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    max-height: 390px;
    overflow-y: auto;
    padding: 0.35rem 0.55rem 0.7rem 0;
    scroll-padding-bottom: 1rem;
}

.update-target-row {
    display: flex;
    gap: 0.8rem;
    align-items: flex-start;
    width: 100%;
    min-height: 68px;
    padding: 0.7rem 0.75rem;
    border: 1px solid transparent;
    border-radius: 8px;
    line-height: 1.35;
    color: var(--ink);
    font-weight: 650;
}

.update-target-row:hover {
    background: #f8fafc;
}

.update-target-row input {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    min-height: 18px;
    margin: 0.2rem 0 0;
}

.check-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    min-height: 40px;
    font-weight: 600;
}

.check-row input {
    flex: 0 0 auto;
    width: 18px;
    min-height: 18px;
    margin-top: 0.2rem;
}

.target-text,
.target-name {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
}

.target-text {
    flex: 1 1 auto;
    line-height: 1.35;
}

.target-name {
    font-size: 0.97rem;
    font-weight: 800;
}

.target-detail {
    display: block;
    min-width: 0;
    margin-top: 0.28rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.target-text small {
    display: block;
    margin-top: 0.18rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.35;
}

.update-target-list + .primary-button {
    margin-top: 0.35rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 0.65rem 1rem;
    margin: 0;
}

.detail-grid dt {
    color: var(--muted);
    font-weight: 750;
}

.detail-grid dd {
    margin: 0;
    min-width: 0;
    word-break: break-word;
}

.internet-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.internet-summary-item {
    display: grid;
    gap: 0.35rem;
    align-content: start;
    min-width: 0;
    padding: 0.2rem 0 0.85rem;
    border-bottom: 1px solid var(--line);
}

.internet-summary-item strong {
    min-width: 0;
    overflow-wrap: anywhere;
}

.internet-summary-item small {
    color: var(--muted);
    font-weight: 600;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.internet-detail-list {
    display: grid;
    gap: 0;
    margin: 0;
}

.internet-detail-list > div {
    display: grid;
    grid-template-columns: 170px minmax(0, 1fr);
    gap: 1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--line);
}

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

.internet-detail-list dt {
    color: var(--muted);
    font-weight: 750;
}

.internet-detail-list dd {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
    margin: 0;
}

.internet-detail-list dd strong,
.internet-detail-list dd span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.internet-detail-list dd span {
    color: var(--ink);
}

.essentials-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1.35rem 1.2rem;
    margin: 0;
}

.essentials-grid div {
    min-width: 0;
}

.essentials-grid dt {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 650;
    margin-bottom: 0.35rem;
}

.essentials-grid dd {
    margin: 0;
    min-width: 0;
    color: var(--ink);
    word-break: break-word;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

.tool-link {
    display: grid;
    gap: 0.25rem;
    min-height: 76px;
    padding: 0.85rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
}

.tool-link:hover {
    border-color: rgba(37, 99, 235, 0.45);
    background: #f8fbff;
    text-decoration: none;
}

.tool-link span {
    color: var(--muted);
    font-size: 0.84rem;
}

.tool-link small {
    min-width: 0;
    color: var(--muted);
    font-size: 0.74rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.battery-layout {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 1rem;
    align-items: center;
}

.battery-meter {
    position: relative;
    width: 70px;
    height: 150px;
    border: 3px solid var(--line);
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
}

.battery-meter::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 22px;
    width: 22px;
    height: 8px;
    border-radius: 4px 4px 0 0;
    background: var(--line);
}

.battery-meter span {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: block;
    background: var(--success);
}

.battery-meter.danger span {
    background: var(--danger);
}

.alert,
.validation-summary {
    padding: 0.75rem 0.85rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid var(--line);
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
    border-color: rgba(6, 118, 71, 0.24);
}

.alert-danger,
.validation-summary {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: rgba(180, 35, 24, 0.24);
}

.validation-summary-valid {
    display: none;
}

.error-text,
.field-validation-error {
    color: var(--danger);
}

.empty-text {
    color: var(--muted);
    margin: 0;
}

.auth-body {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 1rem;
    background:
        linear-gradient(180deg, rgba(15, 118, 110, 0.12), transparent 38%),
        var(--bg);
}

.auth-shell {
    width: min(420px, 100%);
}

.auth-panel {
    display: grid;
    gap: 1rem;
    padding: 1.35rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.auth-panel h1 {
    margin: 0;
    font-size: 1.8rem;
}

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

@media (max-width: 980px) {
    .app-header {
        grid-template-columns: 1fr auto;
    }

    .app-nav {
        grid-column: 1 / -1;
        order: 3;
        padding-top: 0.2rem;
    }

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

    .two-column {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .app-header {
        gap: 0.5rem;
    }

    .app-main {
        padding: 1rem;
    }

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

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

    .detail-grid,
    .essentials-grid,
    .diagnostic-grid,
    .battery-layout,
    .checkbox-grid {
        grid-template-columns: 1fr;
    }

    .internet-summary-grid,
    .internet-detail-list > div {
        grid-template-columns: 1fr;
    }

    .internet-detail-list > div {
        gap: 0.35rem;
    }

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

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

@media (max-width: 980px) {
    .essentials-grid,
    .tool-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .essentials-grid,
    .tool-grid {
        grid-template-columns: 1fr;
    }
}
