/* JustBills — styles */
:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --ink: #1c2430;
  --ink-soft: #5b6675;
  --muted: #8a93a3;
  --line: #e5e9ef;
  --line-strong: #d3d9e2;
  --brand: #2f7d5b;
  --brand-ink: #1f5a41;
  --brand-soft: #e8f4ee;
  --blue: #3b6ea5;
  --blue-soft: #e9f0f8;
  --amber: #b9772a;
  --amber-soft: #fbf0e0;
  --red: #c0453b;
  --red-soft: #fbeceb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20,30,45,0.06), 0 6px 20px rgba(20,30,45,0.06);
  --shadow-lg: 0 10px 40px rgba(20,30,45,0.18);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45; }
#root { height: 100vh; }

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal; font-style: normal;
  font-size: 20px; line-height: 1; vertical-align: middle;
  -webkit-font-feature-settings: 'liga'; letter-spacing: normal;
  display: inline-flex; flex: none;
}
.mi-sm { font-size: 15px; }
.mi-lg { font-size: 26px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.pad { padding: 16px; }
.spacer { flex: 1; }

/* ---------- boot / auth ---------- */
.boot-screen { height: 100vh; display: grid; place-items: center; background: var(--bg); }
.boot-mark {
  width: 64px; height: 64px; border-radius: 18px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 34px; font-weight: 700;
  box-shadow: var(--shadow-lg); animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.06); opacity: 1; } }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #e7f2ec, var(--bg)); }
.auth-card { width: 360px; max-width: 100%; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-brand { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: #fff;
  display: inline-grid; place-items: center; font-weight: 800; }

/* two-column sign-in / sign-up card */
.auth-shell { width: 840px; max-width: 100%; display: grid; grid-template-columns: 1.05fr 1fr;
  background: var(--panel); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow-lg);
  border: 1px solid var(--line); }
.auth-hero { background: linear-gradient(160deg, #2f7d5b 0%, #1f5a41 100%); color: #fff;
  padding: 34px 30px; display: flex; flex-direction: column; justify-content: space-between; gap: 26px; }
.auth-hero .auth-brand { color: #fff; font-size: 24px; }
.auth-hero .brand-mark { background: rgba(255,255,255,0.18); }
.auth-hero-tag { color: rgba(255,255,255,0.86); font-size: 14px; line-height: 1.55; margin: 12px 0 0; }
.auth-marks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.auth-mark { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  background: rgba(255,255,255,0.10); font-size: 13px; font-weight: 500; }
.auth-mark-ico { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: rgba(255,255,255,0.16); flex: none; }
.auth-mark-label { line-height: 1.2; }
.auth-panel { padding: 34px 30px; display: flex; flex-direction: column; justify-content: center; }
.auth-tabs { display: flex; gap: 4px; background: var(--panel-2); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.auth-tab { flex: 1; border: none; background: transparent; font: inherit; font-weight: 600; color: var(--ink-soft);
  padding: 9px; border-radius: 8px; cursor: pointer; }
.auth-tab.is-active { background: var(--panel); color: var(--brand-ink); box-shadow: var(--shadow); }
.linklike { background: none; border: none; color: var(--brand-ink); font: inherit; font-weight: 600;
  cursor: pointer; padding: 6px 0; }
.linklike:hover { text-decoration: underline; }
.auth-forgot { display: block; margin: 14px auto 0; }
.auth-back { display: block; margin-top: 12px; color: var(--ink-soft); }
.auth-recover-title { margin: 0 0 14px; font-size: 18px; }
.code-input { font-size: 22px; letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; }

@media (max-width: 760px) {
  .auth-shell { grid-template-columns: 1fr; width: 400px; }
  .auth-hero { padding: 24px; gap: 18px; }
  .auth-marks { grid-template-columns: 1fr 1fr; }
  .auth-panel { padding: 24px; }
}

/* ---------- buttons / inputs ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent;
  border-radius: var(--radius-sm); padding: 8px 14px; font: inherit; font-weight: 600;
  cursor: pointer; background: var(--panel-2); color: var(--ink); transition: background .12s, border-color .12s; }
.btn:hover { background: #eef1f5; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-ghost { background: transparent; border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger-ghost { background: transparent; border-color: var(--line-strong); color: var(--red); }
.btn-danger-ghost:hover { background: var(--red-soft); }
.btn-block { width: 100%; justify-content: center; margin-top: 8px; }
.icon-btn { border: none; background: transparent; color: var(--ink-soft); cursor: pointer;
  border-radius: 8px; padding: 5px; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--panel-2); color: var(--ink); }
.icon-btn.danger:hover { color: var(--red); background: var(--red-soft); }

.input { width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 8px 10px; font: inherit; background: #fff; color: var(--ink); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a93a3' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; padding-right: 28px; }
.input-sm { padding: 4px 8px; font-size: 13px; }
textarea.input { resize: vertical; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; flex: 1; }
.field-label { font-weight: 600; font-size: 12.5px; color: var(--ink-soft); }
.field-hint { font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 14px; }
.row .field { min-width: 0; }
.row-inline { display: flex; gap: 8px; }
.row-inline .input { flex: 1; }

.alert { background: var(--red-soft); color: var(--red); border: 1px solid #f0cfcc;
  border-radius: var(--radius-sm); padding: 8px 12px; margin: 6px 0; font-size: 13px; }
.note-ok { background: var(--brand-soft); color: var(--brand-ink); border-radius: var(--radius-sm);
  padding: 8px 12px; font-size: 13px; }

.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--panel-2); color: var(--ink-soft); border: 1px solid var(--line); }
.pill-ok { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.pill-late, .pill.pill-late { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.pill-amount { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }

.toggle { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; margin: 4px 0; }
.toggle input { display: none; }
.toggle-track { width: 38px; height: 22px; background: var(--line-strong); border-radius: 999px; position: relative; transition: background .15s; flex: none; }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input:checked + .toggle-track { background: var(--brand); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle-label { font-size: 13px; }

.section-title { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-soft); margin: 18px 0 8px; }

/* ---------- topbar ---------- */
.app { height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); z-index: 5; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px;
  border: none; background: none; cursor: pointer; color: var(--ink); }
.usermenu { position: relative; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff;
  font-weight: 700; border: none; cursor: pointer; }
.menu { position: absolute; right: 0; top: 42px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 220px; padding: 6px; z-index: 20; }
.menu-head { padding: 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-weight: 600; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: none;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--ink); font: inherit; text-align: left; }
.menu-item:hover { background: var(--panel-2); }

/* ---------- layout ---------- */
.layout { flex: 1; display: grid; grid-template-columns: 240px 1fr 300px; min-height: 0; }
.rail { border-right: 1px solid var(--line); background: var(--panel); padding: 12px; overflow-y: auto; }
.rail-head { display: flex; align-items: center; justify-content: space-between; font-weight: 700;
  color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 6px 8px; }
.rail-list { list-style: none; margin: 4px 0 0; padding: 0; }
.rail-item { display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: none;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--ink); font: inherit; text-align: left; }
.rail-item:hover { background: var(--panel-2); }
.rail-item.is-active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.rail-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.content { overflow-y: auto; min-width: 0; background: var(--bg); }

/* ---------- calendar ---------- */
.cal-scroll { height: 100%; overflow-y: auto; padding: 8px 18px 40px; }
.cal-sentinel { height: 1px; }
.cal-month { margin: 18px auto; max-width: 860px; }
.cal-month-label { font-weight: 700; font-size: 16px; margin: 8px 4px; position: sticky; top: 0;
  background: var(--bg); padding: 6px 2px; z-index: 2; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { margin-bottom: 4px; }
.cal-dow-cell { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.cal-cell { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; min-height: 92px;
  padding: 6px; cursor: pointer; transition: border-color .1s, box-shadow .1s; display: flex; flex-direction: column; gap: 4px; }
.cal-cell:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.cal-empty { background: transparent; border: none; cursor: default; box-shadow: none; }
.cal-cell.is-today { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.cal-daynum { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.cal-cell.is-today .cal-daynum { color: var(--brand-ink); }
.cal-events { display: flex; flex-direction: column; gap: 3px; }
.cal-chip { display: flex; align-items: center; gap: 4px; border: none; border-radius: 6px;
  padding: 2px 5px; font-size: 11px; font-weight: 500; cursor: pointer; text-align: left; width: 100%; overflow: hidden; }
.cal-chip-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.chip-arrival { background: var(--blue-soft); color: var(--blue); }
.chip-pay { background: var(--amber-soft); color: var(--amber); }
.chip-entry { background: var(--brand-soft); color: var(--brand-ink); }
.cal-chip.is-late { background: var(--red-soft); color: var(--red); }
.late-x { color: var(--red); }

/* ---------- upcoming ---------- */
.upcoming { border-left: 1px solid var(--line); background: var(--panel); overflow-y: auto; padding: 14px; }
.up-section { margin-bottom: 22px; }
.up-section h3 { display: flex; align-items: center; gap: 8px; font-size: 13px; text-transform: uppercase;
  letter-spacing: .03em; color: var(--ink-soft); margin: 0 0 8px; }
.up-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.up-item { display: flex; align-items: center; gap: 9px; padding: 8px 9px; border-radius: 8px; cursor: pointer; }
.up-item:hover { background: var(--panel-2); }
.up-item.is-late { background: var(--amber-soft); }
.up-name { flex: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-when { font-size: 12px; color: var(--muted); }

/* ---------- detail / history ---------- */
.detail { padding: 20px 24px 48px; max-width: 960px; margin: 0 auto; }
.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.detail-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-ink);
  display: grid; place-items: center; flex: none; }
.detail-title h1 { margin: 0; font-size: 22px; }
.detail-title { min-width: 0; }

.history { margin-top: 6px; }
.range-bar { display: flex; align-items: center; gap: 8px; margin: 6px 0 14px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-strong); background: var(--panel); border-radius: 999px;
  padding: 4px 12px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--ink-soft); }
.chip:hover { background: var(--panel-2); color: var(--ink); }
.range-hint { margin-left: auto; }
.chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 14px; box-shadow: var(--shadow); }
.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.chart-title { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-amount { background: var(--brand); }
.dot-metric { background: var(--blue); }
.chart-wrap { width: 100%; }
.chart-empty { padding: 40px; text-align: center; }
.u-legend { display: none; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 10px 12px; color: var(--ink-soft); font-weight: 600;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel-2); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--panel-2); }
.note-cell { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-soft); }
.row-actions { display: flex; gap: 2px; }

/* ---------- modal ---------- */
.modal-scrim { position: fixed; inset: 0; background: rgba(20,30,45,.42); display: grid; place-items: center;
  padding: 20px; z-index: 50; backdrop-filter: blur(2px); }
.modal { background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-lg); width: 460px; max-width: 100%;
  max-height: 90vh; display: flex; flex-direction: column; }
.modal-wide { width: 620px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 18px; overflow-y: auto; }
.form-grid { display: flex; flex-direction: column; }
.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.form-actions .btn:last-child { margin-left: 0; }
.entry-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* ---------- metrics editor ---------- */
.metrics-editor { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; }
.metrics-head, .metric-row { display: grid; grid-template-columns: 1.4fr 1fr 80px 120px; gap: 8px; align-items: center; }
.metrics-head { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; padding: 0 2px; }
.metric-row { margin-bottom: 8px; }
.metric-actions { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }

/* ---------- icon picker ---------- */
.iconpick { position: relative; }
.iconpick-current { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 6px 10px; background: #fff; cursor: pointer; font: inherit; width: 100%; }
.iconpick-current span { flex: 1; text-align: left; color: var(--ink-soft); }
.iconpick-pop { position: absolute; z-index: 30; top: 46px; left: 0; width: 300px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 10px; }
.iconpick-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; max-height: 240px; overflow-y: auto; margin-top: 8px; }
.iconpick-cell { border: 1px solid transparent; background: none; border-radius: 8px; padding: 7px; cursor: pointer; color: var(--ink-soft); display: grid; place-items: center; }
.iconpick-cell:hover { background: var(--panel-2); color: var(--ink); }
.iconpick-cell.is-active { background: var(--brand-soft); color: var(--brand-ink); }

.create-user { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 200px 1fr; }
  .upcoming { display: none; }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .rail { display: none; }
  .entry-metrics { grid-template-columns: 1fr; }
  .row { flex-direction: column; gap: 0; }
}
