:root {
    --navy: #103a67;
    --blue: #15558d;
    --blue-soft: #eaf2f9;
    --bg: #f3f6f9;
    --text: #1e2b38;
    --muted: #657483;
    --line: #dbe3ea;
    --success: #16794a;
    --warning: #9a6700;
    --danger: #b42318;
    --white: #ffffff;
    --radius: 16px;
    --shadow: 0 10px 28px rgba(31, 53, 73, .08);
}

* { box-sizing: border-box; }

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

a { color: inherit; text-decoration: none; }

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

.topbar {
    min-height: 68px;
    padding: 12px max(18px, calc((100vw - 1240px) / 2));
    background: var(--navy);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 8px 24px rgba(7, 29, 51, .14);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
}

.brand-mark, .brand-login {
    background: white;
    color: var(--navy);
    font-weight: 900;
    letter-spacing: .06em;
    border-radius: 10px;
    padding: 8px 10px;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.main-nav a {
    padding: 9px 12px;
    border-radius: 9px;
    color: rgba(255,255,255,.9);
    font-size: 14px;
    font-weight: 650;
}

.main-nav a:hover {
    background: rgba(255,255,255,.12);
    color: white;
}

.menu-button {
    display: none;
    color: white;
    background: transparent;
    border: 0;
    font-size: 24px;
}

.container {
    width: min(1240px, calc(100% - 28px));
    margin: 0 auto;
    padding: 34px 0 64px;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
}

.page-head h1 {
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.05;
    margin: 6px 0 8px;
}

.page-head p, .panel-head p {
    color: var(--muted);
    margin: 0;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--blue);
    font-size: 12px;
    font-weight: 850;
}

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

.stat-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card span {
    color: var(--muted);
    font-size: 14px;
    display: block;
}

.stat-card strong {
    display: block;
    font-size: 32px;
    margin-top: 8px;
    color: var(--navy);
}

.stat-warning strong { color: var(--warning); }

.panel {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
}

.panel-head, .panel-subhead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.panel-head h2, .panel-subhead h2 {
    margin: 0 0 4px;
    font-size: 20px;
}

.button {
    appearance: none;
    border: 1px solid #c9d4de;
    background: white;
    color: var(--navy);
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 750;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.button:hover { border-color: var(--blue); }

.button-primary {
    background: var(--blue);
    color: white;
    border-color: var(--blue);
}

.button-small {
    padding: 7px 10px;
    font-size: 13px;
}

.button-block { width: 100%; }

.search-input {
    width: min(320px, 100%);
}

input, select, textarea {
    width: 100%;
    border: 1px solid #c9d4de;
    border-radius: 10px;
    padding: 11px 12px;
    background: white;
    color: var(--text);
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(21,85,141,.12);
}

label {
    display: grid;
    gap: 7px;
    color: #394a58;
    font-size: 14px;
    font-weight: 700;
}

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

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

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

th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    background: #f8fafc;
}

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

tbody tr:hover { background: #fafcff; }

.actions-cell {
    text-align: right;
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    background: var(--blue-soft);
    color: var(--blue);
    font-size: 12px;
    font-weight: 800;
}

.badge-success {
    background: #e6f5ed;
    color: var(--success);
}

.badge-warning {
    background: #fff4d6;
    color: var(--warning);
}

.badge-muted {
    background: #edf0f2;
    color: #66727c;
}

.form-panel { padding: 26px; }

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

.full-width { grid-column: 1 / -1; }

.form-actions, .filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 30px;
}

.checkbox-row input, .switch-line input {
    width: auto;
}

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

.size-card {
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 16px;
    display: grid;
    gap: 12px;
}

.size-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.switch-line {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
}

.delivery-items {
    display: grid;
    gap: 12px;
}

.delivery-item-row {
    display: grid;
    grid-template-columns: 1.35fr .8fr .55fr .85fr 1.2fr 36px;
    gap: 10px;
    align-items: end;
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 14px;
    background: #fbfcfd;
}

.remove-row {
    border: 0;
    background: #fbe9e7;
    color: var(--danger);
    height: 42px;
    border-radius: 10px;
    font-size: 24px;
    cursor: pointer;
}

.delivery-list {
    display: grid;
    gap: 14px;
}

.delivery-card {
    border: 1px solid var(--line);
    border-radius: 13px;
    padding: 18px;
}

.delivery-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.delivery-card-head strong {
    display: block;
    font-size: 17px;
}

.delivery-card-head span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-top: 3px;
}

.delivery-card ul {
    margin: 14px 0 0;
    padding-left: 20px;
}

.note {
    color: var(--muted);
    margin: 12px 0 0;
    font-size: 14px;
}

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 28px;
    border: 1px dashed #c9d4de;
    border-radius: 12px;
}

.alert {
    border-radius: 11px;
    padding: 13px 15px;
    margin-bottom: 18px;
    font-weight: 650;
}

.alert-success {
    background: #e6f5ed;
    color: var(--success);
}

.alert-danger {
    background: #fdecea;
    color: var(--danger);
}

.alert-warning {
    background: #fff4d6;
    color: var(--warning);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(circle at top right, rgba(21,85,141,.22), transparent 30%),
        linear-gradient(145deg, #0d3157, #123f6c);
}

.login-card {
    width: min(430px, 100%);
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 24px 70px rgba(0,0,0,.25);
}

.login-card h1 { margin: 20px 0 6px; }
.login-card p { color: var(--muted); margin: 0 0 24px; }
.brand-login { display: inline-block; background: var(--navy); color: white; }

.form-stack {
    display: grid;
    gap: 16px;
}

.filter-grid {
    grid-template-columns: 1.2fr .7fr .7fr auto;
    align-items: end;
}

.filter-actions { margin: 0; }

@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .delivery-item-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .remove-row { grid-column: 2; justify-self: end; width: 42px; }
    .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .topbar { align-items: center; }
    .menu-button { display: block; }
    .main-nav {
        display: none;
        position: absolute;
        top: 64px;
        left: 14px;
        right: 14px;
        background: var(--navy);
        border-radius: 12px;
        padding: 10px;
        box-shadow: var(--shadow);
        flex-direction: column;
        align-items: stretch;
    }
    .main-nav.is-open { display: flex; }

    .container { width: min(100% - 20px, 1240px); padding-top: 24px; }
    .page-head { align-items: stretch; flex-direction: column; }
    .page-head .button { width: 100%; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 16px; }
    .stat-card strong { font-size: 26px; }

    .panel { padding: 15px; }
    .panel-head { align-items: stretch; flex-direction: column; }
    .search-input { width: 100%; }

    .form-grid, .filter-grid, .size-grid { grid-template-columns: 1fr; }
    .full-width { grid-column: auto; }
    .filter-actions { width: 100%; }
    .filter-actions .button { flex: 1; }
    .delivery-item-row { grid-template-columns: 1fr; }
    .remove-row { grid-column: auto; width: 100%; }

    .table-wrap { border: 0; overflow: visible; }
    table, thead, tbody, th, td, tr { display: block; min-width: 0; }
    thead { display: none; }
    tbody { display: grid; gap: 12px; }
    tbody tr {
        border: 1px solid var(--line);
        border-radius: 12px;
        padding: 12px;
        background: white;
    }
    td {
        display: flex;
        justify-content: space-between;
        gap: 16px;
        border-bottom: 1px solid var(--line);
        padding: 10px 4px;
        text-align: right;
    }
    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        text-transform: uppercase;
        font-weight: 800;
        text-align: left;
    }
    td:last-child { border-bottom: 0; }
    .actions-cell { justify-content: flex-end; }
    .actions-cell::before { display: none; }
}

/* Catastro simple */
.stats-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-card strong small { font-size: 15px; color: var(--muted); margin-left: 4px; }
.badge-danger { background: #fdecea; color: var(--danger); }
.compact-head { align-items: center; }
.simple-notice {
    background: var(--blue-soft);
    color: var(--navy);
    border-radius: 11px;
    padding: 13px 15px;
    margin-bottom: 18px;
    font-size: 14px;
    line-height: 1.45;
}
.uniform-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
}
.uniform-form-table { min-width: 900px; }
.uniform-form-table td { padding: 11px; }
.uniform-form-table input,
.uniform-form-table select { min-width: 130px; }
.uniform-form-table tr[data-status="yes"] { background: #f4fbf7; }
.uniform-form-table tr[data-status="no"] { background: #fff8f7; }
.uniform-form-table tr[data-status="pending"] { background: #fffdf7; }
.uniform-form-table input:disabled { background: #eef1f4; color: #8a949d; }
.sticky-actions {
    position: sticky;
    bottom: 0;
    background: rgba(255,255,255,.96);
    border-top: 1px solid var(--line);
    padding: 14px 0 0;
    z-index: 5;
}

@media (max-width: 720px) {
    .stats-grid-3 { grid-template-columns: 1fr; }
    .uniform-table-wrap { border: 0; overflow: visible; }
    .uniform-form-table { min-width: 0; }
    .uniform-form-table thead { display: none; }
    .uniform-form-table,
    .uniform-form-table tbody,
    .uniform-form-table tr,
    .uniform-form-table td { display: block; width: 100%; }
    .uniform-form-table tr {
        border: 1px solid var(--line);
        border-radius: 13px;
        margin-bottom: 12px;
        padding: 13px;
    }
    .uniform-form-table td {
        border: 0;
        padding: 7px 0;
    }
    .uniform-form-table td::before {
        content: attr(data-label);
        display: block;
        font-size: 11px;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: .05em;
        color: var(--muted);
        margin-bottom: 5px;
    }
    .uniform-form-table td:first-child::before { display: none; }
    .uniform-form-table td:first-child { font-size: 18px; padding-bottom: 10px; }
    .uniform-form-table input,
    .uniform-form-table select { min-width: 0; }
    .sticky-actions .button { flex: 1; }
}

.session-label {
    color: rgba(255,255,255,.72);
    font-size: 12px;
    padding: 0 6px;
}

.login-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(21,85,141,.18), transparent 34%),
        linear-gradient(160deg, #eef4f9 0%, #f7f9fb 55%, #e9f0f6 100%);
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-shell {
    width: min(480px, 100%);
}

.login-card {
    background: white;
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 30px;
    box-shadow: 0 24px 60px rgba(16,58,103,.14);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.login-brand h1 {
    margin: 0 0 4px;
    font-size: 24px;
}

.login-brand p,
.login-help,
.config-warning p {
    margin: 0;
    color: var(--muted);
}

.login-form {
    display: grid;
    gap: 18px;
}

.otp-input {
    text-align: center;
    font-size: 28px;
    font-weight: 850;
    letter-spacing: .24em;
    padding-left: calc(12px + .24em);
}

.code-sent-summary {
    background: var(--blue-soft);
    border: 1px solid #cedfec;
    border-radius: 12px;
    padding: 14px;
    display: grid;
    gap: 4px;
}

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

.config-warning {
    border: 1px solid #f1d184;
    background: #fff9e9;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 18px;
}

.config-warning code {
    background: rgba(154,103,0,.1);
    padding: 2px 5px;
    border-radius: 5px;
}

.secondary-login-action {
    text-align: center;
    margin-top: 14px;
}

.text-button {
    border: 0;
    background: transparent;
    color: var(--blue);
    cursor: pointer;
    font-weight: 750;
    padding: 8px;
}

.login-help {
    text-align: center;
    font-size: 12px;
    margin-top: 22px;
}

.alert-danger {
    color: var(--danger);
    background: #fff0ee;
    border: 1px solid #f3c5bf;
}

.alert-success {
    color: var(--success);
    background: #eaf7f0;
    border: 1px solid #bde1cd;
}

.alert {
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 18px;
    font-weight: 650;
}

@media (max-width: 760px) {
    .session-label { display: none; }
    .login-card { padding: 22px; }
}
