:root {
    --bg: #f3f4f6;
    --surface: #ffffff;
    --ink: #111318;
    --muted: #667085;
    --line: #e6e8ee;
    --accent: #111318;
    --in: #0f9f6e;
    --in-soft: #e7f8f1;
    --out: #3559e8;
    --out-soft: #eef1ff;
    --danger: #d92d20;
    --danger-soft: #feecec;
    --ok: #067647;
    --ok-soft: #eaf8ef;
    --warn: #b54708;
    --warn-soft: #fff4e5;
    --shadow: 0 10px 30px rgba(16, 24, 40, .06);
    --radius: 18px;
    --radius-sm: 12px;
    --tabbar: 64px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: inherit; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.03em; }
p { margin: 0; }

.app { min-height: 100dvh; }
.sidebar { display: none; }
.shell { min-height: 100dvh; padding-bottom: calc(var(--tabbar) + var(--safe-b) + 18px); }
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(10px + env(safe-area-inset-top)) 16px 12px;
    background: rgba(243, 244, 246, .86);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid transparent;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.global-search {
    display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
    background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 0 10px;
}
.global-search input {
    border: 0; background: transparent; min-height: 40px; padding: 0; flex: 1;
}
.global-search input:focus { outline: none; box-shadow: none; }
.side-search {
    display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
    margin: 0; height: 32px; padding: 0 8px 0 9px;
    background: #171a22; border: 1px solid #2a2f3c; border-radius: 8px; color: #9aa3b2;
}
.side-search input {
    border: 0; background: transparent; min-height: 0; height: 30px; padding: 0;
    flex: 1; min-width: 0; color: #fff; font-size: 12px; line-height: 1;
}
.side-search input:focus { outline: none; box-shadow: none; }
.side-search input::placeholder { color: #8b93a3; }
.side-search .search-ico { width: 12px; height: 12px; opacity: .7; color: #c9d0db; }
.search-ico {
    width: 16px; height: 16px; flex: 0 0 auto; background: currentColor; opacity: .55;
    -webkit-mask: center / contain no-repeat url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.5-3.5'/></svg>");
    mask: center / contain no-repeat url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.5-3.5'/></svg>");
}
.brand-mark {
    width: 36px; height: 36px; border-radius: 11px;
    display: grid; place-items: center;
    background: var(--ink); color: #fff; font-weight: 700;
    font-size: 11px; letter-spacing: -0.04em;
}
.brand-mark.sm { width: 30px; height: 30px; font-size: 14px; border-radius: 9px; }
.brand-logo {
    width: 40px; height: 40px; object-fit: contain; border-radius: 10px;
    background: #fff; flex: 0 0 auto;
}
.brand-logo.lg { width: 72px; height: 72px; border-radius: 16px; margin: 0 auto 8px; }
.logo-row { display: flex; gap: 16px; align-items: center; margin-bottom: 16px; }
.logo-preview {
    width: 88px; height: 88px; border-radius: 18px; background: #f7f8fa;
    display: grid; place-items: center; overflow: hidden; flex: 0 0 auto;
    box-shadow: inset 0 0 0 1px var(--line);
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.section-title { font-size: 15px; margin: 20px 0 10px; }
.notify-lead { margin: -4px 0 12px; }
.print-logo { height: 48px; width: auto; margin-bottom: 8px; }
.main { padding: 8px 16px 24px; max-width: 1100px; margin: 0 auto; }

.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: flex;
    height: calc(var(--tabbar) + var(--safe-b));
    padding-bottom: var(--safe-b);
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
}
.tabbar a {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none;
}
.tabbar a.is-active { color: var(--ink); }

.nav-ico {
    width: 22px; height: 22px; display: block;
    background: currentColor;
    -webkit-mask: center / contain no-repeat;
    mask: center / contain no-repeat;
}
.nav-ico[data-ico="home"] { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'><path d='M4 10.5 12 4l8 6.5V20a1 1 0 0 1-1 1h-5v-6H10v6H5a1 1 0 0 1-1-1z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'><path d='M4 10.5 12 4l8 6.5V20a1 1 0 0 1-1 1h-5v-6H10v6H5a1 1 0 0 1-1-1z'/></svg>"); }
.nav-ico[data-ico="in"] { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'><path d='M12 3v12'/><path d='m7 10 5 5 5-5'/><path d='M5 21h14'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'><path d='M12 3v12'/><path d='m7 10 5 5 5-5'/><path d='M5 21h14'/></svg>"); }
.nav-ico[data-ico="out"] { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'><path d='M12 21V9'/><path d='m7 14 5-5 5 5'/><path d='M5 3h14'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'><path d='M12 21V9'/><path d='m7 14 5-5 5 5'/><path d='M5 3h14'/></svg>"); }
.nav-ico[data-ico="cal"] { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'><rect x='3' y='5' width='18' height='16' rx='2'/><path d='M3 10h18M8 3v4M16 3v4'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'><rect x='3' y='5' width='18' height='16' rx='2'/><path d='M3 10h18M8 3v4M16 3v4'/></svg>"); }
.nav-ico[data-ico="list"] { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'><path d='M8 7h13M8 12h13M8 17h13M3 7h.01M3 12h.01M3 17h.01'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' viewBox='0 0 24 24'><path d='M8 7h13M8 12h13M8 17h13M3 7h.01M3 12h.01M3 17h.01'/></svg>"); }
.nav-ico[data-ico="users"] { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'><path d='M16 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2'/><circle cx='9.5' cy='7' r='3'/><path d='M22 21v-2a4 4 0 0 0-3-3.87M16 4.13a4 4 0 0 1 0 7.75'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'><path d='M16 21v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2'/><circle cx='9.5' cy='7' r='3'/><path d='M22 21v-2a4 4 0 0 0-3-3.87M16 4.13a4 4 0 0 1 0 7.75'/></svg>"); }
.nav-ico[data-ico="gear"] { -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'><circle cx='12' cy='12' r='3'/><path d='M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 0 1-4 0v-.2a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 0 1 0-4h.2a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 0 1 4 0v.2a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.3.7.9 1.2 1.6 1.3H21a2 2 0 0 1 0 4h-.2a1.7 1.7 0 0 0-1.4 1.1z'/></svg>"); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'><circle cx='12' cy='12' r='3'/><path d='M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 0 1-4 0v-.2a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 0 1 0-4h.2a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 1 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 0 1 4 0v.2a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.3.7.9 1.2 1.6 1.3H21a2 2 0 0 1 0 4h-.2a1.7 1.7 0 0 0-1.4 1.1z'/></svg>"); }

.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center;
    background: #eceef3; font-weight: 700; font-size: 13px; text-decoration: none;
}
.icon-btn {
    width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto;
    display: grid; place-items: center;
    background: #fff; color: var(--ink); text-decoration: none;
    box-shadow: var(--shadow);
}
.icon-btn.is-active { background: var(--ink); color: #fff; }
.side-config { display: none; }

.muted { color: var(--muted); }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.center { text-align: center; }
.empty { padding: 28px 8px; color: var(--muted); text-align: center; }

.flash {
    padding: 12px 14px; border-radius: 14px; margin-bottom: 14px; font-size: 14px; font-weight: 500;
}
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--danger-soft); color: var(--danger); }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 46px; padding: 0 16px; border-radius: 12px;
    border: 0; text-decoration: none; font-weight: 650; cursor: pointer;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-ghost { background: #fff; border: 1px solid var(--line); }
.btn-in { background: var(--in); color: #fff; }
.btn-out { background: var(--out); color: #fff; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.btn-block { width: 100%; }

.hero { display: flex; flex-direction: column; gap: 16px; margin: 6px 0 18px; }
.hero h1 { font-size: 28px; }
.hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hero-actions .btn { min-height: 52px; font-size: 16px; }

.search-panel { margin-bottom: 16px; }
.search-box {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface); border-radius: 16px; padding: 8px 8px 8px 14px;
    box-shadow: var(--shadow); margin-bottom: 10px;
}
.search-box input { border: 0; background: transparent; min-height: 44px; padding: 0; flex: 1; }
.search-box input:focus { outline: none; box-shadow: none; }
.search-box .btn { min-height: 44px; padding: 0 16px; flex: 0 0 auto; }
.chip-row {
    display: flex; gap: 8px; overflow-x: auto; padding: 0 0 10px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
    flex: 0 0 auto; padding: 8px 14px; border-radius: 999px;
    background: var(--surface); color: var(--ink); text-decoration: none;
    font-size: 13px; font-weight: 700; box-shadow: var(--shadow);
}
.chip.is-active { background: var(--ink); color: #fff; }
.filter-more {
    background: var(--surface); border-radius: 16px; padding: 4px 14px;
    box-shadow: var(--shadow);
}
.filter-more summary {
    cursor: pointer; font-weight: 700; font-size: 13px; padding: 12px 0; list-style: none;
}
.filter-more summary::-webkit-details-marker { display: none; }
.filter-grid { display: grid; gap: 10px; padding-bottom: 14px; }
.filter-more-actions { display: flex; gap: 8px; }
.filter-more-actions .btn { flex: 1; }

.week-card {
    background: var(--surface); border-radius: 22px; padding: 16px 12px 12px;
    box-shadow: var(--shadow); margin-bottom: 16px;
}
.week-card-head {
    display: flex; align-items: end; justify-content: space-between; gap: 12px;
    padding: 0 6px 12px;
}
.week-card-head h2 { font-size: 20px; }
.week-card-head a { color: var(--muted); font-size: 13px; font-weight: 700; text-decoration: none; }
.week-strip {
    display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px;
}
.week-day {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 10px 2px 10px; border-radius: 16px; text-decoration: none;
    background: #f7f8fa;
}
.week-day.is-weekend { background: transparent; }
.week-day.has-ops { background: #fff; box-shadow: inset 0 0 0 1px var(--line); }
.week-dow { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.week-num {
    width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center; font-size: 15px; font-weight: 750;
}
.week-day.is-today { background: #111318; }
.week-day.is-today .week-dow, .week-day.is-today .week-count { color: #d0d5dd; }
.week-day.is-today .week-num { background: #fff; color: #111318; }
.week-count { font-size: 11px; font-weight: 750; color: var(--ink); min-height: 14px; }
.week-count.is-empty { color: #d0d5dd; font-weight: 600; }
.week-bars { display: flex; gap: 3px; height: 4px; width: 18px; }
.week-bars i { flex: 1; border-radius: 99px; display: block; }
.week-bars .in { background: var(--in); }
.week-bars .out { background: var(--out); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: #d0d5dd; }
.dot.in { background: var(--in); }
.dot.out { background: var(--out); }
.dot.empty { background: #e5e7eb; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat {
    background: var(--surface); border-radius: var(--radius); padding: 16px;
    box-shadow: var(--shadow);
}
.stat span { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat strong { display: block; font-size: 28px; margin: 6px 0 2px; letter-spacing: -0.04em; }
.stat small { color: var(--muted); }

.panel {
    background: var(--surface); border-radius: var(--radius); padding: 16px;
    box-shadow: var(--shadow); margin-bottom: 16px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { font-size: 16px; }
.panel-head a { color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; }
.export-links { display: flex; align-items: center; gap: 12px; }

.op-list { list-style: none; margin: 0; padding: 0; }
.op-list li + li { border-top: 1px solid var(--line); }
.op-row {
    display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
    padding: 12px 0; text-decoration: none;
}
.op-main { min-width: 0; }
.op-main strong, .op-main small, .op-meta small { display: block; }
.op-main small, .op-meta small { color: var(--muted); font-size: 12px; margin-top: 3px; }
.op-meta { text-align: right; font-size: 13px; font-weight: 600; white-space: nowrap; }

.badge {
    display: inline-flex; align-items: center; border-radius: 999px;
    padding: 4px 9px; font-size: 11px; font-weight: 700; letter-spacing: .02em;
}
.badge-recibido { background: var(--in-soft); color: var(--in); }
.badge-despacho { background: var(--out-soft); color: var(--out); }
.badge-void { background: #f2f4f7; color: var(--muted); }

.form-card, .filters {
    background: var(--surface); border-radius: var(--radius); padding: 18px;
    box-shadow: var(--shadow); margin-bottom: 16px;
}
.form-head { margin-bottom: 16px; }
.form-head h1 { font-size: 22px; margin: 8px 0 6px; }
.stack { display: grid; gap: 12px; }
.grid-2 { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 650; }
.readonly-wrap { display: grid; gap: 6px; font-size: 13px; font-weight: 650; }
.readonly-field {
    margin: 0; min-height: 48px; padding: 12px 14px;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: #eef0f4; color: #3f4654; display: flex; align-items: center;
    font-weight: 600; pointer-events: none; user-select: none;
}
input, select, textarea {
    width: 100%; min-height: 48px; padding: 12px 14px;
    border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fbfbfc;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: 2px solid #11131833; border-color: var(--ink); background: #fff;
}
.firma-block { margin-top: 4px; }
.firma-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.firma-head strong { font-size: 13px; }
.firma-head .btn { min-height: 36px; padding: 0 12px; }
.firma-pad {
    position: relative; border: 1.5px dashed #c5c9d3; border-radius: 16px;
    background:
        linear-gradient(#fff, #fff) padding-box,
        repeating-linear-gradient(-45deg, #f3f4f6, #f3f4f6 8px, #fafafa 8px, #fafafa 16px);
    background-color: #fff;
    overflow: hidden;
}
.firma-pad canvas {
    display: block; width: 100%; height: 240px;
    touch-action: none; cursor: crosshair;
}
@media (pointer: coarse) {
    .firma-pad canvas { height: 280px; }
}
.hint { font-weight: 500; color: var(--muted); }
.firma-preview {
    display: block; max-width: 420px; width: 100%; height: auto;
    margin-top: 8px; background: #fff; border-radius: 12px; border: 1px solid var(--line);
}
.print-firma { max-width: 280px; height: auto; border: 1px solid #e5e7eb; }
.full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check input { width: 18px; height: 18px; min-height: 0; }
.form-actions {
    display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px;
    position: sticky; bottom: calc(var(--tabbar) + var(--safe-b) + 8px);
}
.form-actions .btn { flex: 1; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.inline-form input { min-height: 44px; }

.detail-head { display: grid; gap: 12px; margin-bottom: 16px; }
.detail-head h1 { font-size: 26px; margin-top: 8px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-actions form { margin: 0; }
.facts {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
    background: var(--surface); border-radius: var(--radius); padding: 16px;
    box-shadow: var(--shadow); margin-bottom: 16px;
}
.facts div { padding: 8px 0; }
.facts span { display: block; color: var(--muted); font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.facts strong { font-size: 15px; font-weight: 650; }

.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; height: 140px; object-fit: cover; border-radius: 12px; }
.gallery figcaption { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 6px; }
.gallery button { border: 0; background: none; color: var(--danger); font-weight: 700; cursor: pointer; }

.notes { list-style: none; margin: 0 0 16px; padding: 0; }
.notes li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.notes header { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.notes time { color: var(--muted); font-size: 12px; }

.filters { display: grid; gap: 8px; }
.pager { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.pager a {
    min-width: 36px; height: 36px; display: grid; place-items: center;
    border-radius: 10px; background: #f2f4f7; text-decoration: none; font-weight: 700;
}
.pager a.is-active { background: var(--ink); color: #fff; }

.cal-page { display: grid; gap: 14px; }
.cal-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.cal-head-main { min-width: 0; flex: 1; }
.cal-nav-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-title { text-align: center; }
.cal-title h1 { font-size: 28px; line-height: 1; }
.cal-title span { display: block; margin-top: 4px; color: var(--muted); font-weight: 650; font-size: 13px; }
.cal-kicker { margin: 8px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.cal-nav {
    width: 44px; height: 44px; border-radius: 14px; flex: 0 0 auto;
    display: grid; place-items: center;
    background: var(--surface); box-shadow: var(--shadow);
    text-decoration: none; font-size: 22px; font-weight: 600;
}
.cal-today-btn { min-height: 44px; padding: 0 18px; }

.cal-summary {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.cal-summary article {
    background: var(--surface); border-radius: 16px; padding: 14px 14px 12px;
    box-shadow: var(--shadow);
}
.cal-summary span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.cal-summary strong { display: block; margin-top: 6px; font-size: 22px; letter-spacing: -.03em; }
.cal-summary.compact { grid-template-columns: repeat(3, 1fr); }

.cal-board {
    background: var(--surface); border-radius: 22px; padding: 14px 10px 12px;
    box-shadow: var(--shadow);
}
.cal-legend {
    display: flex; justify-content: center; gap: 16px; margin-bottom: 10px;
    font-size: 12px; font-weight: 650; color: var(--muted);
}
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-dow {
    text-align: center; font-size: 11px; font-weight: 700; color: var(--muted);
    padding: 4px 0 8px; letter-spacing: .04em; text-transform: uppercase;
}
.cal-dow.is-weekend { color: #98a2b3; }
.cal-cell {
    min-height: 58px; border-radius: 12px; padding: 6px 4px 8px;
    text-decoration: none; background: #f7f8fa;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    transition: background .15s ease, transform .15s ease;
}
.cal-cell.has-ops { background: #fff; box-shadow: inset 0 0 0 1px var(--line); }
.cal-cell.is-weekend { background: #f3f4f6; }
.cal-cell.is-out { background: transparent; opacity: .42; }
.cal-cell.is-today { background: #111318; color: #fff; box-shadow: none; }
.cal-cell.is-today .cal-chip { filter: saturate(1.1); }
.cal-cell.is-today .cal-bultos { color: #d0d5dd; }
.cal-num {
    width: 26px; height: 26px; border-radius: 999px;
    display: grid; place-items: center; font-weight: 750; font-size: 13px;
}
.cal-cell.is-today .cal-num { background: #fff; color: #111318; }
.cal-events { display: none; width: 100%; gap: 3px; }
.cal-chip {
    display: flex; align-items: center; justify-content: space-between; gap: 4px;
    border-radius: 7px; padding: 3px 6px; font-size: 10px; font-weight: 700;
}
.cal-chip.in { background: var(--in-soft); color: var(--in); }
.cal-chip.out { background: var(--out-soft); color: var(--out); }
.cal-bars { display: flex; gap: 3px; width: 70%; height: 4px; }
.cal-bars i { flex: 1; border-radius: 99px; display: block; }
.cal-bars .in { background: var(--in); }
.cal-bars .out { background: var(--out); }
.cal-bultos { display: none; font-size: 10px; font-weight: 650; color: var(--muted); }

.day-page { display: grid; gap: 14px; }
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.day-title { text-align: center; min-width: 0; }
.day-title h1 { font-size: 22px; line-height: 1.15; }
.day-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.day-actions .btn { flex: 1; min-width: 110px; }
.day-empty {
    background: var(--surface); border-radius: 20px; padding: 36px 18px;
    text-align: center; box-shadow: var(--shadow); color: var(--muted);
}
.day-empty strong { display: block; color: var(--ink); margin-bottom: 6px; font-size: 16px; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 12px; border-left: 2px solid #eceef3; }
.timeline-item { position: relative; display: grid; grid-template-columns: 54px 1fr; gap: 12px; padding: 0 0 16px 12px; }
.timeline-item::before {
    content: ""; position: absolute; left: -7px; top: 8px; width: 12px; height: 12px;
    border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 4px var(--bg);
}
.timeline-item:has(.badge-recibido)::before { background: var(--in); }
.timeline-item:has(.badge-despacho)::before { background: var(--out); }
.timeline-item time { font-size: 13px; font-weight: 750; padding-top: 10px; }
.timeline-card {
    display: block; background: var(--surface); border-radius: 16px; padding: 14px;
    text-decoration: none; box-shadow: var(--shadow);
}
.timeline-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.timeline-card p, .timeline-card small { color: var(--muted); margin-top: 6px; display: block; }
.timeline-item.is-void { opacity: .55; }

.table-wrap { overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.table th { color: var(--muted); font-weight: 650; }

.auth-body {
    min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
    background:
        radial-gradient(1200px 500px at 10% -10%, #dbe4ff 0%, transparent 50%),
        radial-gradient(900px 400px at 100% 0%, #d9f3e8 0%, transparent 46%),
        var(--bg);
}
.auth-wrap { width: min(420px, 100%); }
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand h1 { font-size: 24px; margin: 10px 0 4px; line-height: 1.2; }
.auth-brand .brand-mark { margin: 0 auto 8px; width: 48px; height: 48px; font-size: 14px; }
.auth-card { background: var(--surface); border-radius: 24px; padding: 22px; box-shadow: var(--shadow); }
.auth-card h2 { font-size: 22px; margin-bottom: 6px; }
.auth-card a { color: var(--out); font-weight: 650; text-decoration: none; }

.print-body { background: #fff; }
.print-toolbar { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; }
.print-sheet { max-width: 900px; margin: 0 auto; padding: 24px; }
.print-head { display: flex; justify-content: space-between; gap: 16px; border-bottom: 2px solid #111; padding-bottom: 12px; margin-bottom: 16px; }
.print-head span, .print-num span { display: block; color: #667085; font-size: 12px; }
.print-num b { font-size: 22px; }
.print-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; }
.print-table th, .print-table td { border: 1px solid #e5e7eb; padding: 8px 10px; text-align: left; font-size: 13px; vertical-align: top; }
.print-table th { width: 18%; background: #f8fafc; }
.print-gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.print-foot { margin-top: 24px; font-size: 12px; color: #667085; }

@media (min-width: 900px) {
    .tabbar, .topbar { display: none; }
    .app { display: grid; grid-template-columns: 240px 1fr; }
    .sidebar {
        display: flex; flex-direction: column; gap: 14px;
        position: sticky; top: 0; height: 100dvh; padding: 22px 16px;
        background: #0b0d12; color: #fff;
    }
    .brand { display: flex; gap: 10px; align-items: center; text-decoration: none; }
    .brand small { display: block; color: #9aa3b2; font-size: 12px; font-weight: 500; }
    .side-nav { display: grid; gap: 4px; }
    .side-nav a {
        display: flex; align-items: center; gap: 10px;
        padding: 10px 12px; border-radius: 12px; text-decoration: none; color: #c9d0db; font-weight: 600;
    }
    .side-nav a.is-active { background: #171a22; color: #fff; }
    .side-config {
        display: flex; align-items: center; gap: 10px; margin-top: auto;
        padding: 10px 12px; border-radius: 12px; text-decoration: none;
        color: #c9d0db; font-weight: 600; background: #171a22; border: 1px solid #2a2f3c;
    }
    .side-config.is-active, .side-config:hover { color: #fff; background: #222633; }
    .side-user {
        margin-top: 8px; display: flex; gap: 10px; align-items: center;
        padding: 10px; border-radius: 14px; text-decoration: none; background: #171a22;
    }
    .side-user small { display: block; color: #9aa3b2; }
    .side-user .avatar { background: #2a2f3c; color: #fff; }
    .shell { padding: 0; }
    .main { padding: 28px 32px 48px; }
    .grid-2 { grid-template-columns: 1fr 1fr; }
    .stats { grid-template-columns: repeat(4, 1fr); }
    .form-actions { position: static; }
    .form-actions .btn { flex: 0 0 auto; min-width: 140px; }
    .hero { flex-direction: row; justify-content: space-between; align-items: end; }
    .hero-actions { width: 280px; }
    .week-card { padding: 18px; }
    .week-strip { gap: 8px; }
    .week-day { padding: 12px 4px 14px; border-radius: 18px; }
    .week-day:hover { background: #fff; transform: translateY(-1px); }
    .week-day.is-today:hover { background: #111318; }
    .filter-grid { grid-template-columns: 1fr 1fr; }
    .filter-more-actions { grid-column: 1 / -1; }
    .search-box .btn { min-width: 120px; }
    .cal-summary { grid-template-columns: repeat(4, 1fr); }
    .cal-head { align-items: end; }
    .cal-nav-row { justify-content: flex-start; gap: 14px; }
    .cal-title { text-align: left; }
    .cal-kicker { text-align: left; }
    .cal-board { padding: 18px; }
    .cal-grid { gap: 8px; }
    .cal-cell {
        min-height: 108px; align-items: flex-start; padding: 10px;
        border-radius: 16px;
    }
    .cal-cell:hover { transform: translateY(-1px); background: #fff; }
    .cal-cell.is-today:hover { background: #111318; }
    .cal-events { display: grid; }
    .cal-bars { display: none; }
    .cal-bultos { display: block; }
    .timeline-item { grid-template-columns: 64px 1fr; }
    .detail-head { grid-template-columns: 1fr auto; align-items: start; }
}

@media (max-width: 720px) {
    .op-row { grid-template-columns: 1fr; gap: 6px; }
    .op-meta { text-align: left; }
    .table thead { display: none; }
    .table tr { display: grid; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
    .table td { border: 0; padding: 0; display: flex; justify-content: space-between; gap: 12px; }
    .table td::before { content: attr(data-label); color: var(--muted); font-weight: 650; }
    .table td.row-actions { justify-content: flex-end; }
    .table td.row-actions::before { display: none; }
}

.modal-overlay {
    position: fixed; inset: 0; z-index: 80;
    background: rgba(11, 13, 18, .55);
    display: grid; place-items: end center;
    padding: 16px 12px calc(16px + var(--safe-b));
}
.modal-overlay[hidden] { display: none; }
.modal {
    width: min(520px, 100%); max-height: min(88dvh, 760px);
    overflow: auto; background: #fff; border-radius: 20px 20px 16px 16px;
    padding: 18px 18px 16px; box-shadow: 0 24px 60px rgba(16, 24, 40, .25);
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.modal-head h2 { font-size: 20px; margin-top: 2px; }
.modal .icon-btn { box-shadow: none; border: 1px solid var(--line); font-size: 22px; line-height: 1; }
.perm-access {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px; border: 1px solid var(--line); border-radius: 14px;
    background: #f7f8fa; margin-bottom: 14px; font-weight: 650;
}
.perm-access input { width: 18px; height: 18px; min-height: 0; margin-top: 2px; flex: 0 0 auto; }
.perm-access small { display: block; font-weight: 500; color: var(--muted); margin-top: 2px; }
.perm-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.perm-presets span { font-size: 12px; font-weight: 700; color: var(--muted); }
.perm-presets button {
    border: 1px solid var(--line); background: #fff; border-radius: 999px;
    min-height: 34px; padding: 0 12px; font-size: 12px; font-weight: 650; cursor: pointer;
}
.perm-presets button.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.perm-group { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px 12px; margin: 0 0 10px; }
.perm-group legend { font-size: 12px; font-weight: 700; color: var(--muted); padding: 0 6px; }
.perm-group .check { margin-top: 8px; }
@media (min-width: 900px) {
    .modal-overlay { place-items: center; padding: 24px; }
    .modal { border-radius: 20px; }
}

@media print {
    .no-print, .print-toolbar { display: none !important; }
    .print-sheet { padding: 0; }
    .print-gallery img { max-height: 220px; object-fit: contain; }
}
