/* ============================================================
   Gestión de Obras — Minimalistic Design System
   ============================================================ */

/* -----  Reset & Base  ---------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0;
    font-family: Inter, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

img, svg { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* -----  Design Tokens  --------------------------------------- */
:root {
    /* Neutrals (zinc) */
    --bg:              #f5f7fa;
    --surface:         #ffffff;
    --surface-muted:   #eef2f6;
    --surface-hover:   #f8fafc;
    --border:          #e5e7eb;
    --border-strong:   #d1d5db;
    --text:            #111827;
    --text-muted:      #6b7280;
    --text-subtle:     #94a3b8;

    /* Accent — refined indigo */
    --accent:          #0070f8;
    --accent-hover:    #005fd4;
    --accent-soft:     #e8f1ff;
    --accent-text:     #ffffff;

    /* Status palette (soft, tinted) */
    --success:         #0f8a5f;
    --success-soft:    #edf9f4;
    --success-border:  #b9e7d4;

    --warning:         #b7791f;
    --warning-soft:    #fff7e6;
    --warning-border:  #f4d08f;

    --danger:          #c24141;
    --danger-soft:     #fdf1f1;
    --danger-border:   #f4c4c4;

    --info:            #0070f8;
    --info-soft:       #eef6ff;
    --info-border:     #bfdcff;

    --neutral-soft:    #f3f4f6;
    --neutral-border:  #e5e7eb;

    /* Geometry */
    --radius:     12px;
    --radius-sm:  10px;
    --radius-lg:  16px;

    /* Shadows — used very sparingly */
    --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md:  0 10px 30px rgba(15, 23, 42, 0.08);

    /* Sizing */
    --container:  1360px;
    --sidebar-width: 264px;
    --mobilebar-height: 68px;
}

/* -----  Layout  ---------------------------------------------- */
.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 28px;
}

@media (max-width: 640px) {
    .container { padding: 0 16px; }
}

/* -----  Top Navigation  -------------------------------------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: var(--nav-height);
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    width: 100%;
}

.brand {
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.01em;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.brand__mark {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    background: var(--text);
    color: var(--surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0;
    flex-shrink: 0;
}

.brand__mark-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

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

.topbar__user {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.topbar__user-name {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
}

.nav__link {
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 500;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background-color 0.15s;
}

.nav__link:hover {
    color: var(--text);
    background: var(--surface-muted);
}

.nav__link.is-active {
    color: var(--text);
    background: var(--surface-muted);
}

@media (max-width: 720px) {
    .topbar { height: auto; padding: 12px 0; }
    .topbar__inner { flex-direction: column; gap: 12px; align-items: stretch; }
    .nav { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .nav__link { white-space: nowrap; }
    .topbar__user {
        width: 100%;
        justify-content: space-between;
        margin-left: 0;
    }
}

/* -----  Main / Page Header  ---------------------------------- */
.main {
    padding: 32px 0 56px;
}

.auth-shell {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

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

.auth-card__eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

.auth-card__title {
    font-size: 28px;
}

.auth-card__subtitle {
    margin-top: 0;
}

.auth-card__form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-card__actions {
    margin-top: 4px;
    padding-top: 0;
    border-top: 0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.page-header__title {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--text);
}

.page-header__subtitle {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 13.5px;
}

.page-header__actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.crumb {
    color: var(--text-muted);
    font-size: 12.5px;
    margin-bottom: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.crumb a {
    color: var(--text-muted);
    transition: color 0.15s;
}

.crumb a:hover { color: var(--text); }
.crumb__sep { color: var(--text-subtle); }

/* -----  Section  --------------------------------------------- */
.section {
    margin-top: 36px;
}

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

.section__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.005em;
}

.section__hint {
    font-size: 13px;
    color: var(--text-muted);
}

/* -----  Cards  ----------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card--padded {
    padding: 20px;
}

.card__header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.card__body {
    padding: 20px;
}

.card__footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-muted);
    display: flex;
    gap: 8px;
    align-items: center;
}

/* -----  Stat Cards  ------------------------------------------ */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    transition: border-color 0.15s, transform 0.15s;
}

.stat__value {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--text);
    line-height: 1.1;
}

.stat__label {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 6px;
    font-weight: 500;
}

.stat--warning .stat__value { color: var(--warning); }
.stat--danger  .stat__value { color: var(--danger); }
.stat--success .stat__value { color: var(--success); }
.stat--info    .stat__value { color: var(--info); }

/* -----  Buttons  --------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13.5px;
    font-weight: 500;
    line-height: 1;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn--primary {
    background: var(--text);
    color: var(--surface);
    border-color: var(--text);
}
.btn--primary:hover { background: #27272a; border-color: #27272a; }

.btn--accent {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
}
.btn--accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn--secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border-strong);
}
.btn--secondary:hover { background: var(--surface-muted); }

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn--ghost:hover { background: var(--surface-muted); color: var(--text); }

.btn--danger {
    background: var(--surface);
    color: var(--danger);
    border-color: var(--border-strong);
}
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger-border); }

.btn--sm {
    padding: 6px 10px;
    font-size: 12.5px;
}

.btn--lg {
    padding: 10px 18px;
    font-size: 14px;
}

.btn--block { width: 100%; }

.btn[disabled],
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* -----  Form Fields  ----------------------------------------- */
.form {
    display: block;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
}

.field__label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-muted);
}

.field__hint {
    font-size: 12px;
    color: var(--text-subtle);
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 8px 12px;
    font-size: 13.5px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
    line-height: 1.4;
    appearance: none;
}

.input:hover,
.select:hover,
.textarea:hover { border-color: #a1a1aa; }

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.input::placeholder,
.textarea::placeholder { color: var(--text-subtle); }

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

.select {
    padding-right: 32px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
}

.input--readonly,
.input[readonly] {
    background: var(--surface-muted);
    color: var(--text-muted);
}

.input[type="file"] {
    padding: 6px;
    background: var(--surface-muted);
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
}

.field-grid > .field { grid-column: span 12; }

@media (min-width: 720px) {
    .field-grid > .col-3  { grid-column: span 3;  }
    .field-grid > .col-4  { grid-column: span 4;  }
    .field-grid > .col-6  { grid-column: span 6;  }
    .field-grid > .col-8  { grid-column: span 8;  }
    .field-grid > .col-9  { grid-column: span 9;  }
    .field-grid > .col-12 { grid-column: span 12; }
}

.form__actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* -----  Filter Bar  ------------------------------------------ */
.toolbar {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 8px;
    margin-bottom: 18px;
    align-items: center;
}

.toolbar .input,
.toolbar .select {
    background: var(--surface);
}

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

/* -----  Tables  ---------------------------------------------- */
.table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
}

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

.table thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: var(--surface-muted);
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-hover); }

.table .num   { text-align: right; font-variant-numeric: tabular-nums; }
.table .center { text-align: center; }
.table .right { text-align: right; }
.table strong { font-weight: 600; }

.table__actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

/* -----  List Items (Cards)  ---------------------------------- */
.list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}

.item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.15s, transform 0.15s;
}

.item:hover { border-color: var(--border-strong); }

.item__top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.item__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 0;
    letter-spacing: -0.005em;
}

.item__meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12.5px;
    color: var(--text-muted);
}

.item__meta-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.item__actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

/* -----  Status Pills (Badges)  ------------------------------- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    font-size: 11.5px;
    font-weight: 500;
    border-radius: 999px;
    background: var(--neutral-soft);
    color: var(--text-muted);
    border: 1px solid var(--border);
    line-height: 1.4;
    white-space: nowrap;
}

.pill::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.6;
}

.pill--success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.pill--warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.pill--danger  { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger-border); }
.pill--info    { background: var(--info-soft);    color: var(--info);    border-color: var(--info-border); }
.pill--neutral { background: var(--neutral-soft); color: var(--text-muted); border-color: var(--border); }
.pill--muted   { background: transparent; color: var(--text-subtle); border-color: var(--border); }
.pill--muted::before { display: none; }

.pill--lg {
    font-size: 12.5px;
    padding: 4px 12px;
}

/* Status chip — compact, used in inline grids */
.chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 3px 7px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--border);
    background: var(--neutral-soft);
    color: var(--text-muted);
    min-width: 28px;
}

.chip--success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.chip--warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.chip--danger  { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger-border); }
.chip--info    { background: var(--info-soft);    color: var(--info);    border-color: var(--info-border); }
.chip--muted   { background: var(--neutral-soft); color: var(--text-subtle); border-color: var(--border); }

/* -----  Definition List (info grids)  ------------------------ */
.kv {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px 24px;
}

.kv__item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.kv__label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.kv__value {
    font-size: 14px;
    color: var(--text);
    word-break: break-word;
}

.kv__value--muted { color: var(--text-subtle); }

/* -----  Status Group (Vientos/Línea/Cuadro/Motivos)  --------- */
.status-group {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
}

.status-group__label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-subtle);
    font-weight: 600;
}

.status-row {
    display: inline-flex;
    gap: 4px;
}

/* -----  Pending Overview  ------------------------------------ */
.pending-groups {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.pending-group {
    min-width: 0;
}

.pending-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pending-row {
    display: grid;
    grid-template-columns: minmax(150px, 0.8fr) minmax(0, 3.2fr);
    gap: 12px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
}

.pending-row:hover {
    border-color: var(--border-strong);
    text-decoration: none;
}

.pending-row__title {
    color: var(--text);
    font-size: 13px;
    line-height: 1.25;
    min-width: 0;
}

.pending-row__states {
    display: grid;
    grid-template-columns: repeat(4, minmax(118px, 1fr));
    gap: 8px;
    min-width: 0;
}

.pending-state {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    padding: 6px 8px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
}

.pending-state__label {
    color: var(--text-subtle);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.1;
}

.pending-state .pill {
    max-width: 100%;
}

@media (max-width: 760px) {
    .pending-row {
        grid-template-columns: 1fr;
    }

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

/* -----  Empty State  ----------------------------------------- */
.empty {
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 40px 24px;
    text-align: center;
    color: var(--text-muted);
}

.empty__text {
    margin: 0 0 14px;
    font-size: 13.5px;
}

/* -----  Alert  ----------------------------------------------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    border: 1px solid var(--warning-border);
    background: var(--warning-soft);
    color: var(--warning);
    margin-bottom: 16px;
}

/* -----  Documents list  -------------------------------------- */
.docs {
    display: flex;
    flex-direction: column;
}

.doc {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}

.doc:last-child { border-bottom: none; }
.doc:hover { background: var(--surface-hover); }

.doc__name {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    min-width: 0;
}

.doc__name span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc__actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
}

.doc__icon {
    width: 16px;
    height: 16px;
    color: var(--text-subtle);
    flex-shrink: 0;
}

.reference-photo-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.reference-photo-preview {
    width: 100%;
    max-width: 260px;
    min-height: 160px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reference-photo-preview--empty {
    color: var(--text-subtle);
    font-size: 13px;
}

.reference-photo-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.reference-photo-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.reference-photo-remove {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 13px;
}

.reference-thumb {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    border: 1px solid var(--border);
    background: var(--surface-muted);
}

.reference-thumb--placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-subtle);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 6px;
}

/* -----  Collapsible inline form  ----------------------------- */
.inline-form {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
}

.is-hidden { display: none; }

/* -----  Misc utilities  -------------------------------------- */
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.mono { font-variant-numeric: tabular-nums; }
.row-gap { display: flex; flex-direction: column; gap: 16px; }
.flex { display: flex; }
.flex--gap { display: flex; gap: 8px; }
.flex--between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.flex--wrap { flex-wrap: wrap; }
.flex--center { display: flex; align-items: center; }
.text-right { text-align: right; }
.full-width { width: 100%; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.hr {
    height: 1px;
    background: var(--border);
    border: 0;
    margin: 24px 0;
}

/* -----  Icons (inline SVG)  ---------------------------------- */
.icon {
    width: 14px;
    height: 14px;
    stroke-width: 2;
    stroke: currentColor;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: -2px;
}

.icon--sm { width: 12px; height: 12px; }
.icon--lg { width: 18px; height: 18px; }

.estado-obra-control {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 124px;
    padding: 3px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--neutral-soft);
    color: var(--text-muted);
    line-height: 1.4;
    transition: opacity 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.estado-obra-control.pill--success {
    background: var(--success-soft);
    color: var(--success);
    border-color: var(--success-border);
}

.estado-obra-control.pill--warning {
    background: var(--warning-soft);
    color: var(--warning);
    border-color: var(--warning-border);
}

.estado-obra-control.pill--info {
    background: var(--info-soft);
    color: var(--info);
    border-color: var(--info-border);
}

.estado-obra-control.pill--neutral {
    background: var(--neutral-soft);
    color: var(--text-muted);
    border-color: var(--border);
}

.estado-obra-control.pill--danger {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: var(--danger-border);
}

.estado-obra-control--lg {
    min-width: 136px;
    padding: 4px 10px;
}

.estado-obra-control__dot {
    flex: 0 0 auto;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.6;
}

.estado-obra-select {
    width: 100%;
    min-width: 0;
    padding: 0 18px 0 0;
    border: 0;
    outline: 0;
    color: inherit;
    background-color: transparent;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 2px center;
    background-size: 10px;
    appearance: none;
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.4;
    cursor: pointer;
}

.estado-obra-control--lg .estado-obra-select {
    font-size: 12.5px;
}

.estado-obra-select:disabled {
    cursor: wait;
}

.estado-obra-control:focus-within {
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.estado-obra-control.is-saving {
    opacity: 0.65;
}

.estado-chip-control {
    position: relative;
    cursor: pointer;
}

.estado-chip-control::after {
    content: '';
    width: 8px;
    height: 8px;
    margin-left: 1px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 8px;
    opacity: 0.75;
}

.estado-chip-label {
    pointer-events: none;
}

.estado-chip-select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    opacity: 0;
    cursor: pointer;
}

.estado-chip-select:disabled {
    cursor: wait;
}

.estado-chip-control:focus-within {
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.estado-chip-control.is-saving {
    opacity: 0.65;
}

.page-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.list--locations {
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

.item--location {
    gap: 12px;
}

.status-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: -4px 0 14px;
    color: var(--text-muted);
    font-size: 12px;
}

.status-legend span {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.status-legend strong {
    color: var(--text);
    font-weight: 600;
}

.estado-chip-full {
    display: none;
}

.toast-stack {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    min-width: 140px;
    padding: 9px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-md);
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.18s, transform 0.18s;
}

.toast--success {
    background: var(--success-soft);
    color: var(--success);
    border-color: var(--success-border);
}

.toast--error {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: var(--danger-border);
}

.toast.is-hiding {
    opacity: 0;
    transform: translateY(4px);
}

.table-sort {
    color: var(--text-muted);
    font-weight: 600;
}

.table-sort:hover {
    color: var(--text);
}

.quick-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: -6px 0 18px;
}

.quick-filter {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 500;
}

.quick-filter:hover,
.quick-filter.is-active {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--surface-muted);
}

/* -----  Ilusquer Rework  ------------------------------------ */
.body--app {
    background:
        radial-gradient(circle at top left, rgba(0, 112, 248, 0.08), transparent 28%),
        var(--bg);
}

.app--shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 28px 20px 20px;
    background: linear-gradient(180deg, #0f172a 0%, #17233a 100%);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar__brand {
    padding: 0 8px;
}

.brand--sidebar {
    align-items: flex-start;
    gap: 12px;
    color: #ffffff;
}

.brand--sidebar .brand__mark,
.brand--mobile .brand__mark {
    background: var(--accent);
    color: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.brand__copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand__copy strong {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0;
}

.brand__copy span {
    font-size: 12px;
    color: rgba(226, 232, 240, 0.72);
}

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

.sidebar__link {
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 0 14px;
    border-radius: 14px;
    color: rgba(226, 232, 240, 0.86);
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.18s, color 0.18s, transform 0.18s;
}

.sidebar__link:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #ffffff;
}

.sidebar__link.is-active {
    background: linear-gradient(180deg, rgba(0, 112, 248, 0.24), rgba(0, 112, 248, 0.14));
    color: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(107, 183, 255, 0.2);
}

.sidebar__footer {
    margin-top: auto;
    padding: 18px 14px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.sidebar__user {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar__user-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(226, 232, 240, 0.64);
}

.sidebar__user-name {
    font-size: 14px;
    color: #ffffff;
}

.sidebar__footer .btn--secondary {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
    color: rgba(226, 232, 240, 0.84);
}

.sidebar__footer .btn--secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.sidebar__logout {
    margin-top: 2px;
}

.sidebar__logout-button {
    min-height: 38px;
    font-size: 13px;
    font-weight: 500;
}

.app__content {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-backdrop {
    display: none;
}

.sidebar-open {
    overflow: hidden;
}

.container--content {
    max-width: 1180px;
    margin: 0;
}

.mobilebar {
    display: none;
}

.main--shell {
    padding: 36px 0 48px;
}

.page-header {
    margin-bottom: 32px;
}

.page-header__title {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.page-header__subtitle {
    margin-top: 8px;
    max-width: 720px;
    font-size: 15px;
}

.section {
    margin-top: 32px;
}

.section__header {
    margin-bottom: 16px;
}

.section__title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.card,
.item,
.stat,
.table-wrap,
.toolbar,
.inline-form,
.empty {
    box-shadow: var(--shadow-sm);
}

.card,
.item,
.table-wrap,
.toolbar,
.inline-form {
    border-color: rgba(148, 163, 184, 0.16);
}

.card,
.table-wrap,
.toolbar,
.inline-form,
.empty,
.stat,
.item {
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(10px);
}

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

.stat {
    position: relative;
    padding: 22px 22px 20px;
    overflow: hidden;
}

.stat::after {
    content: '';
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, rgba(0, 112, 248, 0.9), rgba(0, 112, 248, 0.22));
}

.stat--warning::after {
    background: linear-gradient(90deg, rgba(183, 121, 31, 0.92), rgba(183, 121, 31, 0.24));
}

.stat--success::after {
    background: linear-gradient(90deg, rgba(15, 138, 95, 0.92), rgba(15, 138, 95, 0.24));
}

.stat--danger::after {
    background: linear-gradient(90deg, rgba(194, 65, 65, 0.92), rgba(194, 65, 65, 0.24));
}

.stat__value {
    font-size: 34px;
}

.stat__label {
    font-size: 13px;
    letter-spacing: 0.01em;
}

.btn {
    min-height: 42px;
    padding: 10px 16px;
    border-radius: 12px;
    font-weight: 600;
}

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

.btn--primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn--secondary {
    background: #ffffff;
    border-color: var(--border);
}

.btn--secondary:hover {
    background: #f8fbff;
    border-color: rgba(0, 112, 248, 0.22);
    color: var(--accent);
}

.btn--ghost:hover {
    background: rgba(0, 112, 248, 0.08);
    color: var(--accent);
}

.btn--sm {
    min-height: 36px;
    padding: 8px 12px;
    border-radius: 10px;
}

.field__label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input,
.select,
.textarea {
    min-height: 46px;
    border-radius: 12px;
    border-color: rgba(148, 163, 184, 0.34);
    background: #ffffff;
}

.toolbar {
    grid-template-columns: minmax(0, 1.6fr) minmax(150px, 0.7fr) minmax(150px, 0.7fr) auto;
    padding: 16px;
    border-radius: 16px;
    margin-bottom: 22px;
}

.quick-filters {
    margin: -2px 0 20px;
}

.quick-filter {
    min-height: 34px;
    border-radius: 999px;
    padding: 6px 12px;
}

.quick-filter.is-active {
    background: rgba(0, 112, 248, 0.1);
    color: var(--accent);
    border-color: rgba(0, 112, 248, 0.22);
}

.list {
    gap: 16px;
}

.item {
    padding: 20px;
    border-radius: 18px;
    gap: 12px;
}

.item__title {
    font-size: 16px;
}

.table thead th {
    padding: 14px 16px;
    background: #f8fafc;
}

.table tbody td {
    padding: 14px 16px;
}

.reference-thumb,
.reference-thumb--placeholder {
    width: 56px;
    height: 56px;
    border-radius: 14px;
}

.reference-thumb--placeholder {
    background: #edf2f7;
    color: #64748b;
    border-style: dashed;
}

.pill {
    min-height: 28px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
}

.empty {
    position: relative;
    overflow: hidden;
    border-style: solid;
    padding: 38px 24px 32px;
}

.empty::before {
    content: '';
    display: block;
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
    border-radius: 16px;
    border: 1px solid rgba(0, 112, 248, 0.12);
    background:
        url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 8h8'/%3E%3Cpath d='M8 12h6'/%3E%3Cpath d='M8 16h5'/%3E%3Crect x='4.5' y='4.5' width='15' height='15' rx='3'/%3E%3C/svg%3E") center/22px 22px no-repeat,
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.96));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.empty > * {
    position: relative;
    z-index: 1;
}

.empty__text {
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
}

.pending-group,
.pending-row,
.pending-state {
    border-radius: 16px;
}

.pending-row {
    background: #f8fafc;
}

.pending-state {
    background: #ffffff;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.body--auth {
    background:
        radial-gradient(circle at top left, rgba(0, 112, 248, 0.12), transparent 26%),
        linear-gradient(180deg, #f7faff 0%, #f5f7fa 100%);
}

.container--auth {
    max-width: 1120px;
}

.app__content--auth {
    min-height: 100vh;
    display: flex;
}

.main--auth {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 40px 0;
}

.login-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(360px, 420px);
    gap: 28px;
    align-items: stretch;
}

.login-hero {
    background: linear-gradient(145deg, #0f172a 0%, #102345 55%, #0070f8 160%);
    color: #ffffff;
    border-radius: 28px;
    padding: 40px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.login-hero::after {
    content: '';
    position: absolute;
    inset: auto -80px -80px auto;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.14), transparent 68%);
}

.login-hero__brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 44px;
}

.login-hero__brand .brand__mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: #ffffff;
    color: var(--accent);
    font-size: 18px;
}

.login-hero__kicker {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
}

.login-hero__title {
    margin: 12px 0 14px;
    font-size: 42px;
    line-height: 1.02;
    letter-spacing: -0.04em;
}

.login-hero__text {
    max-width: 460px;
    margin: 0 0 28px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 15px;
}

.login-hero__list {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.login-hero__list li {
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.84);
}

.auth-card {
    max-width: none;
    padding: 34px;
    border-radius: 24px;
    box-shadow: var(--shadow-md);
    border-color: rgba(148, 163, 184, 0.2);
}

.auth-card__eyebrow {
    color: var(--accent);
}

.auth-card__title {
    font-size: 34px;
    line-height: 1.02;
}

.auth-card__subtitle {
    font-size: 15px;
}

.mobilebar__left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
}

.mobilebar__menu {
    width: 44px;
    height: 44px;
    border: 1px solid var(--accent);
    border-radius: 12px;
    background: var(--accent);
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 0 11px;
    box-shadow: 0 10px 24px rgba(0, 112, 248, 0.18);
    flex-shrink: 0;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.mobilebar__menu:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.mobilebar__menu:active {
    transform: translateY(1px);
}

.mobilebar__menu:focus-visible {
    outline: 2px solid rgba(0, 112, 248, 0.28);
    outline-offset: 2px;
}

.mobilebar__menu span {
    display: block;
    width: 100%;
    height: 2.5px;
    border-radius: 999px;
    background: #ffffff;
}

.brand--mobile {
    gap: 10px;
    min-width: 0;
}

.brand__mobile-label {
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 1024px) {
    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

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

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(86vw, 320px);
        z-index: 60;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        border: 0;
        padding: 0;
        background: rgba(15, 23, 42, 0.42);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        z-index: 50;
    }

    .sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .mobilebar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: var(--mobilebar-height);
        padding: 12px 16px;
        background: rgba(255, 255, 255, 0.95);
        border-bottom: 1px solid rgba(148, 163, 184, 0.14);
        backdrop-filter: blur(12px);
        position: sticky;
        top: 0;
        z-index: 40;
        overflow: hidden;
    }

    .sidebar-open .mobilebar__menu {
        background: var(--accent-hover);
        border-color: var(--accent-hover);
    }

    .container--content,
    .container--auth {
        max-width: none;
        padding: 0 16px;
    }

    .main--shell {
        padding-top: 22px;
    }

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

    .login-hero {
        padding: 28px 24px;
    }

    .login-hero__title {
        font-size: 34px;
    }

    .auth-card {
        padding: 26px 22px;
    }

    .main {
        padding-top: 22px;
    }

    .btn,
    .input,
    .select,
    .textarea {
        min-height: 42px;
    }

    .btn--sm {
        min-height: 38px;
        padding: 8px 11px;
    }

    .toolbar {
        grid-template-columns: 1fr;
    }

    .stats {
        grid-template-columns: 1fr;
    }

    .item__actions .btn {
        flex: 1 1 auto;
    }

    .doc {
        align-items: flex-start;
        flex-direction: column;
    }

    .doc__actions {
        width: 100%;
        justify-content: stretch;
    }

    .doc__actions .btn {
        flex: 1 1 auto;
    }

    .status-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .estado-chip-control {
        justify-content: flex-start;
        min-width: 0;
    }

    .estado-chip-short {
        display: none;
    }

    .estado-chip-full {
        display: inline;
    }

    .toast-stack {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }

    .toast {
        width: 100%;
    }

    .table--responsive,
    .table--responsive thead,
    .table--responsive tbody,
    .table--responsive tr,
    .table--responsive th,
    .table--responsive td {
        display: block;
    }

    .table--responsive thead {
        display: none;
    }

    .table--responsive tbody tr {
        padding: 12px 14px;
        border-bottom: 1px solid var(--border);
    }

    .table--responsive tbody td {
        display: flex;
        justify-content: space-between;
        gap: 14px;
        padding: 7px 0;
        border-bottom: 0;
        text-align: right;
    }

    .table--responsive tbody td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-weight: 600;
        text-align: left;
    }

    .reference-thumb,
    .reference-thumb--placeholder {
        width: 72px;
        height: 72px;
    }
}

@media (max-width: 430px) {
    .list,
    .list--locations {
        grid-template-columns: 1fr;
    }

    .page-header {
        align-items: stretch;
    }

    .page-header__actions {
        width: 100%;
    }
}
