:root {
    --ink: #17202a;
    --muted: #607080;
    --line: #d8dee6;
    --surface: #ffffff;
    --band: #f4f7fa;
    --brand: #17263a;
    --accent: #1f7a68;
    --warning: #bd7b00;
    --danger: #b84a4a;
    --info: #3269a8;
    --archived: #6d7480;
}

* {
    box-sizing: border-box;
}

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

a {
    color: inherit;
}

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

.app-shell {
    min-height: 100vh;
    padding-bottom: 76px;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: env(safe-area-inset-top) 14px 10px;
}

.header-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    min-height: 36px;
}

.header-row.sub {
    grid-template-columns: 1fr auto;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.85rem;
}

.brand-name {
    font-weight: 800;
    text-decoration: none;
    color: var(--brand);
}

.brand-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.net-pill,
.badge {
    justify-self: end;
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.net-pill.online,
.badge.ok {
    color: #0d4f42;
    background: #dff3ef;
}

.net-pill.offline,
.badge.error {
    color: #7a2424;
    background: #f5dede;
}

.install-btn,
.btn {
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--ink);
    min-height: 38px;
    padding: 8px 12px;
    font-weight: 700;
    cursor: pointer;
}

.btn.primary,
.install-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn.warning {
    background: #fff5df;
    border-color: #e7c56e;
    color: #6d4800;
}

.btn.danger {
    background: #fae8e8;
    border-color: #e5b5b5;
    color: #7a2424;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.app-main {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 18px 14px 26px;
}

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
}

.bottom-nav a {
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
    border-radius: 7px;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
}

.bottom-nav a.active {
    color: #fff;
    background: var(--brand);
}

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

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

h1 {
    font-size: 1.45rem;
}

h2 {
    font-size: 1.12rem;
}

.section,
.toolbar {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 14px;
}

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

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

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 12px;
}

.stat .value {
    font-size: 1.65rem;
    font-weight: 800;
}

.stat .label {
    color: var(--muted);
    font-size: 0.82rem;
}

.form-grid {
    display: grid;
    gap: 12px;
}

.field label {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 700;
}

.input,
.select,
.textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 9px 10px;
    background: #fff;
    color: var(--ink);
}

.textarea {
    min-height: 92px;
    resize: vertical;
}

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

.message {
    border-radius: 7px;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: #eef4fb;
    color: #254b78;
}

.message.error {
    background: #fae8e8;
    color: #7a2424;
}

.message.ok {
    background: #e2f3ec;
    color: #0d4f42;
}

.responsive-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.responsive-table th,
.responsive-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    font-size: 0.88rem;
}

.responsive-table th {
    background: #edf1f5;
    color: #44515e;
    font-size: 0.78rem;
    text-transform: uppercase;
}

.badge.potential {
    background: #dff3ef;
    color: #0d4f42;
}

.badge.pending {
    background: #fff2c8;
    color: #775000;
}

.badge.process {
    background: #dfeafb;
    color: #254b78;
}

.badge.archived {
    background: #e6e8eb;
    color: #555b64;
}

.card-list {
    display: grid;
    gap: 10px;
}

.opp-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.opp-card .meta {
    color: var(--muted);
    font-size: 0.84rem;
}

.detail-grid {
    display: grid;
    gap: 10px;
}

.detail-item {
    border-bottom: 1px solid var(--line);
    padding-bottom: 8px;
}

.detail-item span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
}

.page-state {
    color: var(--muted);
    padding: 20px;
}

#blazor-error-ui {
    background: #fff2c8;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
}

.boot-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 18px;
    background: #fff;
}

.boot-screen img {
    width: 118px;
    height: 118px;
    object-fit: contain;
}

.boot-spinner {
    width: 42px;
    height: 42px;
    border: 4px solid #d8dee6;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 760px) {
    .desktop-only {
        display: none;
    }

    .responsive-table {
        display: none;
    }
}

@media (min-width: 761px) {
    .mobile-only {
        display: none;
    }

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

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

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

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