/* Estilo del negocio: variables, encabezado, tarjetas, toast, la liga pegada y las dos
   páginas (la tabla de cierres y el cierre de un día). Solo lo que usan index.html y dia.html. */

/* ========== Variables ========== */
:root {
    --primary: #023265;
    --primary-light: #e8f0fb;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #b9770e;
    --bg: #f9f9f9;
    --surface: #ffffff;
    --text: #333333;
    --text-muted: #888888;
    --border: #e8e8e8;
    --shadow-sm: 0 2px 8px rgba(2, 50, 101, 0.07);
    --shadow: 0 4px 16px rgba(2, 50, 101, 0.1);
    --radius: 14px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-weight: 400;
    background-color: var(--bg);
    color: var(--text);
    padding-bottom: env(safe-area-inset-bottom);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

/* ========== Header sticky glassmorphism ========== */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

header h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(1.2em, 3vw, 1.8em);
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.3px;
}

.header-subtitle {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-top: 2px;
}

.header-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.88em;
    font-weight: 600;
    border: 1.5px solid var(--primary);
    padding: 7px 16px;
    border-radius: 50px;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.header-link:hover { background: var(--primary); color: white; }

/* ========== Layout ========== */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 24px 18px;
}

.vacio {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9em;
    padding: 14px 0 4px;
}

/* ========== Card ========== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px 20px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.card h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.25em;
    color: var(--primary);
    margin-bottom: 16px;
}

/* ========== Botones ========== */
.btn-mini {
    display: inline-block;
    background: var(--surface);
    color: var(--primary);
    border: 1px solid var(--border);
    border-radius: 50px;
    padding: 8px 14px;
    font-family: inherit;
    font-size: 0.82em;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.btn-mini:hover:not([aria-disabled="true"]) { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-mini.principal { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ========== Toast ========== */
#toast {
    position: fixed;
    bottom: calc(24px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--primary);
    color: white;
    padding: 10px 18px;
    border-radius: 50px;
    font-size: 0.85em;
    font-weight: 500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    z-index: 9999;
    max-width: 90vw;
    text-align: center;
    box-shadow: var(--shadow);
}

#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error   { background: var(--danger); }

/* ========== Sin token: «abre tu liga otra vez» ========== */
.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
}

.auth-card { width: 100%; max-width: 380px; margin: 0; text-align: center; }
.auth-card p { color: var(--text-muted); font-size: 0.92em; line-height: 1.5; }

/* ========== Responsive ========== */
@media (max-width: 480px) {
    header h1 { font-size: 1.2em; }
    .header-subtitle { display: none; }
    .container { padding: 16px 12px; }
    .card { padding: 18px 14px; }
}

/* ========== Liga pegada (sin token, p. ej. la app instalada en iPhone) ========== */
.form-liga { display: flex; gap: 8px; margin-top: 16px; }
.form-liga input {
    flex: 1; min-width: 0; padding: 10px 12px; font: inherit; font-size: 16px; /* 16px: sin zoom en iOS */
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg); color: var(--text); outline: none; appearance: none;
}
.form-liga input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(2, 50, 101, 0.08); background: var(--surface); }

/* ========== Negocio: tabla de cierres (index.html) ========== */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 0.9em; cursor: pointer;
}
.chip.activo { background: var(--primary); border-color: var(--primary); color: #fff; }

.resumen { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.resumen-card {
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm);
    padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
}
.resumen-titulo { font-size: 0.78em; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.resumen-card strong { font-size: 1.5em; }
.resumen-card span:last-child { font-size: 0.85em; color: var(--text-muted); }

.tabla-cont { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.tabla-cierres { width: 100%; border-collapse: collapse; font-size: 0.92em; }
.tabla-cierres th {
    text-align: right; font-size: 0.75em; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em; padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.tabla-cierres th:first-child, .tabla-cierres td:first-child { text-align: left; }
.tabla-cierres td { text-align: right; padding: 12px 14px; border-top: 1px solid var(--border); white-space: nowrap; vertical-align: top; }
.tabla-cierres tr:first-child td { border-top: 0; }
.tabla-cierres .fila { cursor: pointer; }
.tabla-cierres .fila:hover, .tabla-cierres .fila:focus { background: var(--primary-light); outline: none; }
.tabla-cierres .fecha { font-weight: 600; text-transform: capitalize; }
.tabla-cierres small { display: block; font-size: 0.78em; color: var(--text-muted); }
.positivo { color: var(--success); font-weight: 600; }
.negativo { color: var(--danger); font-weight: 600; }
.aviso { color: var(--warning); }
@media (max-width: 480px) { .tabla-cierres .opcional { display: none; } }

/* ========== Negocio: un día (dia.html) ========== */
#titulo { text-transform: capitalize; }
#dia .card { margin-bottom: 16px; }
#dia h2 { font-size: 1em; margin-bottom: 10px; color: var(--primary); }
.estado { width: 100%; border-collapse: collapse; }
.estado td { padding: 7px 0; border-top: 1px solid var(--border); }
.estado td:last-child { text-align: right; white-space: nowrap; }
.estado tr:first-child td { border-top: 0; }
.estado .subtotal td { font-weight: 600; }
.estado .total td { font-weight: 700; border-top: 2px solid var(--text); }
.estado small { color: var(--text-muted); }
.dato { margin-top: 10px; font-size: 0.92em; color: var(--text-muted); }
.nota-dia { margin: 0 0 16px; padding: 12px 14px; border-radius: var(--radius-sm); background: #fff6e5; color: var(--warning); font-size: 0.92em; }
.nav-dia { display: flex; justify-content: space-between; gap: 8px; margin: 8px 0 24px; }
.nav-dia [aria-disabled="true"] { opacity: 0.4; cursor: default; }

.analisis p, .analisis ul, .analisis ol { margin: 0 0 12px; line-height: 1.55; }
.analisis ul, .analisis ol { padding-left: 20px; }
.analisis h2, .analisis h3, .analisis h4 { margin: 16px 0 8px; }
.md-tabla { overflow-x: auto; margin: 0 0 12px; }
.md-tabla table { border-collapse: collapse; font-size: 0.9em; min-width: 60%; }
.md-tabla th, .md-tabla td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.md-tabla th { color: var(--text-muted); font-weight: 600; }
