/* ══════════ Sistema visual ══════════
   Monocromático en grises. Una sola familia (Archivo).
   La marca es siempre el logo (img/logo-blanco.png en el encabezado); el nombre nunca va escrito.
   La franja grafito del encabezado es el único elemento oscuro de la página. */

:root {
    --font:        'Archivo', 'Helvetica Neue', Arial, sans-serif;

    --brand:       #2b2d31;   /* grafito: botones principales, totales */
    --brand-mid:   #46494f;   /* grafito claro: hover */
    --brand-light: #5c5f66;   /* acero: títulos de sección, enlaces */

    --bg:          #f3f3f4;   /* fondo */
    --surface:     #ffffff;   /* tarjetas, tablas */
    --surface2:    #e9eaec;   /* encabezados de tabla, barras */
    --border:      #d9dadd;   /* líneas */
    --text:        #1d1e21;   /* texto */
    --text-muted:  #74777e;   /* texto secundario */
    --total-color: #1d1e21;

    --header-bg:   #26282c;
    --header-text: #f3f3f4;
    --header-muted:#9a9da3;
    --danger:      #9e3b3b;   /* solo para borrar y errores */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
}

button, input, select, textarea { font-family: var(--font); }

:focus-visible { outline: 2px solid var(--brand-light); outline-offset: 2px; }

/* ── HEADER ── */
header {
    position: relative;
    background: var(--header-bg);
    color: var(--header-text);
    padding: 22px 60px 22px;
    display: flex;
    align-items: center;
    gap: 28px;
    overflow: hidden;
}

/* Logo a la izquierda; a su lado, el nombre de la sección y el enlace de regreso */
header > div:first-child {
    display: grid !important;
    grid-template-columns: auto 1fr;
    grid-template-rows: 1fr 1fr;
    column-gap: 26px;
    align-items: center;
}

.brand {
    grid-column: 1;
    grid-row: 1 / 3;
    display: block;
    line-height: 0;
    position: relative;
    text-decoration: none;
}
.brand-logo {
    display: block;
    height: 112px;
    width: auto;
}
a.brand { transition: opacity 0.2s; }
a.brand:hover { opacity: 0.85; }

.brand-sub {
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    font-family: var(--font);
    font-size: 1.6rem;
    font-weight: 300;
    font-stretch: 112%;
    letter-spacing: 0.01em;
    color: var(--header-text);
    padding-left: 26px;
    border-left: 1px solid #4a4d53;
    line-height: 1.15;
    position: relative;
}
/* Páginas sin enlace de regreso (menú, acceso): el nombre se centra junto al logo */
header > div:first-child:not(:has(.back-link)) .brand-sub { grid-row: 1 / 3; align-self: center; }

.back-link {
    grid-column: 2;
    grid-row: 2;
    align-self: start;
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font);
    font-size: 0.85rem;
    color: var(--header-muted);
    text-decoration: none;
    margin-top: 8px;
    padding-left: 26px;
    border-left: 1px solid #4a4d53;
    transition: color 0.2s;
}

.back-link:hover { color: var(--header-text); }

.back-arrow {
    font-size: 0.95rem;
    display: inline-block;
    transition: transform 0.2s;
}

.back-link:hover .back-arrow { transform: translateX(-4px); }

/* Regla fina que remata la franja, como la cota de un plano */
.header-line {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(to right, #8d9096 0, #8d9096 60px, transparent 60px);
}

/* ── MAIN ── */
main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 48px 40px 80px;
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.section-title {
    font-family: var(--font);
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    color: var(--text);
}

.actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.actions + .table-wrap ~ .actions {
    margin-top: 16px;
}

/* ── TABLE ── */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-wrap {
    border: 1px solid var(--border);
    border-radius: 3px;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(29,30,33,0.05);
    min-width: 620px;
}

.col-header {
    display: grid;
    grid-template-columns: 70px 1fr 150px 140px 150px;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
}

.col-header span {
    font-size: 0.79rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-muted);
    padding: 13px 16px;
}

.col-header span:not(:last-child) {
    border-right: 1px solid var(--border);
}

/* ── ROWS ── */
.rows-container { display: flex; flex-direction: column; }

.row {
    display: grid;
    grid-template-columns: 70px 1fr 150px 140px 150px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    background: var(--surface);
}

.row:last-child { border-bottom: none; }
.row:nth-child(even) { background: #fafafa; }
.row:hover { background: rgba(29,30,33,0.03); }

.cell {
    border-right: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 2px 8px;
}

.cell:last-child { border-right: none; }

.cell input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.85rem;
    padding: 7px 10px;
    caret-color: var(--brand);
    transition: color 0.15s;
}

.cell input::placeholder { color: #bfc1c5; }
.cell input:focus { color: var(--text); }

.cell input[type="number"] { -moz-appearance: textfield; }
.cell input[type="number"]::-webkit-inner-spin-button,
.cell input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }

.cell-total {
    padding: 7px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #b4b6ba;
    font-family: var(--font);
    flex: 1;
    transition: color 0.2s;
}

.cell-total.has-value { color: var(--total-color); }

/* ── TOTALS BAR ── */
.totals-bar {
    display: grid;
    grid-template-columns: 70px 1fr 150px 140px 150px;
    background: var(--surface2);
    border-top: 1px solid var(--border);
}

.totals-bar .tb-cell {
    padding: 16px 18px;
    border-right: 1px solid var(--border);
}
.totals-bar .tb-cell:last-child { border-right: none; }

.totals-bar .tb-label {
    font-size: 0.79rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-muted);
    display: block;
    margin-bottom: 5px;
}

.totals-bar .tb-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--brand);
    font-family: var(--font);
}

/* ── ACTIONS ── */
.btn {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    padding: 10px 20px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    border-radius: 4px;
}

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

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

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

.btn-danger:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* ── FORMULARIO COTIZACIÓN ── */
.cot-form {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 24px 28px;
    margin-bottom: 32px;
    box-shadow: 0 1px 6px rgba(29,30,33,0.05);
}
.cot-form-title {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    color: var(--text);
    margin-bottom: 16px;
}
.cot-form-fields {
    display: grid;
    grid-template-columns: 1.5fr 160px 1fr 100px;
    gap: 16px;
}
.cot-field { display: flex; flex-direction: column; gap: 6px; position: relative; }
.cot-label {
    font-size: 0.79rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-muted);
}
.cot-input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 9px 12px;
    font-family: var(--font);
    font-size: 0.85rem;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}
.cot-input:focus { border-color: var(--brand-light); }
.date-input { cursor: pointer; }

/* ── CALENDARIO ── */
.date-picker {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    box-shadow: 0 4px 16px rgba(29,30,33,0.1);
    z-index: 200;
    padding: 12px;
    width: 260px;
}
.cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.cal-month {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text);
}
.cal-nav {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 2px;
    transition: color 0.15s;
}
.cal-nav:hover { color: var(--brand); }
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.cal-day-name {
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-align: center;
    color: var(--text-muted);
    padding: 4px 0;
}
.cal-day {
    text-align: center;
    font-size: 0.75rem;
    padding: 6px 2px;
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    color: var(--text);
}
.cal-day:hover { background: var(--surface2); color: var(--brand); }
.cal-today { font-weight: 600; color: var(--brand-light); }
.cal-selected { background: var(--brand) !important; color: #fff !important; border-radius: 2px; }

/* ── BÚSQUEDA CLIENTE ── */
.client-search-wrap { position: relative; }
.client-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2px;
    box-shadow: 0 4px 12px rgba(29,30,33,0.08);
    z-index: 100;
    max-height: 180px;
    overflow-y: auto;
}
.client-option {
    padding: 9px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
}
.client-option:hover { background: var(--surface2); color: var(--brand); }
.btn-new-client {
    background: none;
    border: none;
    color: var(--brand-light);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    padding: 4px 0;
    text-align: left;
    transition: color 0.2s;
}
.btn-new-client:hover { color: var(--brand); }
.new-client-form {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 8px;
}

/* ── CATEGORÍAS ── */
.categoria-section { margin-bottom: 36px; }
.categoria-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.categoria-title {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    color: var(--text);
}
.btn-sm {
    padding: 7px 16px;
    font-size: 0.65rem;
}

/* ── SUBTOTAL BAR ── */
.subtotal-bar {
    display: grid;
    grid-template-columns: 70px 1fr 150px 140px 150px;
    background: var(--surface2);
    border-top: 1px solid var(--border);
}
.sb-cell {
    padding: 12px 16px;
    border-right: 1px solid var(--border);
    font-family: var(--font);
}
.sb-cell:last-child { border-right: none; }
.sb-label {
    text-align: right;
    letter-spacing: 0.01em;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
}
.sb-value { color: var(--brand); font-size: 0.85rem; font-weight: 600; }

/* ── TOTAL GENERAL ── */
.total-general-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 18px 24px;
    margin-top: 8px;
    box-shadow: 0 1px 6px rgba(29,30,33,0.05);
}
.total-general-label {
    font-size: 0.79rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-muted);
}
.total-general-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--brand);
    font-family: var(--font);
}

/* ── BOTONES GUARDAR ── */
.btn-save { border-color: var(--brand); color: var(--brand); }
.btn-save:hover { background: var(--brand); color: #fff; }
.btn-save-exit { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-save-exit:hover { background: var(--brand-mid); border-color: var(--brand-mid); }

/* ── LOGIN ── */
.login-wrap { display: flex; justify-content: center; align-items: center; min-height: 60vh; }
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 36px 40px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 1px 6px rgba(29,30,33,0.05);
}
.login-error { font-size: 0.75rem; color: #b56a6a; margin-top: 6px; display: block; }

/* ── INDEX NAV ── */
.index-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.index-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 118px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 22px 56px 22px 24px;
    text-decoration: none;
    color: var(--text);
    transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.index-card:hover { background: var(--header-bg); border-color: var(--header-bg); }
.index-card-title { font-size: 1.1rem; font-weight: 600; letter-spacing: -0.005em; color: var(--text); transition: color 0.18s; }
.index-card-sub { font-size: 0.82rem; line-height: 1.45; color: var(--text-muted); transition: color 0.18s; }
.index-card-arrow {
    position: absolute;
    right: 22px;
    bottom: 20px;
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: transform 0.18s, color 0.18s;
}
.index-card:hover .index-card-title { color: var(--header-text); }
.index-card:hover .index-card-sub { color: var(--header-muted); }
.index-card:hover .index-card-arrow { transform: translateX(4px); color: var(--header-text); }

@media (max-width: 640px) {
    .index-nav { grid-template-columns: 1fr; }
    .index-card { min-height: 0; }
}

/* ── REGISTRO ── */
.cotizaciones-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.cot-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 18px 20px;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    box-shadow: 0 1px 4px rgba(29,30,33,0.05);
}

.cot-card:hover {
    border-color: var(--brand-light);
    box-shadow: 0 4px 12px rgba(29,30,33,0.1);
    transform: translateY(-2px);
}

.cot-card.dragging {
    opacity: 0.4;
    cursor: grabbing;
}

.cot-card-titulo {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 10px;
    line-height: 1.3;
}

.cot-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.cot-card-fecha {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--brand);
    letter-spacing: 0.05em;
}

.cot-card-estado {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    padding: 3px 8px;
    border-radius: 2px;
}

/* Los estados avanzan de claro a oscuro: entre más oscuro, más cerca de cerrar */
.estado-borrador      { background: transparent; color: var(--text-muted); box-shadow: inset 0 0 0 1px var(--border); }
.estado-por_autorizar { background: #e9eaec; color: #46494f; }
.estado-autorizado    { background: #c9cbcf; color: #1d1e21; }
.estado-por_liquidar  { background: #74777e; color: #ffffff; }
.estado-liquidado     { background: #1d1e21; color: #ffffff; }

.cot-card-cliente {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.cot-card-autor {
    font-size: 0.79rem;
    color: #b4b6ba;
    letter-spacing: 0.01em;
}

.cot-loading, .cot-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 40px 0;
    text-align: center;
    grid-column: 1 / -1;
}

/* ── LAST MODIFIED BAR ── */
.last-modified-bar {
    font-size: 0.72rem;
    color: var(--text-muted);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 10px 16px;
    margin-bottom: 16px;
}

.last-modified-bar span {
    font-weight: 600;
    color: var(--brand-light);
}

/* ── ESTADO BAR ── */
.estado-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 12px 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(29,30,33,0.04);
}

.estado-bar-label {
    font-size: 0.73rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-muted);
    white-space: nowrap;
}

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

.estado-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 14px;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.estado-btn:hover {
    border-color: var(--brand-light);
    color: var(--brand);
}

.estado-btn.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #ffffff;
}

.hidden { display: none !important; }

/* ── EXPORT BUTTONS ── */
.export-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.btn-export {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 6px 14px;
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-export:hover {
    border-color: var(--brand);
    color: var(--brand);
}

/* ── SCROLL TO TOP ── */
.btn-scroll-top {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 10px 28px;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-scroll-top:hover {
    border-color: var(--brand-light);
    color: var(--brand);
}

/* ── EXPORT BAR ── */
.export-bar {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 12px 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(29,30,33,0.04);
}

/* ── PROVEEDORES ── */
.prov-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr 140px 90px 80px 44px !important;
}

.cell-action {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.btn-delete {
    background: none;
    border: none;
    color: #b4b6ba;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 2px;
    transition: color 0.15s, background 0.15s;
    line-height: 1;
}

.btn-delete:hover {
    color: #9e3b3b;
    background: #f5eded;
}

/* ── MODAL ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20,21,24,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 32px 36px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(29,30,33,0.12);
}

.modal-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.modal-body {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn-danger-confirm {
    background: #8f3333;
    border-color: #8f3333;
    color: #fff;
}

.btn-danger-confirm:hover {
    background: #7a2a2a;
    border-color: #7a2a2a;
}

/* ── CONCEPTOS ── */
.conceptos-grid {
    display: grid !important;
    grid-template-columns: 1fr 160px 44px !important;
}

/* ── RENGLONES DE COMENTARIO ── */
.cell-with-comment {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    flex: 1;
}

.btn-add-comment {
    background: none;
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--text-muted);
    font-size: 0.75rem;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
    padding: 0;
}

.row:hover .btn-add-comment {
    opacity: 1;
}

.btn-add-comment:hover {
    color: var(--brand);
    border-color: var(--brand-light);
}

.row-comment {
    display: grid;
    grid-template-columns: 24px 70px 1fr 150px 110px 120px 100px;
    background: #fafafa !important;
    border-bottom: 1px dashed var(--border) !important;
}

.row-comment .cell-comment-full {
    grid-column: 3 / 7;
}

.row-comment:hover {
    background: rgba(29,30,33,0.02) !important;
}

.cell-comment-full {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-right: none !important;
}

.comment-icon {
    font-size: 0.75rem;
    opacity: 0.5;
    flex-shrink: 0;
}

.comment-text {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    font-family: var(--font);
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    caret-color: var(--brand);
}

.comment-text::placeholder {
    color: #bfc1c5;
}

.btn-remove-comment {
    background: none;
    border: none;
    color: #bfc1c5;
    font-size: 0.75rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    flex-shrink: 0;
}

.row-comment:hover .btn-remove-comment {
    opacity: 1;
}

.btn-remove-comment:hover {
    color: #9e3b3b;
}

/* ── DROPDOWN ACTIVE OPTION ── */
.dropdown-active {
    background: var(--surface2);
    color: var(--brand);
}

/* ── CARD DELETE BUTTON ── */
.cot-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 8px;
}

.cot-card-header .cot-card-titulo {
    margin-bottom: 0;
    flex: 1;
}

.btn-delete-card {
    background: none;
    border: none;
    color: #bfc1c5;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    flex-shrink: 0;
    line-height: 1;
}

.cot-card:hover .btn-delete-card {
    opacity: 1;
}

.btn-delete-card:hover {
    color: #9e3b3b;
}

/* ── ROW CONTROLS ── */
.col-header:not(.prov-grid):not(.conceptos-grid):not(.venues-grid),
.row[data-tipo="item"],
.subtotal-bar {
    grid-template-columns: 24px 70px 1fr 150px 110px 120px 100px !important;
}

.cell-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #bfc1c5;
    font-size: 1rem;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.15s;
    user-select: none;
    border-right: none !important;
    padding: 0 !important;
}

.row:hover .cell-drag-handle { opacity: 1; }
.cell-drag-handle:active { cursor: grabbing; }

.cell-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    padding: 0 6px !important;
    border-left: 1px solid var(--border);
    opacity: 0;
    transition: opacity 0.15s;
}

.row:hover .cell-row-actions { opacity: 1; }

.btn-row-action {
    background: none;
    border: none;
    color: #b4b6ba;
    font-size: 0.65rem;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 2px;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
    font-family: var(--font);
    line-height: 1;
}

.btn-row-action:not(.btn-row-delete):not(.btn-row-comment) {
    font-size: 0.85rem;
}

.btn-row-action:hover { color: var(--brand); background: var(--surface2); }
.btn-row-delete:hover { color: #9e3b3b !important; background: #f5eded !important; }

.row.dragging { opacity: 0.4; }
.row.drag-over { border-top: 2px solid var(--brand-light); }

.col-handle { padding: 0 !important; }

/* ── VENUES ── */
.venues-grid {
    display: grid !important;
    grid-template-columns: 1fr 1.5fr 44px !important;
}

/* ── COMMENT TOOLBAR BUTTON ── */
.btn-comment-toolbar {
    border-color: var(--text-muted);
    color: var(--text-muted);
    font-style: italic;
    opacity: 1 !important;
}
.btn-comment-toolbar:hover {
    border-color: var(--brand-light);
    color: var(--brand);
}

.btn-row-comment:hover { color: var(--brand-light) !important; background: var(--surface2) !important; }

/* ── DUPLICATE CARD BUTTON ── */
.btn-duplicate-card {
    background: none;
    border: 1px solid var(--border);
    border-radius: 2px;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    padding: 6px 10px;
    transition: all 0.15s;
    opacity: 0;
}

.cot-card:hover .btn-duplicate-card {
    opacity: 1;
}

.btn-duplicate-card:hover {
    border-color: var(--brand-light);
    color: var(--brand);
}

/* ── CALENDAR ICON BUTTON ── */
.btn-cal-icon {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 2px;
    cursor: pointer;
    padding: 6px 8px;
    font-size: 0.85rem;
    line-height: 1;
    color: var(--text-muted);
    transition: border-color 0.15s;
    flex-shrink: 0;
}
.btn-cal-icon:hover { border-color: var(--brand-light); }

/* ── ANTICIPOS ── */
.anticipo-add-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.btn-add-anticipo {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.75rem;
  padding: 6px 14px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.btn-add-anticipo:hover { border-color: var(--brand); color: var(--brand); }

.anticipo-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
}

.anticipo-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 90px;
  text-align: right;
}

.anticipo-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.82rem;
  padding: 5px 10px;
  width: 220px;
  text-align: right;
  outline: none;
  transition: border-color 0.2s;
}
.anticipo-input:focus { border-color: var(--brand); }

.anticipo-monto {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  min-width: 100px;
  text-align: right;
}

.btn-del-anticipo {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0.5;
  transition: opacity 0.2s, color 0.2s;
}
.btn-del-anticipo:hover { opacity: 1; color: #9e3b3b; }

.total-neto-bar {
  margin-top: 0;
  border-top: 2px solid var(--brand);
}

/* ── SEPARADOR ── */
.row-separator {
  display: flex;
  align-items: center;
  border-top: 2px solid var(--border);
  margin: 6px 0;
  background: transparent;
}

.cell-separator-full {
  flex: 1;
  padding: 4px 8px;
}

.separator-text {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  width: 100%;
  outline: none;
  padding: 4px 0;
}
.separator-text::placeholder { color: var(--border); }

.btn-add-separator {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.65rem;
  padding: 3px 10px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  margin-left: 8px;
}
.btn-add-separator:hover { border-color: var(--brand); color: var(--brand); }

/* ── SEPARADOR: botón eliminar siempre visible ── */
.row-separator .cell-row-actions {
  opacity: 1 !important;
}

/* ── SELECTOR DE HORA ── */
.time-field-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

.time-input {
    flex: 1;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.05em;
}
.time-input::placeholder { color: var(--border); letter-spacing: 0.1em; }

.btn-time-icon {
    background: none;
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1;
    padding: 7px 9px;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.2s, color 0.2s;
}
.btn-time-icon:hover { border-color: var(--brand); color: var(--brand); }

.time-picker {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    box-shadow: 0 4px 16px rgba(29,30,33,0.1);
    z-index: 200;
    padding: 10px;
    width: 226px;
}
.time-picker.hidden { display: none; }

.tp-cols { display: grid; gap: 6px; }
.tp-cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.tp-col-label {
    font-size: 0.72rem;
    letter-spacing: 0.01em;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 6px;
}

.tp-scroll {
    height: 168px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    scrollbar-width: thin;
}
.tp-scroll::-webkit-scrollbar { width: 5px; }
.tp-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.tp-opt {
    background: none;
    border: none;
    border-radius: 3px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
    padding: 7px 0;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.12s, color 0.12s;
}
.tp-opt:hover { background: rgba(29,30,33,0.06); }
.tp-opt.active {
    background: var(--brand);
    color: #fff;
    font-weight: 600;
}

.tp-footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.tp-btn-clear, .tp-btn-ok {
    font-family: var(--font);
    font-size: 0.68rem;
    padding: 5px 12px;
    border-radius: 3px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.tp-btn-clear {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.tp-btn-clear:hover { border-color: var(--brand); color: var(--brand); }
.tp-btn-ok {
    background: var(--brand);
    border: 1px solid var(--brand);
    color: #fff;
}
.tp-btn-ok:hover { opacity: 0.88; }

/* Móvil: columnas más anchas y táctiles */
@media (max-width: 768px) {
    .time-picker { width: 244px; padding: 12px; }
    .tp-scroll { height: 150px; }
    .tp-opt { padding: 10px 0; font-size: 0.88rem; }
}

/* Columna AM/PM: sólo 2 opciones, sin scroll */
.tp-col:last-child .tp-scroll {
    height: auto;
    justify-content: flex-start;
    overflow: visible;
}

/* ── PRECIO ESPECIAL (CLIENTE / CORTESÍA) ── */
.cell-precio { position: relative; display: flex; align-items: center; gap: 2px; }
.cell-precio .unit-cost { flex: 1; min-width: 0; }
.cell-precio .unit-cost.hidden { display: none; }

.precio-badge {
    flex: 1;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--brand);
    background: rgba(29,30,33,0.07);
    border-radius: 3px;
    padding: 5px 4px;
    text-align: center;
    white-space: nowrap;
}
.precio-badge.hidden { display: none; }

.btn-precio-tipo {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    padding: 3px 5px;
    cursor: pointer;
    opacity: 0.55;
    flex-shrink: 0;
    transition: opacity 0.15s, color 0.15s;
}
.btn-precio-tipo:hover { opacity: 1; color: var(--brand); }

.precio-menu {
    position: fixed;
    z-index: 400;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 3px;
    box-shadow: 0 4px 14px rgba(29,30,33,0.18);
    display: flex;
    flex-direction: column;
    min-width: 110px;
    padding: 3px;
}
.precio-menu.hidden { display: none; }
.precio-menu button {
    background: none;
    border: none;
    border-radius: 2px;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.7rem;
    text-align: left;
    padding: 6px 9px;
    cursor: pointer;
    transition: background 0.12s;
}
.precio-menu button:hover { background: rgba(29,30,33,0.07); }

/* Iconos de calendario y reloj en escala de grises, para no romper la paleta */
.btn-cal-icon, .btn-time-icon { filter: grayscale(1); }

/* Encabezado compacto en celular: la marca en una sola línea */
@media (max-width: 640px) {
    header { padding: 16px 20px; }
    header > div:first-child { column-gap: 16px; }
    .brand-logo { height: 76px; }
    .brand-sub { font-size: 1.15rem; padding-left: 16px; }
    .back-link { font-size: 0.78rem; padding-left: 16px; margin-top: 6px; }
    .header-line { background: linear-gradient(to right, #8d9096 0, #8d9096 20px, transparent 20px); }
}
