:root {
  color-scheme: light;
  --navy: #102d62;
  --blue: #2459b9;
  --blue-light: #eaf0ff;
  --ink: #172033;
  --muted: #6f7888;
  --line: #e4e9f1;
  --surface: #ffffff;
  --background: #f3f6fb;
  --green: #1c9a70;
  --teal: #1ca7a8;
  --amber: #eaa033;
  --danger: #bd3e4b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; max-width: 100%; overflow-x: hidden; background: var(--background); }

body {
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 80% -10%, rgba(77, 121, 212, 0.13), transparent 34rem),
    var(--background);
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .42; }

.boot-screen, .empty-page {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1rem;
  color: var(--muted);
}

.brand-mark {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  color: white;
  font-weight: 900;
  letter-spacing: -.08em;
  padding-right: .14em;
  background: linear-gradient(145deg, #2b69db, #102d62);
  box-shadow: 0 14px 32px rgba(16, 45, 98, .22);
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  font-size: .88rem;
  box-shadow: none;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(16, 45, 98, .97), rgba(37, 89, 185, .84)),
    radial-gradient(circle at top right, #7fa6f6, #102d62);
}

.login-card {
  width: min(100%, 440px);
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 28px;
  padding: 34px;
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 36px 80px rgba(6, 19, 44, .35);
}

.login-brand, .sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand strong, .sidebar-brand strong { display: block; font-size: 1.05rem; }
.login-brand span, .sidebar-brand span { display: block; margin-top: 2px; color: var(--muted); font-size: .7rem; letter-spacing: .09em; }
.login-copy { margin: 38px 0 28px; }
.login-copy h1 { margin: 10px 0; font-size: clamp(2rem, 8vw, 2.7rem); line-height: 1.03; letter-spacing: -.05em; }
.login-copy p { margin: 0; color: var(--muted); line-height: 1.55; }
.eyebrow { color: #738098; font-size: .68rem; font-weight: 800; letter-spacing: .16em; }

.login-form { display: grid; gap: 18px; }
.login-form label { display: grid; gap: 8px; color: #4a5364; font-size: .82rem; font-weight: 700; }
.login-form input {
  width: 100%;
  border: 1px solid #d7deea;
  border-radius: 13px;
  padding: 14px 15px;
  color: var(--ink);
  outline: none;
  background: #fbfcff;
  transition: border-color .2s, box-shadow .2s;
}
.login-form input:focus { border-color: #4c79d4; box-shadow: 0 0 0 4px rgba(76, 121, 212, .13); }
.form-error { margin: -4px 0 0; padding: 11px 13px; border-radius: 10px; color: #8c2633; background: #ffedf0; font-size: .82rem; }
.primary-button, .secondary-button, .ghost-button {
  border: 0;
  border-radius: 12px;
  padding: 13px 17px;
  font-weight: 800;
}
.primary-button { color: white; background: linear-gradient(135deg, #2c69dc, #173e83); box-shadow: 0 12px 24px rgba(36, 89, 185, .22); }
.secondary-button { color: white; background: var(--blue); }
.ghost-button { color: #5f6a7b; background: #e9edf4; }
.login-security { margin: 22px 0 0; color: #8a93a2; font-size: .72rem; line-height: 1.5; text-align: center; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 30px 23px;
  color: white;
  background:
    radial-gradient(circle at 0 100%, rgba(75, 126, 230, .42), transparent 45%),
    linear-gradient(180deg, #12346e, #0a2450);
}
.sidebar .sidebar-brand span { color: #9fb4dd; }
.sidebar nav { display: grid; gap: 8px; margin-top: 54px; }
.sidebar nav button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 13px 14px;
  color: #afc1e4;
  text-align: left;
  background: transparent;
}
.sidebar nav button span { width: 22px; font-size: 1.2rem; text-align: center; }
.sidebar nav button:hover, .sidebar nav button.active { color: white; background: rgba(255, 255, 255, .12); }
.sidebar-footer { margin-top: auto; padding: 15px; border: 1px solid rgba(255,255,255,.12); border-radius: 13px; background: rgba(0,0,0,.08); }
.sidebar-footer span, .sidebar-footer strong { display: block; }
.sidebar-footer span { color: #92a8d2; font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; }
.sidebar-footer strong { margin-top: 6px; overflow: hidden; font-size: .76rem; text-overflow: ellipsis; }

.dashboard { min-width: 0; padding: 42px clamp(24px, 4vw, 60px) 30px; }
.mobile-header { display: none; }
.dashboard-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.dashboard-header h1 { margin: 7px 0 3px; font-size: clamp(2rem, 4vw, 2.9rem); letter-spacing: -.05em; }
.dashboard-header p { margin: 0; color: var(--muted); }
.eyebrow.online { display: flex; align-items: center; gap: 7px; }
.eyebrow.online i { width: 7px; height: 7px; border-radius: 50%; background: #33b785; box-shadow: 0 0 0 4px rgba(51,183,133,.12); }
.header-actions { display: flex; gap: 8px; }

.cycle-toolbar { display: flex; align-items: center; gap: 12px; margin: 32px 0 23px; }
.cycle-toolbar > div { min-width: 220px; display: grid; gap: 3px; padding: 10px 15px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.75); }
.cycle-toolbar > div span { color: #7a8494; font-size: .64rem; text-transform: uppercase; letter-spacing: .12em; }
.cycle-toolbar > div strong { font-size: .82rem; }
.round-button, .icon-button {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  color: #5f6b7d;
  background: white;
}
.round-button { width: 38px; height: 38px; border-radius: 50%; font-size: 1.4rem; }
.icon-button { width: 38px; height: 38px; border-radius: 11px; font-size: 1.2rem; }
.verified-badge { margin-left: auto; color: #47725f; font-size: .72rem; font-weight: 700; }
.verified-badge.pending { color: #9b712c; }

.summary-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.summary-card {
  position: relative;
  min-height: 137px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 20px;
  background: rgba(255,255,255,.86);
  box-shadow: 0 14px 36px rgba(31,55,94,.05);
}
.summary-card::after { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg, #6f96e9, transparent); }
.summary-card.profit { background: linear-gradient(145deg, #f1fbf6, #fff); }
.summary-card.profit::after { background: linear-gradient(90deg, #3bb481, transparent); }
.summary-card span { color: #718097; font-size: .63rem; font-weight: 800; letter-spacing: .12em; }
.summary-card strong { margin: 13px 0 7px; font-size: clamp(1.28rem, 2.1vw, 1.75rem); letter-spacing: -.035em; }
.summary-card small { color: #8290a4; font-size: .68rem; line-height: 1.4; }

.tabs { display: flex; gap: 28px; margin-top: 24px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-bottom: 2px solid transparent; padding: 13px 1px 12px; color: #7b8595; background: transparent; font-size: .8rem; }
.tabs button.active { border-bottom-color: var(--navy); color: var(--ink); font-weight: 800; }
.tab-content { margin-top: 20px; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 18px; }
.panel-card { border: 1px solid var(--line); border-radius: 18px; padding: 24px; background: rgba(255,255,255,.9); box-shadow: 0 16px 40px rgba(31,55,94,.045); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.section-heading h2 { margin: 6px 0 0; font-size: 1.15rem; letter-spacing: -.025em; }
.accumulated { display: grid; justify-items: end; }
.accumulated span { color: #8b94a2; font-size: .58rem; letter-spacing: .12em; }
.accumulated strong { margin-top: 5px; color: var(--green); font-size: 1.25rem; }

.profit-visual { height: 190px; display: flex; align-items: end; justify-content: center; margin: 20px 0 5px; border-bottom: 1px solid #dfe5ef; background: repeating-linear-gradient(to top, transparent 0, transparent 46px, #edf1f6 47px); }
.profit-bar { width: 88px; height: var(--profit-height); min-height: 35px; position: relative; border-radius: 10px 10px 0 0; background: linear-gradient(180deg, #48c58e, #21976b); box-shadow: 0 10px 24px rgba(33,151,107,.2); }
.profit-bar span { position: absolute; top: -25px; left: 50%; transform: translateX(-50%); font-size: .72rem; font-weight: 800; white-space: nowrap; }
.metric-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--line); }
.metric-strip > div { display: grid; gap: 5px; padding: 13px; background: #fbfcfe; }
.metric-strip span { color: #7e899a; font-size: .66rem; }
.metric-strip strong { font-size: .9rem; }

.donut-wrap { display: grid; justify-items: center; gap: 26px; margin-top: 27px; }
.donut { width: 170px; height: 170px; display: grid; place-items: center; border-radius: 50%; }
.donut > div { width: 104px; height: 104px; display: grid; place-content: center; justify-items: center; border-radius: 50%; background: white; box-shadow: inset 0 0 0 1px #edf0f5; }
.donut span { color: #8a94a5; font-size: .55rem; letter-spacing: .13em; }
.donut strong { margin-top: 4px; font-size: .95rem; }
.legend { width: 100%; display: grid; gap: 10px; }
.legend > div { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto; align-items: center; gap: 9px; font-size: .72rem; }
.legend i { width: 8px; height: 8px; border-radius: 3px; }
.legend span { color: #707a8a; }
.legend strong { font-size: .7rem; }

.cash-card { margin-top: 18px; }
.cash-equation { display: grid; grid-template-columns: repeat(3, minmax(130px, 1fr)); align-items: center; gap: 10px; margin-top: 20px; }
.cash-equation > div { display: grid; gap: 6px; min-height: 76px; align-content: center; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: #fafcff; }
.cash-equation > div span { color: #798496; font-size: .65rem; }
.cash-equation > div strong { font-size: .88rem; }
.cash-equation > b { display: none; }
.cash-equation .result { border-color: #bce3d1; background: #effaf4; }
.cash-equation .result strong { color: var(--green); }
.late-payment-note { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 14px; padding: 13px 15px; border-radius: 11px; color: #536176; background: #f2f5fa; font-size: .72rem; }
.late-payment-note strong { color: #294f9f; }

.truck-total { display: flex; align-items: center; gap: 18px; margin: 26px 0; padding: 22px; border: 1px solid #dbe4f4; border-radius: 15px; background: linear-gradient(145deg, #f7faff, #edf3ff); }
.truck-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; color: white; background: var(--blue); font-size: 1.6rem; }
.truck-total > div:last-child { display: grid; gap: 4px; }
.truck-total span, .truck-total small { color: var(--muted); }
.truck-total strong { font-size: 1.6rem; }
.truck-total small { font-size: .72rem; }
.notice-box { padding: 17px 19px; border-left: 4px solid #4c79d4; border-radius: 8px 12px 12px 8px; color: #4e5b70; background: #f1f5ff; }
.notice-box strong { color: #294f9f; }
.notice-box p { margin: 5px 0 0; font-size: .78rem; line-height: 1.6; }

.expense-total { color: var(--danger); font-size: 1.4rem; }
.expense-list { display: grid; margin-top: 22px; }
.expense-list > div, .late-payment { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 17px 4px; border-bottom: 1px solid var(--line); }
.expense-list span, .late-payment span { display: grid; gap: 4px; }
.expense-list small, .late-payment small { color: var(--muted); font-size: .68rem; }
.expense-list b { color: var(--danger); }
.openforce-detail { border-bottom: 1px solid var(--line); }
.openforce-detail summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 17px 4px; cursor: pointer; list-style: none; }
.openforce-detail summary::-webkit-details-marker { display: none; }
.openforce-detail summary span { display: grid; gap: 4px; }
.openforce-detail summary small { color: var(--muted); font-size: .68rem; }
.openforce-detail summary b { color: var(--danger); white-space: nowrap; }
.openforce-detail summary strong::before { content: "›"; display: inline-block; margin-right: 8px; color: #5575a7; transition: transform .18s ease; }
.openforce-detail[open] summary strong::before { transform: rotate(90deg); }
.deduction-items { margin: 0 4px 8px 24px; padding: 8px 14px; border-radius: 12px; background: #f5f8fc; }
.deduction-items > div { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid #e4eaf3; font-size: .74rem; }
.deduction-items > div:last-child { border-bottom: 0; }
.deduction-items span { color: #43516a; }
.deduction-items b { color: var(--danger); white-space: nowrap; }
.deduction-items p { margin: 6px 0; color: var(--muted); font-size: .72rem; }
.deduction-check { display: flex; justify-content: space-between; gap: 12px; margin: 8px 4px 16px 24px; padding: 11px 14px; border-radius: 10px; font-size: .7rem; }
.deduction-check.matched { color: #247b5b; background: #e9f8f1; }
.deduction-check.mismatch { color: #9b5d20; background: #fff4df; }
.late-payment { margin-top: 10px; border-bottom: 0; color: var(--green); }

.dashboard-footer { display: flex; justify-content: space-between; gap: 15px; margin-top: 25px; padding: 12px 3px; color: #929baa; font-size: .67rem; }
.dashboard-footer button { border: 0; padding: 0; color: #5373ad; background: none; font-size: inherit; text-decoration: underline; }

dialog { width: min(92vw, 520px); border: 0; border-radius: 20px; padding: 25px; color: var(--ink); box-shadow: 0 28px 80px rgba(15, 32, 65, .35); }
dialog::backdrop { background: rgba(10, 25, 52, .48); backdrop-filter: blur(3px); }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; }
.dialog-header h2 { margin: 5px 0; }
dialog > p { color: var(--muted); font-size: .8rem; }
.sources-list { display: grid; margin-top: 20px; }
.source-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 14px 2px; border-bottom: 1px solid var(--line); }
.source-row > div { display: grid; gap: 3px; }
.source-row span { color: var(--muted); font-size: .68rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; }
.status-dot.ready { background: #2eb47f; box-shadow: 0 0 0 4px rgba(46,180,127,.12); }
.status-dot.waiting { background: #e8a43c; box-shadow: 0 0 0 4px rgba(232,164,60,.12); }
.source-state { padding: 5px 8px; border-radius: 7px; font-weight: 800; }
.ready-text { color: #207857 !important; background: #ebf8f2; }
.waiting-text { color: #8d631e !important; background: #fff7e9; }
.menu-dialog { width: calc(100vw - 30px); margin: auto 15px 15px; padding: 12px; }
.menu-dialog button { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 15px; color: var(--ink); text-align: left; background: white; }

@media (max-width: 1100px) {
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .distribution-card .donut-wrap { grid-template-columns: auto minmax(220px, 1fr); align-items: center; justify-items: stretch; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .dashboard { width: 100%; max-width: 100%; overflow-x: hidden; padding: 0 16px calc(24px + env(safe-area-inset-bottom)); }
  .mobile-header { display: flex; align-items: center; justify-content: space-between; margin: 0 -16px 24px; padding: calc(12px + env(safe-area-inset-top)) 17px 12px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); backdrop-filter: blur(12px); }
  .mobile-header .sidebar-brand span { font-size: .58rem; }
  .dashboard-header { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 14px; }
  .dashboard-header > div { min-width: 0; }
  .dashboard-header h1 { max-width: 100%; font-size: clamp(1.9rem, 9vw, 2.25rem); overflow-wrap: anywhere; }
  .dashboard-header p { max-width: none; font-size: .8rem; line-height: 1.5; }
  .header-actions { width: 100%; }
  .header-actions .ghost-button { display: none; }
  .header-actions .secondary-button { width: 100%; padding: 11px 12px; font-size: 0; }
  .header-actions .secondary-button::after { content: "Fuentes"; font-size: .72rem; }
  .cycle-toolbar { display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; margin-top: 24px; }
  .cycle-toolbar > div { min-width: 0; text-align: center; }
  .verified-badge { grid-column: 1 / -1; justify-self: center; margin: 2px 0 0; }
  .summary-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0; padding: 0; overflow: visible; }
  .summary-card { min-width: 0; min-height: 122px; padding: 16px; }
  .summary-card strong { font-size: clamp(1.14rem, 5.4vw, 1.38rem); overflow-wrap: anywhere; }
  .summary-card small { font-size: .63rem; }
  .tabs { position: sticky; top: 0; z-index: 3; justify-content: space-around; gap: 0; margin: 17px -16px 0; padding: 0 16px; background: rgba(243,246,251,.95); backdrop-filter: blur(10px); }
  .tabs button { flex: 1; }
  .tab-content { margin-top: 15px; }
  .panel-card { width: 100%; min-width: 0; overflow: hidden; padding: 19px; border-radius: 16px; }
  .content-grid { width: 100%; min-width: 0; grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .section-heading { min-width: 0; flex-wrap: wrap; }
  .section-heading > * { min-width: 0; }
  .section-heading h2 { overflow-wrap: anywhere; }
  .accumulated { justify-items: start; }
  .profit-visual { height: 160px; }
  .metric-strip { grid-template-columns: 1fr; }
  .distribution-card .donut-wrap { display: grid; grid-template-columns: 1fr; justify-items: center; }
  .donut { width: min(170px, 60vw); height: auto; aspect-ratio: 1; }
  .donut > div { width: 61%; height: auto; aspect-ratio: 1; }
  .legend { min-width: 0; width: 100%; }
  .legend span { min-width: 0; overflow-wrap: anywhere; }
  .legend strong { white-space: nowrap; }
  .cash-equation { grid-template-columns: 1fr; }
  .cash-equation > div { min-height: 62px; }
  .cash-equation > b { display: block; margin: -6px 0; color: #9aa3b1; text-align: center; }
  .late-payment-note { display: grid; }
  .expense-list > div, .late-payment { align-items: flex-start; }
  .openforce-detail summary { align-items: flex-start; }
  .deduction-items, .deduction-check { margin-left: 0; }
  .truck-total { align-items: flex-start; padding: 17px; }
  .dashboard-footer { flex-direction: column; align-items: flex-start; }
  .login-page { padding: 15px; }
  .login-card { padding: 27px 22px; border-radius: 23px; }
  dialog { width: min(calc(100vw - 24px), 520px); padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
