:root {
  --red: #d71920;
  --red-dark: #b9141a;
  --navy: #10233f;
  --page: #f3f6f9;
  --line: #dfe6ed;
  --muted: #64748b;
  --success: #047857;
  --success-bg: #ecfdf5;
  --danger: #be123c;
  --danger-bg: #fff1f2;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--page); color: #0f172a; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 2px; color: var(--red); font-size: .78rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #fff 0, #f6f8fb 50%, #e9eef4 100%); }
.login-card { width: min(430px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 24px; background: white; box-shadow: 0 24px 70px rgba(15, 23, 42, .12); }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 22px; border-radius: 17px; background: var(--red); color: white; font-size: 1.7rem; font-weight: 900; }
.brand-mark.small { width: 44px; height: 44px; margin: 0; border-radius: 14px; font-size: 1.35rem; }
.login-card h1 { margin: 4px 0 8px; font-size: 2rem; letter-spacing: -.04em; }
.login-copy { margin: 0 0 26px; color: var(--muted); font-size: 1rem; }
.login-form label, .field label { display: block; margin-bottom: 8px; font-weight: 800; }
.login-form input, .field input { width: 100%; height: 60px; padding: 0 16px; border: 1px solid #cbd5e1; border-radius: 13px; background: #f8fafc; font-size: 1.15rem; font-weight: 700; outline: none; }
.login-form input:focus, .field input:focus { border-color: var(--red); box-shadow: 0 0 0 4px rgba(215, 25, 32, .1); }
.error-message { min-height: 24px; margin: 7px 0; color: var(--danger); font-weight: 700; }
.primary-button { width: 100%; min-height: 54px; border: 0; border-radius: 13px; background: var(--red); color: white; font-weight: 850; cursor: pointer; box-shadow: 0 10px 24px rgba(185, 20, 26, .16); }
.primary-button:hover { background: var(--red-dark); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.primary-button.large { min-height: 62px; font-size: 1.05rem; }

.topbar { border-bottom: 1px solid var(--line); background: rgba(255,255,255,.93); backdrop-filter: blur(10px); }
.topbar-inner { max-width: 1240px; margin: auto; padding: 14px 22px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: flex; align-items: center; gap: 13px; }
.brand h1 { margin: 0; font-size: 1.35rem; letter-spacing: -.03em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.role-badge { padding: 7px 11px; border-radius: 999px; background: #eef2f7; color: #475569; font-size: .82rem; font-weight: 800; }
.text-button { border: 0; background: transparent; color: var(--red); font-weight: 800; cursor: pointer; }

.workspace { max-width: 1240px; margin: auto; padding: 28px 22px; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 22px; align-items: start; }
.entry-card, .seven-card, .history-section { border: 1px solid var(--line); border-radius: 22px; background: white; box-shadow: 0 17px 52px rgba(15, 23, 42, .07); overflow: hidden; }
.section-heading { display: flex; align-items: center; gap: 10px; padding: 22px; border-bottom: 1px solid #edf1f5; }
.section-heading h2, .latest-card h2, .seven-card h2, .history-heading h2 { margin: 0; font-size: 1.08rem; }
.step { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--red); color: white; font-size: .8rem; font-weight: 900; }
.entry-form { padding: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 20px 16px; }
.field.full, .calculated-summary, .message, .entry-form > button { grid-column: 1 / -1; }
.money-input { position: relative; }
.money-input input { padding-right: 45px; }
.money-input span { position: absolute; top: 50%; right: 16px; transform: translateY(-50%); color: #94a3b8; font-size: 1.15rem; font-weight: 850; }
.calculated-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 13px; border: 1px solid #a7f3d0; border-radius: 17px; background: var(--success-bg); }
.calculated-summary.negative { border-color: #fecdd3; background: var(--danger-bg); }
.calculated-summary > div { padding: 12px; border-radius: 13px; background: rgba(255,255,255,.8); }
.calculated-summary span { display: block; color: #475569; font-size: .82rem; font-weight: 700; }
.calculated-summary strong { display: block; margin-top: 5px; color: var(--success); font-size: 1.18rem; }
.calculated-summary.negative strong:not(:last-child) { color: var(--danger); }
.message { padding: 13px 15px; border-radius: 13px; font-weight: 750; }
.message.success { background: var(--success-bg); color: var(--success); }
.message.error { background: var(--danger-bg); color: var(--danger); }

.summary-column { display: grid; gap: 16px; }
.latest-card { min-height: 230px; padding: 22px; border-radius: 22px; background: var(--navy); color: white; box-shadow: 0 17px 52px rgba(15, 23, 42, .14); }
.latest-card h2 { color: #cbd5e1; }
.empty-state { padding-top: 52px; color: #cbd5e1; }
.latest-date { margin: 18px 0 4px; color: #cbd5e1; font-weight: 700; text-transform: capitalize; }
.latest-sales { margin: 0 0 16px; font-size: 2.35rem; font-weight: 900; letter-spacing: -.05em; }
.latest-grid { display: grid; grid-template-columns: 1fr; gap: 9px; }
.latest-grid div { padding: 11px; border-radius: 12px; background: rgba(255,255,255,.08); }
.latest-grid span { display: block; color: #94a3b8; font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.latest-grid strong { display: block; margin-top: 3px; }
.latest-difference { margin-top: 12px; padding: 10px 12px; border-radius: 11px; background: rgba(52, 211, 153, .13); color: #6ee7b7; font-weight: 800; }
.latest-difference.negative { background: rgba(251, 113, 133, .13); color: #fda4af; }
.seven-card { padding: 22px; }
.seven-card > span { display: block; margin-top: 27px; color: var(--muted); font-size: .84rem; font-weight: 700; }
.seven-card > strong { display: block; margin: 3px 0 18px; color: var(--navy); font-size: 1.9rem; }
.seven-variance { display: flex; justify-content: space-between; gap: 12px; padding: 11px 13px; border-radius: 12px; background: var(--success-bg); color: var(--success); font-weight: 800; }

.history-section { max-width: 1240px; margin: 0 auto 42px; }
.history-heading { padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid #edf1f5; }
.history-heading .header-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.history-heading p { margin: 4px 0 0; color: var(--muted); font-size: .84rem; }
.history-pagination { padding: 12px 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid #edf1f5; }
.history-pagination > span { color: var(--muted); font-size: .84rem; }
.history-page-buttons { display: flex; gap: 8px; }
.history-page-buttons button { background: white; cursor: pointer; }
.history-page-buttons button:disabled { opacity: .45; cursor: default; }
.history-page-buttons button:hover:not(:disabled) { background: #f3f6f9; }
.outline-button { padding: 10px 15px; border: 1px solid #cbd5e1; border-radius: 12px; color: #334155; font-size: .88rem; font-weight: 800; text-decoration: none; white-space: nowrap; }
.table-scroll { overflow-x: auto; }
table { width: 100%; min-width: 800px; border-collapse: collapse; }
th, td { padding: 14px 16px; border-bottom: 1px solid #edf1f5; text-align: right; font-size: .9rem; }
th { background: #f8fafc; color: var(--muted); font-size: .8rem; }
th:first-child, td:first-child { text-align: left; }
td { font-weight: 650; }
.positive-text { color: var(--success); font-weight: 850; }
.negative-text { color: var(--danger); font-weight: 850; }
.edit-button { padding: 6px 9px; border: 1px solid #cbd5e1; border-radius: 9px; background: white; cursor: pointer; font-weight: 750; }
.history-empty { padding: 48px 20px; text-align: center; color: var(--muted); font-weight: 700; }

@media (max-width: 850px) {
  .workspace { grid-template-columns: 1fr; }
  .history-section { margin-inline: 16px; }
}

@media (max-width: 600px) {
  .login-card { padding: 28px 22px; }
  .topbar-inner { padding: 12px 15px; }
  .role-badge { display: none; }
  .workspace { padding: 18px 14px; }
  .entry-form { grid-template-columns: 1fr; padding: 18px; }
  .field, .field.full { grid-column: 1; }
  .calculated-summary { grid-template-columns: 1fr; }
  .section-heading { padding: 18px; }
  .history-heading { align-items: flex-start; flex-direction: column; }
  .history-pagination { padding: 12px 18px; }
  .history-page-buttons { width: 100%; }
  .history-page-buttons button { flex: 1; padding-inline: 10px; }
}
