/* =====================================================================
   Gestión de Trabajos — Tecbisol
   Estilos base. Paleta "taller/contable": superficie clara, panel
   lateral profundo tipo consola, acento teal y cifras legibles.
   ===================================================================== */

:root {
    --bg:        #eef1f4;
    --surface:   #ffffff;
    --surface-2: #f7f9fb;
    --ink:       #16202b;
    --ink-soft:  #5b6b7b;
    --line:      #dce3ea;
    --brand:     #0d5c63;
    --brand-2:   #0f766e;
    --brand-ink: #e6f7f6;
    --accent:    #c2703d;
    --pos:       #157a4a;
    --neg:       #b23a3a;
    --panel:     #131c26;
    --panel-2:   #1c2833;
    --panel-ink: #cdd8e3;
    --radius:    10px;
    --radius-sm: 7px;
    --shadow:    0 1px 2px rgba(16,32,43,.06), 0 8px 24px rgba(16,32,43,.06);
    font-synthesis: none;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- Login */
.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        radial-gradient(1200px 600px at 15% -10%, #1c3540 0%, transparent 60%),
        radial-gradient(900px 500px at 110% 110%, #0d5c63 0%, transparent 55%),
        var(--panel);
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border-radius: 14px;
    padding: 32px 28px;
    box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand h1 { font-size: 1.35rem; margin: 12px 0 2px; letter-spacing: -.01em; }
.login-brand p { margin: 0; color: var(--ink-soft); font-size: .85rem; }
.login-foot { text-align: center; color: var(--ink-soft); font-size: .78rem; margin: 18px 0 0; }

.brand-dot {
    display: inline-block;
    width: 34px; height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--brand-2), var(--brand));
    box-shadow: 0 6px 16px rgba(13,92,99,.4);
}
.brand-dot-lg { width: 56px; height: 56px; border-radius: 12px; }

/* Logo cargado por el usuario */
.brand-logo {
    width: 38px; height: 38px;
    border-radius: 9px;
    object-fit: contain;
    background: #fff;
    box-shadow: 0 6px 16px rgba(0,0,0,.18);
    flex-shrink: 0;
}
.login-logo {
    width: 64px; height: 64px;
    border-radius: 14px;
    object-fit: contain;
    background: #fff;
    box-shadow: 0 8px 20px rgba(13,92,99,.25);
    margin: 0 auto 6px;
    display: block;
}

/* Bloque de carga de logo en Configuración */
.logo-config {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}
.logo-preview {
    width: 84px; height: 84px;
    border-radius: 14px;
    background: #f1f4f6;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-fields { flex: 1; min-width: 240px; }
.logo-fields .check { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: .88rem; }
.logo-fields .check input { width: auto; }
.small { font-size: .8rem; }

/* -------------------------------------------------------------- Layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--panel);
    color: var(--panel-ink);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand strong { display: block; color: #fff; font-size: .98rem; letter-spacing: -.01em; }
.brand small { color: #8397a8; font-size: .72rem; }

.menu { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.menu a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--panel-ink);
    font-size: .92rem;
    font-weight: 500;
}
.menu a:hover { background: var(--panel-2); text-decoration: none; color: #fff; }
.menu a.active { background: var(--brand); color: #fff; }
.menu a .ico { width: 18px; text-align: center; opacity: .85; }
.menu-sep {
    margin: 14px 12px 6px;
    font-size: .68rem;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #6b8093;
}

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

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 22px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-title { font-weight: 600; font-size: 1.02rem; flex: 1; letter-spacing: -.01em; }
.btn-menu {
    display: none;
    background: none; border: none;
    font-size: 1.35rem; cursor: pointer; color: var(--ink);
}
.user-box { display: flex; align-items: center; gap: 14px; }
.user-info { text-align: right; line-height: 1.2; }
.user-info strong { font-size: .86rem; }

.content { padding: 24px 22px; flex: 1; max-width: 1180px; width: 100%; }

.footer {
    display: flex;
    justify-content: space-between;
    padding: 16px 22px;
    color: var(--ink-soft);
    font-size: .78rem;
    border-top: 1px solid var(--line);
}

/* ---------------------------------------------------------- Roles/tags */
.rol {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .02em;
}
.rol-admin   { background: #fde8dc; color: #9a4a1f; }
.rol-usuario { background: #dcecee; color: #0d5c63; }

.tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--ink-soft);
    font-size: .7rem;
    font-weight: 600;
}
.tag-empresa { background: #eef4ff; border-color: #d6e4ff; color: #2a4d8f; }
.tag-persona { background: #f0f6f0; border-color: #d9ecd9; color: #2f6b3f; }

/* ------------------------------------------------------------- Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.card-title { margin: 0 0 16px; font-size: 1.02rem; letter-spacing: -.01em; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.card-head .card-title { margin: 0; }
.form-card { max-width: 760px; }

/* -------------------------------------------------------- Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.stat-card.accent {
    background: linear-gradient(155deg, var(--brand), #0a4a50);
    border-color: transparent;
    color: #fff;
}
.stat-card.accent .stat-label { color: var(--brand-ink); }
.stat-card.accent .stat-sub  { color: #bfe6e3; }
.stat-label {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-soft);
    font-weight: 600;
}
.stat-value { font-size: 1.55rem; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.stat-sub { font-size: .76rem; color: var(--ink-soft); margin-top: 2px; }

/* --------------------------------------------------- Estados por trabajo */
.estado-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.estado-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    padding: 8px 14px;
    border-radius: 40px;
}
.estado-cant { font-weight: 700; font-size: 1rem; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .74rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-recibido  { background: #e7edf3; color: #3a556e; }
.badge-proceso   { background: #fdf0d9; color: #8a5a12; }
.badge-curso     { background: #dbeafe; color: #1e50a8; }
.badge-entregado { background: #d9f2e3; color: #146c42; }
.badge-cancelado { background: #f8dede; color: #9a2b2b; }

/* -------------------------------------------------------------- Tablas */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table thead th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--line);
    color: var(--ink-soft);
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
}
.table tbody td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-2); }
.table .right  { text-align: right; white-space: nowrap; }
.table .center { text-align: center; }
.pos { color: var(--pos); font-weight: 600; }
.neg { color: var(--neg); font-weight: 600; }
.actions { text-align: right; white-space: nowrap; }

/* -------------------------------------------------------------- Botones */
.btn {
    display: inline-block;
    padding: 8px 15px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .12s, border-color .12s;
    text-decoration: none;
    line-height: 1.3;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.btn-primary:hover { background: var(--brand-2); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--neg); border-color: #edc9c9; background: #fdf3f3; }
.btn-danger:hover { background: #f8dede; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-block { width: 100%; margin-top: 8px; }
.inline { display: inline; }

/* --------------------------------------------------------- Formularios */
form label {
    display: block;
    margin-bottom: 14px;
    font-size: .82rem;
    font-weight: 600;
    color: var(--ink);
}
form input, form select, form textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font: inherit;
    color: var(--ink);
    font-weight: 400;
}
form input:focus, form select:focus, form textarea:focus {
    outline: none;
    border-color: var(--brand-2);
    box-shadow: 0 0 0 3px rgba(15,118,110,.14);
}
form textarea { resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }
.req { color: var(--neg); }
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.calc-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    background: var(--surface-2);
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 14px;
}
.calc-box strong { font-size: 1.1rem; }

.perm-note {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: .82rem;
    color: var(--ink-soft);
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.perm-note strong { color: var(--ink); }

/* --------------------------------------------------- Detalle cliente */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px 24px;
}
.detail-grid .col-span { grid-column: 1 / -1; }
.dl {
    display: block;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ink-soft);
    font-weight: 600;
    margin-bottom: 2px;
}

/* -------------------------------------------------------- Encabezados */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.page-head-actions { display: flex; gap: 10px; }
.search { display: flex; gap: 8px; align-items: center; flex: 1; max-width: 520px; flex-wrap: wrap; }
.search input, .search select {
    margin: 0;
    display: block;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font: inherit;
    color: var(--ink);
    font-weight: 400;
}
.search input[type="search"] { flex: 1 1 180px; width: auto; min-width: 0; }
.search select { flex: 0 1 auto; width: auto; min-width: 150px; }
.search .btn { flex: 0 0 auto; }
.search input:focus, .search select:focus {
    outline: none;
    border-color: var(--brand-2);
    box-shadow: 0 0 0 3px rgba(15,118,110,.14);
}
.search.filters { max-width: 640px; }

/* ---------------------------------------------------------- Alertas */
.alert {
    padding: 11px 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: .88rem;
    border: 1px solid transparent;
}
.alert ul { margin: 0; padding-left: 18px; }
.alert-ok    { background: #d9f2e3; border-color: #b6e3c8; color: #14683f; }
.alert-error { background: #fbe4e4; border-color: #f0c2c2; color: #9a2b2b; }
.alert-info  { background: #dfeef0; border-color: #bfe0e3; color: #0d5c63; }

.muted { color: var(--ink-soft); }

/* ------------------------------------------------------- Responsive */
@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        transition: transform .22s ease;
        z-index: 60;
        box-shadow: 8px 0 30px rgba(0,0,0,.3);
    }
    .sidebar.open { transform: translateX(0); }
    .btn-menu { display: block; }
    .grid-2, .grid-3, .detail-grid, .calc-box { grid-template-columns: 1fr; }
    .content { padding: 16px; }
    .user-info { display: none; }
}
@media (max-width: 680px) {
    .page-head { flex-direction: column; align-items: stretch; }
    .search, .search.filters { max-width: none; width: 100%; }
    .search input[type="search"], .search select { flex: 1 1 100%; width: 100%; min-width: 0; }
    .search .btn { flex: 1 1 100%; width: 100%; }
    .page-head > .btn,
    .page-head > a.btn { width: 100%; text-align: center; }
}

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

/* =====================================================================
   Orden de trabajo / comprobante
   ===================================================================== */
.code {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-weight: 700; letter-spacing: .04em; color: var(--brand);
    background: rgba(13,92,99,.08); padding: 2px 8px; border-radius: 6px;
    font-size: .82rem; white-space: nowrap;
}
.btn-order { border-color: rgba(13,92,99,.35); color: var(--brand); }

.orden-actions {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px;
}
.orden-actions .spacer { flex: 1; }
.btn-wa { background: #25D366; color: #fff; border: none; }
.btn-wa:hover { background: #1fb959; }
.btn-wa-ghost { background: #fff; color: #128C7E; border: 1px solid #25D366; }
.btn-wa-ghost:hover { background: #e9fbf0; }

.orden-doc {
    max-width: 620px; margin: 0 auto; background: #fff;
    border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
    box-shadow: 0 10px 30px rgba(15,23,42,.08);
}
.orden-head {
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    color: #fff; padding: 22px 26px; display: flex;
    align-items: center; justify-content: space-between; gap: 16px;
}
.orden-brand { display: flex; align-items: center; gap: 14px; }
.orden-logo { width: 52px; height: 52px; border-radius: 11px; object-fit: contain; background: #fff; padding: 4px; }
.orden-head h2 { margin: 0; font-size: 1.15rem; }
.orden-head p { margin: 2px 0 0; opacity: .9; font-size: .85rem; }
.orden-code { text-align: right; }
.orden-code span { display: block; font-size: .7rem; text-transform: uppercase; opacity: .85; letter-spacing: .08em; }
.orden-code strong { font-size: 1.15rem; letter-spacing: .03em; }

.orden-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
    padding: 24px 26px 6px;
}
.orden-grid .lbl, .orden-work .lbl {
    display: block; font-size: .68rem; text-transform: uppercase;
    letter-spacing: .07em; color: var(--ink-soft); font-weight: 700; margin-bottom: 4px;
}
.orden-grid p { margin: 0; font-weight: 600; color: var(--ink); }
.orden-work { padding: 12px 26px 4px; }
.orden-work h3 { margin: 2px 0 6px; font-size: 1.1rem; }
.orden-total {
    margin: 18px 26px; padding: 16px 20px; background: #f1f5f9;
    border-radius: 12px; display: flex; align-items: center; justify-content: space-between;
}
.orden-total span { font-weight: 700; color: var(--ink-soft); font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; }
.orden-total strong { font-size: 1.5rem; color: var(--brand); }
.orden-foot { text-align: center; color: var(--ink-soft); font-size: .85rem; padding: 0 26px 22px; margin: 0; }

/* Utilidades varias */
.table.mini td { padding: 8px 10px; }
.tight { margin: 6px 0 0; padding-left: 18px; }
.tight li { margin: 2px 0; }
.mt { margin-top: 14px; }

@media (max-width: 620px) {
    .orden-grid { grid-template-columns: 1fr; }
    .orden-head { flex-direction: column; align-items: flex-start; }
    .orden-code { text-align: left; }
}

/* Impresión: solo el comprobante */
@media print {
    .sidebar, .topbar, .footer, .orden-actions, .alert { display: none !important; }
    .layout, .main, .content { display: block; margin: 0; padding: 0; }
    .orden-doc { box-shadow: none; border: none; max-width: 100%; }
    body { background: #fff; }
}

/* =====================================================================
   Multi-empresa: superusuario
   ===================================================================== */
.section-title { margin: 0; font-size: 1.05rem; color: var(--ink); }
.rol-superuser { background: #ede9fe; color: #6d28d9; }

/* =====================================================================
   Mi plan y medios de pago
   ===================================================================== */
.plan-cards { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 16px; }
.plan-main { display: flex; flex-direction: column; gap: 6px; }
.plan-main .lbl { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); font-weight: 700; }
.plan-name { margin: 2px 0; font-size: 1.6rem; color: var(--brand); }
.plan-periodo { color: var(--ink-soft); font-weight: 600; }
.plan-estado { margin-top: 8px; }
.plan-side { display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.plan-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.plan-row .lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); font-weight: 700; }

.pay-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.pay-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: #fff; }
.pay-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.pay-tipo { font-size: .7rem; background: rgba(13,92,99,.08); color: var(--brand); padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.pay-detalle { margin: 0; color: var(--ink-soft); font-size: .9rem; line-height: 1.5; }

@media (max-width: 620px) {
    .plan-cards { grid-template-columns: 1fr; }
}
