/* ============================================================
   TIRARCO — base.css
   Sistema de diseño: variables, reset, utilidades y componentes.
   Sin dependencias externas (sustituye a Bootstrap + FontAwesome).
   ============================================================ */

:root {
    --primary: #0160de;
    --primary-dark: #004bb0;
    --primary-soft: #e8f0fe;
    --accent: #ffcb02;
    --pink: #ff007a;
    --danger: #d9353f;
    --danger-dark: #b02a33;
    --success: #1f9d55;
    --success-dark: #15803d;
    --warning: #f59e0b;
    --info: #0ea5e9;

    --bg: #f4f6fb;
    --bg-card: #ffffff;
    --bg-alt: #f8fafd;
    --ink: #17233b;
    --muted: #5b6b84;
    --border: #e3e9f2;
    --border-strong: #cdd8e8;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 2px 10px rgba(22, 45, 86, .06);
    --shadow-lg: 0 14px 40px rgba(22, 45, 86, .16);

    /* Colores de anillas de diana */
    --target-yellow: #ffec3a;
    --target-red: #f44236;
    --target-blue: #2099f6;
    --target-black: #212121;
    --target-white: #f5f8f5;
    --target-miss: #6b7280;

    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-head: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --safe-top: env(safe-area-inset-top, 0px);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    line-height: 1.55;
    padding-top: var(--safe-top);
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 1rem; color: var(--ink); }
h1, h2, h3, h4, h5, h6 { font-family: var(--font-head); line-height: 1.25; }
a { color: var(--primary); }
a:hover { text-decoration: none; }

[data-icon] svg, svg.icon-inline { width: 1em; height: 1em; vertical-align: -0.15em; }
[data-icon] { display: inline-flex; align-items: center; gap: .45em; }
[data-icon]:empty::before { content: "\00a0"; }

/* ---------- Layout ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 16px 16px 96px; }
.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.row > [class*="col"] { padding: 0 8px; }
.col { flex: 1 1 0; min-width: 0; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }
@media (min-width: 768px) {
    .col-md-1 { flex: 0 0 8.3333%; max-width: 8.3333%; }
    .col-md-2 { flex: 0 0 16.6666%; max-width: 16.6666%; }
    .col-md-3 { flex: 0 0 25%; max-width: 25%; }
    .col-md-4 { flex: 0 0 33.3333%; max-width: 33.3333%; }
    .col-md-6 { flex: 0 0 50%; max-width: 50%; }
}

.d-none { display: none !important; }
.hidden { display: none !important; }
.d-flex { display: flex; }
.d-grid { display: grid; }
.flex-column { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-grow { flex: 1 1 auto; }
.flex-grow-1 { flex-grow: 1 !important; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.align-center { align-items: center; }
.align-start { align-items: flex-start; }
.text-center { text-align: center; }
.text-end { text-align: right; }
.text-start { text-align: left; }
.w-100 { width: 100%; }
.mx-auto { margin-left: auto; margin-right: auto; }

.gap-sm { gap: .5rem; }
.gap-2 { gap: .75rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }
.m-0 { margin: 0; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .35rem; }
.mb-2 { margin-bottom: .6rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: .35rem; }
.mt-2 { margin-top: .6rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.ms-auto { margin-left: auto; }
.me-2 { margin-right: .6rem; }
.me-1 { margin-right: .35rem; }
.p-0 { padding: 0; }
.p-2 { padding: .6rem; }
.p-3 { padding: 1rem; }
.p-4 { padding: 1.5rem; }
.px-2 { padding-left: .6rem; padding-right: .6rem; }
.px-3 { padding-left: 1rem; padding-right: 1rem; }
.px-4 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-2 { padding-top: .6rem; padding-bottom: .6rem; }
.py-3 { padding-top: 1rem; padding-bottom: 1rem; }
.py-5 { padding-top: 2.5rem; padding-bottom: 2.5rem; }
.pb-4 { padding-bottom: 1.5rem; }
.pt-3 { padding-top: 1rem; }

.form-max { max-width: 800px; }
.select-auto { max-width: 320px; }

/* ---------- Colores de texto ---------- */
.muted { color: var(--muted) !important; }
.c-primary { color: var(--primary) !important; }
.c-success { color: var(--success) !important; }
.c-warning { color: var(--warning) !important; }
.c-danger { color: var(--danger) !important; }
.bg-alt { background: var(--bg-alt) !important; }
.bg-warning { background: var(--warning); }
.fw-bold { font-weight: 700; }
.small { font-size: .85rem; }
.fs-4 { font-size: 1.4rem; }

/* ---------- Barra superior ---------- */
.topbar {
    position: sticky; top: 0; z-index: 1020;
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 10px rgba(1, 60, 150, .25);
}
.topbar-inner {
    max-width: 1080px; margin: 0 auto; padding: 10px 16px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff !important; text-decoration: none; font-weight: 800; font-size: 1.25rem; letter-spacing: .4px; }
.brand-logo { border-radius: 8px; background: #fff; padding: 2px; border: 1px solid var(--border); }
.brand-name { color: #ffcb02; }
.version-tag {
    background: rgba(0,0,0,.25); color: #fff; font-size: .7rem; font-weight: 700;
    border-radius: 10px; padding: 2px 8px; letter-spacing: .4px;
}
.topnav { display: flex; gap: 6px; }
.nav-link {
    color: rgba(255,255,255,.85); text-decoration: none; font-weight: 600; font-size: .9rem;
    padding: 8px 12px; border-radius: 10px; display: inline-flex; align-items: center; gap: 7px;
    transition: background .12s ease;
}
.nav-link:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-link.active { background: rgba(0,0,0,.22); color: #fff; }

/* Botón menú (solo móvil ≤640px) */
.nav-toggle {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 10px;
    background: rgba(255,255,255,.14);
    cursor: pointer;
    padding: 0;
}
.nav-toggle:hover { background: rgba(255,255,255,.24); }
.nav-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: #fff;
    transition: transform .2s ease, opacity .2s ease;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 0; border-radius: 10px; padding: 10px 18px; font-size: .95rem; font-weight: 600;
    cursor: pointer; text-decoration: none; line-height: 1.2;
    transition: filter .12s ease, box-shadow .12s ease, transform .12s ease, background .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(1,96,222,.25); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-outline-secondary { background: #fff; color: var(--muted); border: 1.5px solid var(--border-strong); }
.btn-outline-secondary:hover { background: var(--bg-alt); color: var(--ink); }
    .btn-outline-danger { background: #fff; color: var(--danger); border: 1.5px solid var(--danger); }
    .btn-outline-danger:hover { background: var(--danger); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-dark); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { filter: brightness(1.05); }
.btn-link { background: none; color: var(--primary); font-weight: 600; padding: 6px 10px; }
.btn-link.text-muted { color: var(--muted); }
.btn-link:hover { text-decoration: underline; }
.btn-sm { padding: 7px 13px; font-size: .85rem; border-radius: 9px; }
.btn-lg { padding: 14px 24px; font-size: 1.05rem; border-radius: 12px; }
.icon-only { padding: 10px 12px; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--border-strong);
    background: #fff; color: var(--muted); cursor: pointer; font-size: 1rem;
}
.icon-btn:hover { background: var(--bg-alt); color: var(--primary); }

/* Colores de teclas / rejilla de tanteo */
.btn-red { background: var(--target-red); color: #fff; }
.btn-blue { background: var(--target-blue); color: #fff; }
.btn-dark { background: var(--target-black); color: #fff; }
.btn-light { background: var(--target-white); color: var(--ink); border: 1.5px solid var(--border); }
.btn-miss { background: #6b7280; color: #fff; }

/* ---------- Tarjetas ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-heading { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
.card-body { padding: 16px; }
.card-tab-title { font-weight: 700; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 8px; }

/* ---------- Formularios ---------- */
.field { margin-bottom: 1rem; }
.form-label { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: .35rem; }
.form-control, .form-select {
    display: block; width: 100%; padding: 10px 12px; font-size: .95rem;
    border: 1.5px solid var(--border-strong); border-radius: 10px; background: #fff;
    transition: border-color .12s ease, box-shadow .12s ease;
}
.form-control:focus, .form-select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(1,96,222,.15);
}
.input-group { display: flex; }
.input-group .btn { border-radius: 10px 0 0 10px; flex-shrink: 0; }
.input-group .form-control { border-radius: 0 10px 10px 0; }

/* ---------- Segmented control ---------- */
.segmented { display: inline-flex; background: #eef1f7; border-radius: 11px; padding: 4px; gap: 4px; }
.seg-btn {
    border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: .88rem;
    padding: 8px 16px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
    transition: background .12s ease, color .12s ease;
}
.seg-btn.active { background: #fff; color: var(--primary); box-shadow: 0 2px 6px rgba(22,45,86,.12); }

/* ---------- Tablas ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
/* :where() deja especificidad (0,0,1) para que utilidades como .text-end
   o .text-center puedan alinear titulares de columnas concretas. */
:where(.table) th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--bg-alt); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* ---------- Listas ---------- */
.list-group { list-style: none; }
.list-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 16px; cursor: pointer;
    background: var(--bg-alt); border: 0; border-radius: 10px;
    transition: background .12s ease;
}
.list-item + .list-item { margin-top: 6px; }
.list-item:hover { background: #e7ecf4; }
.list-item.disabled { cursor: default; }
.list-item.disabled:hover { background: var(--bg-alt); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .72rem; font-weight: 700; line-height: 1.4; }
.badge-success { background: #e5f6ec; color: var(--success-dark); }
.badge-info { background: var(--primary-soft); color: var(--primary-dark); }
.badge-light { background: var(--bg-alt); color: var(--muted); border: 1px solid var(--border); }

/* ---------- Estados vacíos / carga ---------- */
.empty-state { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty-icon { font-size: 4rem; opacity: .18; display: block; margin-bottom: 1rem; }
.spin { display: inline-block; width: 1.4em; height: 1.4em; border: 3px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: tr-spin .8s linear infinite; margin-right: .5em; vertical-align: -.3em; }
@keyframes tr-spin { to { transform: rotate(360deg); } }

/* ---------- Modales ---------- */
.modal { display: none; position: fixed; inset: 0; z-index: 2000; align-items: center; justify-content: center; padding: 16px; }
.modal.show { display: flex; }
.modal-overlay { position: absolute; inset: 0; background: rgba(15, 26, 46, .55); backdrop-filter: blur(2px); animation: tr-fade .15s ease; }
.modal-box {
    position: relative; background: #fff; border-radius: var(--radius); width: 100%; max-width: 480px;
    max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
    animation: tr-pop .18s cubic-bezier(.2,.9,.3,1.2);
}
.modal-sm { max-width: 360px; }
.modal-lg { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border); }
.modal-foot.center { justify-content: center; }
.modal-x { background: none; border: 0; font-size: 1.1rem; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; }
.modal-x:hover { background: var(--bg-alt); color: var(--ink); }
.modal-body > .modal-ok, .modal-body > .modal-flag, .modal-body > .modal-warn, .modal-body > .modal-info, .modal-body > .modal-exit {
    font-size: 3.6rem; display: inline-block; margin-bottom: 1rem;
}
.modal-ok { color: var(--success); }
.modal-flag { color: var(--success); }
.modal-warn { color: var(--warning); }
.modal-info { color: var(--info); }
.modal-exit { color: var(--danger); }
@keyframes tr-fade { from { opacity: 0; } }
@keyframes tr-pop { from { opacity: 0; transform: scale(.94) translateY(8px); } }

/* ---------- Toast ---------- */
.toast-root { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); }
.toast {
    background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 16px;
    font-size: .9rem; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center;
    animation: tr-slide .2s ease;
}
.toast.success { background: var(--success-dark); }
.toast.error { background: var(--danger-dark); }
.toast.info { background: var(--primary-dark); }
@keyframes tr-slide { from { opacity: 0; transform: translateY(12px); } }

/* ---------- Buscador ---------- */
.search-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.search-ico { color: var(--muted); font-size: 1rem; }
.search-input { border: 0; box-shadow: none !important; padding-left: 0; }
.search-bar .search-ico { display: inline-flex; }

/* ---------- Rejilla de edición de flecha ---------- */
.edit-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

/* ---------- Caja de ruta PDF ---------- */
.path-box { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 9px; padding: 10px; font-size: .78rem; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; word-break: break-all; text-align: left; }

@media (max-width: 640px) {
    .nav-toggle { display: inline-flex; }
    .topnav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        gap: 2px;
        padding: 8px 16px 14px;
        background: var(--primary);
        box-shadow: 0 12px 24px rgba(1, 60, 150, .25);
    }
    .topnav.open { display: flex; }
    .topnav .nav-link { justify-content: flex-start; padding: 12px; }
    .topnav .nav-link span[data-icon] { display: none; }
    .container { padding-left: 12px; padding-right: 12px; }
}