:root {
    --bg: #f3f6fb;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #d7dee9;
    --soft-line: #edf1f7;
    --panel: #ffffff;
    --sidebar: #05223e;
    --sidebar-dark: #03182d;
    --brand: #0f8fd3;
    --brand-strong: #1457d9;
    --green: #16a35b;
    --amber: #e56b13;
    --red: #dc2626;
    --violet: #6746e8;
    --shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    letter-spacing: 0;
}

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

button,
input,
select {
    font: inherit;
}

button {
    min-height: 42px;
    border: 0;
    border-radius: 6px;
    background: var(--brand-strong);
    color: #fff;
    padding: 0 18px;
    font-weight: 800;
    cursor: pointer;
}

button:hover {
    background: #0f3f9f;
}

button:disabled,
.is-disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

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

input[type="checkbox"] {
    width: 18px;
    min-width: 18px;
    min-height: 18px;
    height: 18px;
    accent-color: var(--brand-strong);
}

label span {
    display: block;
    margin-bottom: 6px;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
}

.app-frame {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 28px 14px;
    background: linear-gradient(180deg, var(--sidebar-dark), var(--sidebar));
    color: #e6f2ff;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 10px 34px;
    color: #fff;
    font-size: 28px;
    font-weight: 900;
}

.brand b {
    color: #8ed044;
}

.brand-mark {
    position: relative;
    display: inline-flex;
    width: 34px;
    height: 34px;
    border: 4px solid #8ed044;
    border-radius: 50% 50% 50% 6px;
    transform: rotate(-45deg);
}

.brand-mark::after {
    content: "";
    position: absolute;
    top: 8px;
    left: 8px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e6f2ff;
}

.side-nav {
    display: grid;
    gap: 8px;
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    border-radius: 7px;
    padding: 0 14px;
    color: #dbeafe;
    font-weight: 700;
}

.side-nav a:hover,
.side-nav a.active {
    background: rgba(15, 143, 211, 0.24);
    color: #ffffff;
}

.side-nav a.active {
    border-left: 4px solid #22d3ee;
    padding-left: 10px;
}

.nav-icon {
    position: relative;
    width: 22px;
    height: 22px;
    color: #e0f2fe;
    flex: 0 0 22px;
}

.icon-transfer::before,
.icon-transfer::after {
    content: "";
    position: absolute;
    left: 2px;
    right: 2px;
    height: 2px;
    background: currentColor;
}

.icon-transfer::before {
    top: 7px;
    box-shadow: 5px 5px 0 currentColor;
}

.icon-transfer::after {
    top: 2px;
    right: 0;
    width: 8px;
    height: 8px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    background: transparent;
    transform: rotate(45deg);
}

.icon-plug::before {
    content: "";
    position: absolute;
    inset: 2px 7px 8px;
    border: 2px solid currentColor;
    border-top: 0;
    border-radius: 0 0 6px 6px;
}

.icon-plug::after {
    content: "";
    position: absolute;
    left: 10px;
    bottom: 2px;
    width: 2px;
    height: 8px;
    background: currentColor;
    box-shadow: -5px -15px 0 currentColor, 5px -15px 0 currentColor;
}

.icon-clock::before {
    content: "";
    position: absolute;
    inset: 2px;
    border: 2px solid currentColor;
    border-radius: 50%;
}

.icon-clock::after {
    content: "";
    position: absolute;
    left: 10px;
    top: 5px;
    width: 6px;
    height: 7px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
}

.icon-gear::before {
    content: "";
    position: absolute;
    inset: 4px;
    border: 2px solid currentColor;
    border-radius: 50%;
    box-shadow: 0 -5px 0 -2px currentColor, 0 5px 0 -2px currentColor, 5px 0 0 -2px currentColor, -5px 0 0 -2px currentColor;
}

.sidebar-logout {
    margin-top: auto;
    padding: 18px 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.18);
}

.ghost-button {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: transparent;
    color: #dbeafe;
}

.ghost-button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.page-shell {
    width: min(1280px, calc(100% - 52px));
    margin: 0 auto;
    padding: 40px 0 56px;
}

.workspace-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.workspace-header h1 {
    margin: 0 0 6px;
    color: #111827;
    font-size: 31px;
    line-height: 1.08;
}

.workspace-header p {
    margin: 0;
    color: var(--muted);
    font-size: 17px;
}

.header-status {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.header-status span {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    background: #fff;
    color: #334155;
    font-size: 12px;
    font-weight: 800;
}

.hero-panel,
.section-band,
.summary-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.hero-panel {
    padding: 24px;
}

.migration-steps {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.step {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 7px;
    color: #64748b;
    font-size: 13px;
}

.step::before {
    content: "";
    position: absolute;
    top: 16px;
    left: calc(-50% + 18px);
    width: calc(100% - 36px);
    height: 3px;
    background: #cbd5e1;
}

.step:first-child::before {
    content: none;
}

.step.is-done::before,
.step.is-active::before {
    background: #22b8cf;
}

.step span {
    z-index: 1;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    background: #fff;
    color: #475569;
    font-weight: 900;
}

.step.is-active span {
    border-color: #22b8cf;
    background: #22b8cf;
    color: #fff;
}

.step.is-done span {
    border-color: #22b8cf;
}

.connection-flow {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr);
    align-items: center;
    gap: 16px;
}

.connection-card {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 86px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px 18px;
    background: #fff;
}

.connection-card h2 {
    margin: 0 0 8px;
    font-size: 22px;
}

.connection-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #075985;
    font-size: 26px;
    font-weight: 900;
}

.flow-arrow {
    text-align: center;
    color: #64748b;
    font-size: 34px;
}

.status-dot {
    position: relative;
    margin: 0;
    padding-left: 20px;
    color: #64748b;
    font-weight: 700;
}

.status-dot::before {
    content: "";
    position: absolute;
    left: 0;
    top: 5px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #94a3b8;
}

.status-dot.is-ok {
    color: var(--green);
}

.status-dot.is-ok::before {
    background: var(--green);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 318px;
    gap: 24px;
    align-items: start;
    margin-top: 18px;
}

.section-band {
    margin-top: 18px;
    padding: 22px;
}

.dashboard-grid > .section-band,
.dashboard-grid > .summary-panel {
    margin-top: 0;
}

.primary-panel {
    min-width: 0;
}

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

.compact-heading {
    margin-top: 22px;
}

.section-heading h2,
.run-title h3,
.run-panel h3,
.summary-panel h2 {
    margin: 0;
}

.section-heading p {
    max-width: 520px;
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.eyebrow {
    margin: 0 0 6px;
    color: #4f6f9f;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

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

.preflight-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-actions {
    display: flex;
    align-items: end;
}

.search-row,
.execute-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-row button {
    min-width: 134px;
}

.preflight-block {
    margin-top: 20px;
}

.checkbox-line {
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: center;
    min-height: 42px;
}

.checkbox-line span {
    margin-bottom: 0;
}

.status-strip,
.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}

.status-strip span,
.metrics div {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
    background: #f8fafc;
}

.metrics span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.metrics strong {
    display: block;
    margin-top: 4px;
    font-size: 24px;
}

.summary-panel {
    position: sticky;
    top: 24px;
    padding: 22px;
}

.summary-panel h2 {
    font-size: 23px;
}

.summary-list {
    margin-top: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 48px;
    border-bottom: 1px solid var(--line);
    padding: 9px 12px;
}

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

.summary-row span {
    color: #475569;
}

.summary-row strong {
    font-size: 27px;
}

.summary-row.good strong {
    color: var(--green);
}

.summary-row.warn strong {
    color: var(--amber);
}

.summary-row.neutral strong {
    color: #64748b;
}

.hardware-progress {
    margin-top: 18px;
    border-top: 1px solid var(--line);
    padding-top: 18px;
}

.hardware-progress > div:first-child {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #334155;
}

.progress-bar {
    height: 10px;
    margin-top: 10px;
    border-radius: 999px;
    background: #e2e8f0;
    overflow: hidden;
}

.progress-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--green);
}

.summary-check {
    margin-top: 20px;
}

.start-button,
.check-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 54px;
    margin-top: 12px;
    border-radius: 6px;
    font-weight: 900;
}

.start-button {
    background: var(--green);
}

.start-button:hover {
    background: #118348;
}

.check-button {
    border: 1px solid #0f4c81;
    background: #fff;
    color: #0f4c81;
}

.secondary-button {
    border: 1px solid #0f4c81;
    background: #fff;
    color: #0f4c81;
}

.secondary-button:hover,
.check-button:hover {
    background: #eff6ff;
}

.notice {
    border-radius: 6px;
    margin-bottom: 14px;
    padding: 12px 14px;
    line-height: 1.45;
}

.notice-ok {
    border: 1px solid #b7e4c7;
    background: #effaf3;
    color: #14532d;
}

.notice-error {
    border: 1px solid #fecaca;
    background: #fff1f2;
    color: var(--red);
}

.notice-warn {
    border: 1px solid #fde68a;
    background: #fffbeb;
    color: #713f12;
}

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

.search-row + .table-wrap {
    margin-top: 0;
}

.table-wrap.compact {
    margin-top: 14px;
}

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

th,
td {
    border-bottom: 1px solid var(--soft-line);
    padding: 11px 12px;
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f8fafc;
    color: #334155;
    font-size: 12px;
    text-transform: uppercase;
}

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

.check-cell {
    width: 42px;
    text-align: center;
}

.client-line {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
}

.unit-count {
    display: inline-flex;
    min-height: 22px;
    align-items: center;
    border-radius: 6px;
    padding: 2px 8px;
    background: #eef4ff;
    color: #0f3f9f;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    min-height: 24px;
    align-items: center;
    border-radius: 999px;
    padding: 3px 9px;
    background: #e5e7eb;
    color: #374151;
    font-size: 12px;
    font-weight: 800;
}

.badge-checked,
.badge-ready,
.badge-completed,
.badge-created,
.badge-existing,
.badge-existing_mapping,
.badge-existing_updated,
.badge-account_ready,
.badge-imported,
.badge-message_transfer {
    background: #dcfce7;
    color: var(--green);
}

.badge-blocked,
.badge-conflict,
.badge-failed,
.badge-completed_with_errors,
.badge-missing_hardware {
    background: #fee2e2;
    color: var(--red);
}

.badge-queued,
.badge-running,
.badge-create,
.badge-create_renamed,
.badge-map_existing {
    background: #dbeafe;
    color: #0f3f9f;
}

.badge-skip,
.badge-skipped {
    background: #fef3c7;
    color: #a45f00;
}

.run-panel {
    margin-top: 18px;
    border-top: 4px solid var(--brand);
    padding-top: 18px;
}

.run-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.execute-row {
    margin: 18px 0;
}

.execute-row span {
    color: var(--muted);
    font-size: 13px;
}

.muted {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.backline {
    margin-bottom: 16px;
}

.login-panel {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 1080px) {
    .app-frame {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        min-height: auto;
        padding: 18px;
    }

    .side-nav {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .side-nav a {
        justify-content: center;
        padding: 0 10px;
        text-align: center;
    }

    .side-nav a.active {
        border-left: 0;
        border-bottom: 4px solid #22d3ee;
        padding-left: 10px;
    }

    .sidebar-logout {
        margin-top: 16px;
    }

    .dashboard-grid,
    .connection-flow {
        grid-template-columns: 1fr;
    }

    .flow-arrow {
        font-size: 24px;
        transform: rotate(90deg);
    }

    .summary-panel {
        position: static;
    }
}

@media (max-width: 820px) {
    .page-shell {
        width: min(100% - 24px, 760px);
        padding-top: 24px;
    }

    .workspace-header,
    .section-heading,
    .search-row,
    .execute-row {
        align-items: stretch;
        flex-direction: column;
    }

    .workspace-header h1 {
        font-size: 26px;
    }

    .side-nav,
    .migration-steps,
    .grid-form,
    .preflight-form,
    .status-strip,
    .metrics {
        grid-template-columns: 1fr;
    }

    .step::before {
        content: none;
    }

    .section-band,
    .hero-panel,
    .summary-panel {
        padding: 16px;
    }

    .search-row button {
        width: 100%;
    }
}
