:root {
    --bg: #0f172a;
    --panel: #ffffff;
    --muted: #64748b;
    --text: #102033;
    --line: #d7dee8;
    --brand: #0f766e;
    --brand-dark: #115e59;
    --danger: #b91c1c;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #e8edf3;
}

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

button {
    border: 0;
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    min-height: 38px;
    padding: 8px 12px;
    cursor: pointer;
}

button:hover {
    background: var(--brand-dark);
}

button.secondary {
    background: #334155;
}

button.small-button {
    min-height: 30px;
    padding: 5px 8px;
    border-radius: 5px;
    background: #e2e8f0;
    color: #0f172a;
    font-size: 12px;
}

button.small-button:hover {
    background: #cbd5e1;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: #17202d;
}

.login-panel {
    width: min(420px, 100%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, .22);
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--brand);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 26px;
}

h2 {
    font-size: 17px;
}

h3 {
    margin: 0 0 10px;
    font-size: 14px;
    letter-spacing: 0;
}

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

.sidebar {
    min-width: 0;
    background: var(--panel);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.icon-button {
    width: 38px;
    min-width: 38px;
    padding: 0;
    border-radius: 6px;
    background: #e2e8f0;
    color: #0f172a;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--line);
    border-bottom: 1px solid var(--line);
}

.stats div {
    background: #f8fafc;
    padding: 12px 10px;
}

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

.stats strong {
    font-size: 22px;
}

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

.tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-bottom: 1px solid var(--line);
}

.tab {
    min-height: 42px;
    border-radius: 0;
    background: #f8fafc;
    color: #334155;
    border-right: 1px solid var(--line);
    padding: 6px;
}

.tab.is-active {
    background: #fff;
    color: var(--brand-dark);
    box-shadow: inset 0 -3px 0 var(--brand);
}

.panel {
    display: none;
    padding: 16px;
    overflow: auto;
}

.panel.is-active {
    display: block;
}

.stack {
    display: grid;
    gap: 12px;
}

label span {
    display: block;
    margin-bottom: 5px;
    color: #475569;
    font-size: 13px;
    font-weight: 650;
}

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: #334155;
    font-size: 13px;
    line-height: 1.35;
}

.checkbox-row input {
    width: 16px;
    min-width: 16px;
    min-height: 16px;
    margin-top: 2px;
}

.checkbox-row span {
    margin: 0;
    font-weight: 500;
}

input,
select,
textarea {
    width: 100%;
    min-height: 38px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 10px;
    background: #fff;
    color: #0f172a;
}

textarea {
    resize: vertical;
}

.grid-2,
.grid-3 {
    display: grid;
    gap: 10px;
}

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

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

.hint {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.form-error {
    margin: 0;
    color: var(--danger);
}

.map-shell {
    min-width: 0;
    display: grid;
    grid-template-rows: 52px minmax(0, 1fr);
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
}

.toolbar button {
    background: #334155;
}

#status-line {
    color: var(--muted);
    font-size: 13px;
}

#map {
    min-height: 0;
}

.details-empty {
    color: var(--muted);
    padding: 12px;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
}

.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.detail-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.detail-actions span {
    color: var(--muted);
    font-size: 12px;
}

.object-edit-form {
    margin: 12px 0;
}

.catalog-block {
    display: grid;
    gap: 10px;
    padding: 12px 0 16px;
    border-bottom: 1px solid #e2e8f0;
}

.catalog-block:first-of-type {
    padding-top: 14px;
}

.catalog-block:last-child {
    border-bottom: 0;
}

.catalog-list {
    display: grid;
    gap: 6px;
}

.catalog-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
    min-height: 36px;
    padding: 7px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    font-size: 13px;
}

.catalog-main {
    min-width: 0;
}

.catalog-row .small-button {
    align-self: center;
}

.catalog-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
}

.catalog-meta {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
}

.color-dot {
    width: 12px;
    height: 12px;
    border: 1px solid #94a3b8;
    border-radius: 50%;
    flex: 0 0 auto;
}

.compact-form {
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
}

.form-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.commutation {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.section-title {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.section-title span {
    color: var(--muted);
    font-size: 12px;
}

.endpoint-table {
    display: grid;
    gap: 5px;
    max-height: 280px;
    overflow: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 6px;
    background: #f8fafc;
}

.endpoint-row {
    display: grid;
    grid-template-columns: 14px minmax(76px, .8fr) minmax(110px, 1fr) minmax(72px, .8fr) 48px;
    align-items: center;
    gap: 7px;
    min-height: 30px;
    padding: 4px 5px;
    border-radius: 4px;
    background: #fff;
    font-size: 12px;
}

.endpoint-row strong,
.endpoint-row span,
.endpoint-row em {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.endpoint-row em {
    color: #047857;
    font-style: normal;
    text-align: right;
}

.endpoint-row.is-occupied {
    background: #fff7ed;
}

.endpoint-row.is-occupied em {
    color: #c2410c;
}

.splitter-list {
    display: grid;
    gap: 8px;
}

.splitter-card {
    display: grid;
    gap: 8px;
    padding: 8px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
}

.splitter-title {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
}

.splitter-title span {
    color: var(--muted);
}

.splitter-ports {
    display: grid;
    gap: 6px;
}

.splitter-port-group {
    display: grid;
    gap: 4px;
    font-size: 12px;
}

.splitter-port-group > span {
    color: #475569;
    font-weight: 700;
}

.splitter-port-group div {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.splitter-port-group em {
    min-width: 42px;
    padding: 3px 5px;
    border: 1px solid #fed7aa;
    border-radius: 4px;
    background: #fff7ed;
    color: #c2410c;
    font-style: normal;
    text-align: center;
}

.splitter-port-group em.is-free {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #047857;
}

.detail-table th,
.detail-table td {
    padding: 7px 6px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    vertical-align: top;
}

.fiber-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin-top: 12px;
}

.fiber-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 5px 6px;
    font-size: 12px;
}

.fiber-swatch {
    width: 12px;
    height: 12px;
    border: 1px solid #94a3b8;
    border-radius: 50%;
    flex: 0 0 auto;
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: 48vh 52vh;
    }

    .sidebar {
        order: 2;
        border-right: 0;
        border-top: 1px solid var(--line);
    }

    .map-shell {
        order: 1;
    }
}
