@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #fff7f1;
    --text: #1f2933;
    --muted: #6b7280;
    --border: #dde2e8;
    --accent: #f26a21;
    --accent-dark: #c94f11;
    --selected: #168f7a;
    --assigned: #d94b34;
    --focus: #2276d2;
    --shadow: 0 18px 45px rgba(31, 41, 51, 0.12);
}

* {
    box-sizing: border-box;
}

html,
body,
#app {
    min-height: 100%;
}

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

a {
    color: inherit;
}

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

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

.sidebar {
    background: #171b22;
    color: #fff;
    min-height: 100vh;
}

main {
    min-width: 0;
}

.top-row {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 28px;
    background: rgba(255, 255, 255, 0.88);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
}

.top-row strong {
    display: block;
    font-size: 15px;
}

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

.content {
    padding: 26px;
}

.page-heading {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.page-heading h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
}

.page-heading p {
    margin: 6px 0 0;
    color: var(--muted);
}

.brand-row {
    padding: 22px 18px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-row .container-fluid {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.navbar-brand {
    color: #fff;
    text-decoration: none;
    font-weight: 800;
    font-size: 22px;
}

.navbar-toggler {
    display: none;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 6px;
    background: transparent;
}

.navbar-toggler span,
.navbar-toggler span::before,
.navbar-toggler span::after {
    display: block;
    width: 16px;
    height: 2px;
    background: #fff;
    content: "";
    margin: auto;
}

.navbar-toggler span::before {
    transform: translateY(-6px);
}

.navbar-toggler span::after {
    transform: translateY(4px);
}

.nav-scrollable {
    padding: 16px 10px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-link {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 0;
    border-radius: 6px;
    padding: 11px 14px;
    background: transparent;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    font-weight: 650;
    text-align: left;
}

.nav-icon {
    position: relative;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
}

.map-icon {
    border: 2px solid currentColor;
    border-radius: 3px;
}

.map-icon::after {
    position: absolute;
    inset: 4px;
    border: 1px solid currentColor;
    content: "";
}

.list-icon,
.settings-icon,
.exit-icon {
    border-top: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
}

.list-icon::after,
.settings-icon::after {
    position: absolute;
    top: 6px;
    left: 0;
    right: 0;
    border-top: 2px solid currentColor;
    content: "";
}

.settings-icon {
    transform: rotate(45deg);
}

.exit-icon::after {
    position: absolute;
    top: 4px;
    right: 0;
    width: 8px;
    height: 8px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: rotate(45deg);
    content: "";
}

.nav-link.active,
.nav-link:hover {
    color: #fff;
    background: rgba(242, 106, 33, 0.24);
}

.logout-button {
    margin-top: 14px;
    cursor: pointer;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(120deg, rgba(242, 106, 33, 0.14), rgba(22, 143, 122, 0.12)),
        #f8fafc;
}

.login-panel {
    width: min(920px, 100%);
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.login-brand {
    padding: 54px;
    color: #fff;
    background:
        linear-gradient(rgba(18, 22, 28, 0.42), rgba(18, 22, 28, 0.72)),
        url('../assets/stationmall-zemin-kat.png') center / cover no-repeat;
}

.login-brand span {
    color: #ffd2b8;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
}

.login-brand h1 {
    margin: 18px 0 10px;
    font-size: 48px;
    line-height: 1;
    font-weight: 800;
}

.login-brand p {
    margin: 0;
    max-width: 360px;
    line-height: 1.6;
}

.login-form {
    padding: 54px;
    display: grid;
    align-content: center;
    gap: 18px;
}

label {
    display: grid;
    gap: 7px;
    color: #374151;
    font-weight: 650;
    font-size: 13px;
}

.form-control,
.form-select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 9px 11px;
    color: var(--text);
    background: #fff;
}

textarea.form-control {
    resize: vertical;
}

.code-field {
    font-family: Consolas, 'Courier New', monospace;
    font-size: 12px;
}

.primary-button,
.secondary-button,
.danger-button,
.row-actions button,
.selected-row button,
.detail-modal header button {
    min-height: 40px;
    border-radius: 6px;
    border: 1px solid transparent;
    padding: 9px 14px;
    font-weight: 750;
    cursor: pointer;
}

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

.primary-button:hover {
    background: var(--accent-dark);
}

.secondary-button {
    background: #fff;
    color: var(--text);
    border-color: var(--border);
}

.danger-button {
    background: #d8392b;
    color: #fff;
}

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

.alert {
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-success {
    background: #e8f7f2;
    border-color: #b9eadc;
    color: #116b5c;
}

.alert-danger {
    background: #fff0ee;
    border-color: #ffc8c1;
    color: #a83225;
}

.alert-info {
    background: #eef6ff;
    border-color: #c8e0ff;
    color: #1d5f9d;
}

.loading-card,
.management-panel,
.selection-panel,
.map-stage {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(31, 41, 51, 0.06);
}

.loading-card {
    padding: 22px;
}

.map-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 18px;
    align-items: start;
}

.map-stage {
    padding: 12px;
    min-width: 0;
    overflow: auto;
}

.map-image-frame {
    position: relative;
    min-width: 900px;
}

.map-image-frame img {
    display: block;
    width: 100%;
    height: auto;
}

.map-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.map-region rect,
.map-region polygon {
    cursor: pointer;
    stroke-width: 0.22;
    vector-effect: non-scaling-stroke;
    transition: fill 0.16s ease, stroke 0.16s ease, opacity 0.16s ease;
}

.map-region.available rect,
.map-region.available polygon {
    fill: rgba(34, 118, 210, 0.08);
    stroke: rgba(34, 118, 210, 0.42);
}

.map-region.available:hover rect,
.map-region.available:hover polygon {
    fill: rgba(242, 106, 33, 0.28);
    stroke: var(--accent);
}

.map-region.selected rect,
.map-region.selected polygon {
    fill: rgba(22, 143, 122, 0.42);
    stroke: var(--selected);
}

.map-region.assigned rect,
.map-region.assigned polygon {
    fill: rgba(217, 75, 52, 0.46);
    stroke: #a52d20;
}

.map-region text {
    font-size: 1.15px;
    font-weight: 800;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
    fill: #17202a;
    paint-order: stroke;
    stroke: rgba(255, 255, 255, 0.88);
    stroke-width: 0.3px;
}

.selection-panel,
.management-panel {
    padding: 18px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
}

.panel-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
}

.panel-header span,
.muted {
    color: var(--muted);
}

.selected-list {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.selected-row {
    display: grid;
    grid-template-columns: 1fr auto 32px;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border-radius: 6px;
    background: #eef9f6;
}

.selected-row button,
.detail-modal header button {
    min-height: 32px;
    padding: 4px 9px;
    background: #fff;
    border-color: var(--border);
}

.totals-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin: 16px 0;
}

.totals-grid div {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fafbfc;
}

.totals-grid dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.totals-grid dd {
    margin: 4px 0 0;
    font-size: 17px;
    font-weight: 800;
}

.totals-grid .grand-total {
    grid-column: 1 / -1;
    background: var(--surface-2);
    border-color: #ffd8bd;
}

.panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(17, 24, 39, 0.45);
}

.detail-modal {
    width: min(860px, 100%);
    max-height: calc(100vh - 40px);
    overflow: auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 22px;
}

.detail-modal header,
.detail-modal footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.detail-modal h2 {
    margin: 4px 0 0;
    font-size: 24px;
}

.detail-modal header span {
    color: var(--accent);
    font-weight: 800;
}

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

.detail-grid div {
    display: grid;
    gap: 4px;
    padding: 10px;
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: 6px;
}

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

.detail-section {
    margin: 18px 0;
}

.detail-section h3 {
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: 800;
}

.detail-table-wrap {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.detail-items-table {
    width: 100%;
    min-width: 650px;
    border-collapse: collapse;
    background: #fff;
}

.detail-items-table th,
.detail-items-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: right;
    white-space: nowrap;
}

.detail-items-table th:first-child,
.detail-items-table td:first-child {
    text-align: left;
}

.detail-items-table th {
    color: var(--muted);
    background: #fafbfc;
    font-size: 12px;
    font-weight: 800;
}

.detail-items-table tr:last-child td {
    border-bottom: 0;
}

.note-box {
    padding: 12px;
    border-radius: 6px;
    background: #fafbfc;
    border: 1px solid var(--border);
}

.settings-grid {
    display: grid;
    gap: 18px;
}

.map-point-editor {
    margin-top: 18px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fafbfc;
}

.map-point-editor .panel-header {
    align-items: flex-start;
}

.map-point-editor .panel-header p {
    margin: 4px 0 0;
}

.point-editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.map-picker-frame {
    overflow: auto;
    max-height: 620px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: crosshair;
}

.map-picker-canvas {
    position: relative;
    width: 100%;
    min-width: 980px;
}

.map-picker-canvas img {
    display: block;
    width: 100%;
    height: auto;
    user-select: none;
    pointer-events: none;
}

.map-picker-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.map-picker-hitbox {
    position: absolute;
    inset: 0;
    z-index: 2;
    cursor: crosshair;
    background: transparent;
}

.picker-polygon {
    fill: rgba(22, 143, 122, 0.32);
    stroke: #0f766e;
    stroke-width: 0.32;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

.picker-line {
    fill: none;
    stroke: #f26a21;
    stroke-width: 0.28;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

.picker-point {
    fill: #f26a21;
    stroke: #fff;
    stroke-width: 0.22;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}

.picker-point-label {
    font-size: 1.65px;
    font-weight: 800;
    fill: #111827;
    paint-order: stroke;
    stroke: #fff;
    stroke-width: 0.35px;
    pointer-events: none;
}

.point-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.point-list button {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    padding: 7px 9px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

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

.wide-field {
    grid-column: span 2;
}

.checkbox-label {
    align-content: end;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
}

.table-wrap {
    overflow: auto;
    margin-top: 16px;
}

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

.data-table th,
.data-table td {
    border-bottom: 1px solid var(--border);
    padding: 10px;
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    background: #fafbfc;
}

.row-actions {
    display: flex;
    gap: 8px;
}

.row-actions button {
    min-height: 34px;
    padding: 6px 10px;
    border-color: var(--border);
    background: #fff;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.status-pill.active {
    background: #e8f7f2;
    color: #116b5c;
}

.status-pill.cancelled {
    background: #fff0ee;
    color: #a83225;
}

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 16px 16px 16px;
    z-index: 1000;
    padding: 12px 16px;
    background: #fff0ee;
    border: 1px solid #ffc8c1;
    border-radius: 6px;
}

@media (max-width: 1100px) {
    .page {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
    }

    .navbar-toggler {
        display: grid;
        place-items: center;
    }

    .nav-scrollable.collapse {
        display: none;
    }

    .map-workspace {
        grid-template-columns: 1fr;
    }

    .selection-panel {
        order: -1;
    }
}

@media (max-width: 760px) {
    .content {
        padding: 16px;
    }

    .top-row {
        padding: 0 16px;
    }

    .page-heading,
    .panel-header {
        align-items: stretch;
        flex-direction: column;
    }

    .login-panel {
        grid-template-columns: 1fr;
    }

    .login-brand,
    .login-form {
        padding: 28px;
    }

    .login-brand h1 {
        font-size: 36px;
    }

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

    .wide-field,
    .totals-grid .grand-total {
        grid-column: auto;
    }
}
