:root {
  --ink: #17201e;
  --muted: #68736f;
  --line: #e2e7e4;
  --surface: #ffffff;
  --canvas: #f4f6f3;
  --forest: #173f35;
  --forest-2: #245c4d;
  --lime: #cde86b;
  --danger: #a43f34;
  --shadow: 0 18px 50px rgba(27, 48, 42, 0.08);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); min-height: 100vh; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  height: 68px;
  justify-content: space-between;
  padding: 0 4vw;
}
.brand { align-items: center; color: var(--ink); display: flex; gap: 11px; text-decoration: none; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1; }
.brand b { font-size: 18px; letter-spacing: .04em; }
.brand small { color: var(--muted); font-size: 9px; letter-spacing: .2em; margin-top: 5px; }
.brand-mark { align-items: center; background: var(--lime); border-radius: 18px; color: var(--forest); display: flex; font-size: 28px; font-weight: 800; height: 58px; justify-content: center; width: 58px; }
.brand-mark-small { border-radius: 10px; font-size: 19px; height: 38px; width: 38px; }
.topbar-actions { align-items: center; display: flex; gap: 20px; }
.topbar-actions form { margin: 0; }
.environment { align-items: center; color: var(--muted); display: flex; font-size: 12px; gap: 7px; }
.environment i { background: #3ea969; border-radius: 50%; box-shadow: 0 0 0 4px #e1f3e8; height: 7px; width: 7px; }

.page-shell { margin: 0 auto; max-width: 1500px; padding: 46px 4vw 80px; }
.page-heading { align-items: flex-end; display: flex; justify-content: space-between; margin-bottom: 28px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(34px, 4vw, 54px); letter-spacing: -.045em; line-height: 1; margin-bottom: 13px; }
h2 { font-size: 26px; letter-spacing: -.025em; margin-bottom: 8px; }
.eyebrow { color: var(--forest-2); font-size: 10px; font-weight: 800; letter-spacing: .17em; margin-bottom: 11px; }
.muted { color: var(--muted); line-height: 1.55; }
.sync-box { align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; display: flex; gap: 22px; padding: 12px 13px 12px 18px; }
.sync-box div { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.sync-box span { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.sync-box b { font-size: 12px; }

.button { align-items: center; border: 1px solid transparent; border-radius: 9px; cursor: pointer; display: inline-flex; font-weight: 700; justify-content: center; padding: 11px 16px; text-decoration: none; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .65; }
.button-primary { background: var(--forest); color: #fff; }
.button-primary:hover:not(:disabled) { box-shadow: 0 8px 20px rgba(23, 63, 53, .2); }
.button-secondary { background: #eef3ef; color: var(--forest); }
.button-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.button-danger { background: var(--danger); color: #fff; }
.button-small { border-radius: 8px; font-size: 11px; padding: 8px 10px; white-space: nowrap; }
.button-wide { width: 100%; }

.stats-grid { display: grid; gap: 14px; grid-template-columns: repeat(4, 1fr); margin-bottom: 22px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; display: grid; min-height: 132px; padding: 21px; }
.stat-card span { color: var(--muted); font-size: 12px; }
.stat-card strong { font-size: 34px; letter-spacing: -.04em; }
.stat-card small { color: var(--muted); font-size: 11px; }
.stat-card.stat-accent { background: var(--forest); border-color: var(--forest); color: #fff; }
.stat-card.stat-accent span, .stat-card.stat-accent small { color: #c9d8d2; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.toolbar { align-items: center; border-bottom: 1px solid var(--line); display: flex; gap: 12px; justify-content: space-between; padding: 16px; }
.search-box { align-items: center; background: var(--canvas); border: 1px solid transparent; border-radius: 9px; display: flex; flex: 1; gap: 8px; max-width: 520px; padding: 0 12px; }
.search-box:focus-within { border-color: #98b5a9; }
.search-box input { background: transparent; border: 0; outline: 0; padding: 11px 0; width: 100%; }
.toolbar select, input { background: #fff; border: 1px solid #d8dfdb; border-radius: 9px; color: var(--ink); padding: 11px 12px; }
.toolbar select { min-width: 190px; }
.table-wrap { overflow-x: auto; }
.notes-table { border-collapse: collapse; min-width: 1150px; width: 100%; }
.notes-table th { color: #77817d; font-size: 9px; letter-spacing: .13em; padding: 13px 18px; text-align: left; text-transform: uppercase; }
.notes-table td { border-top: 1px solid #edf0ee; font-size: 12px; padding: 17px 18px; vertical-align: middle; }
.notes-table tr:hover td { background: #fbfcfb; }
.notes-table b { display: block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invoice-number { font-size: 15px; }
.cell-detail { color: var(--muted); display: block; font-size: 10px; margin-top: 5px; }
.align-right { text-align: right !important; }
.key-copy { background: transparent; border: 0; color: #88938e; cursor: pointer; font-size: 9px; margin-top: 6px; padding: 0; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.badge { border-radius: 999px; display: inline-flex; font-size: 9px; font-weight: 800; padding: 6px 9px; text-transform: uppercase; }
.badge-ready { background: #e7f5b4; color: #48600c; }
.badge-review { background: #fff1d5; color: #8c5a0c; }
.badge-issued { background: #dcebe7; color: #235c4e; }
.badge-paid { background: #dff2e5; color: #247342; }
.badge-blocked { background: #f7dfdc; color: #8d3930; }
.empty-row td, .filter-empty { color: var(--muted); padding: 60px 20px !important; text-align: center; }

.modal { border: 0; border-radius: 18px; box-shadow: 0 28px 90px rgba(12, 31, 26, .26); max-width: 720px; padding: 0; width: calc(100% - 28px); }
.modal::backdrop { background: rgba(13, 26, 22, .55); backdrop-filter: blur(3px); }
.modal form { padding: 28px; }
.modal-small { max-width: 510px; }
.modal-heading { align-items: flex-start; display: flex; justify-content: space-between; }
.modal-close { background: var(--canvas); border: 0; border-radius: 50%; color: var(--muted); cursor: pointer; font-size: 21px; height: 34px; width: 34px; }
.note-summary { background: var(--forest); border-radius: 12px; color: #fff; display: grid; gap: 1px; grid-template-columns: 2fr 1fr 1fr; margin: 20px 0; overflow: hidden; }
.note-summary div { background: rgba(255,255,255,.04); display: flex; flex-direction: column; gap: 7px; padding: 15px; }
.note-summary span { color: #b8cbc4; font-size: 9px; text-transform: uppercase; }
.note-summary b { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-grid { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; margin: 18px 0; }
label { color: #4f5a56; display: flex; flex-direction: column; font-size: 11px; font-weight: 700; gap: 7px; }
label input { font-weight: 500; }
.money-input { align-items: center; display: flex; position: relative; }
.money-input i { color: var(--muted); font-style: normal; left: 12px; position: absolute; }
.money-input input { padding-left: 38px; width: 100%; }
.check-row { align-items: flex-start; background: #f7f9f7; border-radius: 10px; flex-direction: row; font-size: 12px; font-weight: 500; line-height: 1.45; padding: 14px; }
.check-row input { margin-top: 2px; }
.modal-actions { border-top: 1px solid var(--line); display: flex; gap: 9px; justify-content: flex-end; margin-top: 22px; padding-top: 20px; }
.alert { border-radius: 9px; font-size: 12px; line-height: 1.45; margin: 14px 0; padding: 12px 14px; }
.alert-error { background: #f8e4e1; color: #8c342b; }
.alert-warning { background: #fff2d6; color: #7e510d; }
.toast { background: var(--forest); border-radius: 10px; bottom: 24px; box-shadow: var(--shadow); color: #fff; font-size: 12px; font-weight: 700; left: 50%; max-width: 560px; padding: 14px 18px; position: fixed; transform: translateX(-50%); z-index: 20; }
.toast[data-kind="error"] { background: var(--danger); }

.login-page { background: var(--forest); }
.login-shell { display: grid; grid-template-columns: 1.1fr .9fr; min-height: 100vh; }
.login-brand { align-self: center; color: #fff; max-width: 620px; padding: 10vw; }
.login-brand .eyebrow { color: var(--lime); margin-top: 38px; }
.login-brand h1 { font-size: clamp(46px, 6vw, 86px); max-width: 600px; }
.login-brand > p:last-child { color: #bfd0ca; font-size: 17px; line-height: 1.6; max-width: 520px; }
.login-card { align-self: center; background: #fff; border-radius: 20px; box-shadow: 0 30px 80px rgba(0,0,0,.18); margin: 40px 8vw 40px 0; max-width: 470px; padding: 38px; width: calc(100% - 40px); }
.stack { display: grid; gap: 17px; margin-top: 28px; }

@media (max-width: 950px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-heading { align-items: flex-start; flex-direction: column; gap: 20px; }
  .sync-box { width: 100%; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { padding: 60px 7vw 20px; }
  .login-brand h1 { font-size: 48px; }
  .login-card { margin: 20px auto 60px; }
}

@media (max-width: 600px) {
  .page-shell { padding-top: 30px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { min-height: 112px; padding: 16px; }
  .stat-card strong { font-size: 28px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar select, .search-box { max-width: none; width: 100%; }
  .environment { display: none; }
  .sync-box { align-items: stretch; flex-direction: column; }
  .form-grid, .note-summary { grid-template-columns: 1fr; }
  .login-card { padding: 28px; }
}
