/* LedgerRight CRM — design system */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f7faf8;
  --border: #e3e8ef;
  --text: #1a2233;
  --muted: #667085;
  /* Ledger Right brand */
  --brand: #1aa24c;         /* Ledger green */
  --brand-dark: #148040;
  --brand-tint: #e6f6ec;
  --blue: #1e3a8c;          /* Right royal blue */
  --blue-dark: #16296b;
  --blue-tint: #e8edf9;
  --accent: #1e3a8c;        /* links use brand blue */
  --danger: #d92d20;
  --warn: #d97706;
  --ok: #148040;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { margin: 0; font-weight: 650; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }

/* Layout */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--blue-dark); color: #cdd7ef; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 18px 16px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid rgba(255,255,255,.10); }
.brand .brand-mark { flex: 0 0 auto; }
/* The color monogram (blue+green) needs a light chip to read on the navy sidebar. */
.brand img.brand-mark { width: 40px; height: 40px; background: #fff; border-radius: 9px; padding: 4px; box-sizing: border-box; object-fit: contain; }
.brand .brand-text { line-height: 1.1; }
.brand .brand-text b { color: #fff; font-size: 17px; font-weight: 700; display: block; }
.brand .brand-text small { display:block; font-size: 10px; font-weight: 600; color: #8fe3ab; letter-spacing:.16em; margin-top: 2px; }
.nav { padding: 10px 8px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: #b7c4e2; font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav .ico { width: 18px; text-align: center; }
.nav-sep { color:#7d8dbd; font-size:11px; text-transform:uppercase; letter-spacing:.06em; padding:14px 12px 4px; }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.10); font-size: 12px; color: #9aa8ce; }
.sidebar-foot .who { color:#eef2fb; font-weight:600; }
.sidebar-foot button { margin-top:8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display:flex; align-items:center; justify-content: space-between; gap: 16px; padding: 16px 26px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 19px; }
.content { padding: 22px 26px 60px; }

/* Buttons */
.btn { display:inline-flex; align-items:center; gap:7px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 550; transition: .12s; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #f3c6c2; }
.btn.danger:hover { background: #fdf0ef; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn:disabled { opacity:.5; cursor:not-allowed; }

/* Cards & grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .card-h { padding: 14px 16px; border-bottom: 1px solid var(--border); display:flex; align-items:center; justify-content:space-between; gap: 10px; }
.card .card-h h3 { font-size: 14.5px; }
.card .card-b { padding: 16px; }
/* Brand-outlined dashboard boxes — a full 2px brand border around every card */
.card.accent-green { border: 2px solid var(--brand); }
.card.accent-green > .card-h { background: var(--brand-tint); border-bottom-color: #bfe6d4; }
.card.accent-blue { border: 2px solid var(--blue); }
.card.accent-blue > .card-h { background: var(--blue-tint); border-bottom-color: #c7dbfd; }
.card.clickable { cursor: pointer; transition: transform .1s, box-shadow .1s; }
.card.clickable:hover { transform: translateY(-1px); box-shadow: 0 5px 14px rgba(16,24,40,.12); }
.grid { display: grid; gap: 16px; }
.stat-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 900px){ .cols-2,.cols-3 { grid-template-columns: 1fr; } .layout { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } }

.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 550; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 27px; font-weight: 700; margin-top: 6px; }
.stat .value.warn { color: var(--warn); }
.stat .value.danger { color: var(--danger); }
.stat .value.ok { color: var(--ok); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing:.03em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr.clickable:hover { background: var(--surface-2); cursor: pointer; }
.t-wrap { overflow-x: auto; }

/* Badges */
.badge { display:inline-flex; align-items:center; gap:5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.green { background:#e7f6ef; color:#12805c; border-color:#bfe6d4; }
.badge.blue  { background:#e8f0fe; color:#1d4ed8; border-color:#c7dbfd; }
.badge.amber { background:#fef3e2; color:#b45309; border-color:#fadfb0; }
.badge.red   { background:#fdecea; color:#b42318; border-color:#f7cfca; }
.badge.gray  { background:#f2f4f7; color:#475467; border-color:#e3e8ef; }
.badge.purple{ background:#f4ecfe; color:#7c3aed; border-color:#e2d1fb; }
.dot { width:7px; height:7px; border-radius:50%; display:inline-block; }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display:block; font-size: 12.5px; font-weight: 600; color: #344054; margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.field textarea { min-height: 74px; resize: vertical; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(16,24,40,.45); display:flex; align-items:flex-start; justify-content:center; padding: 6vh 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: 0 20px 40px rgba(16,24,40,.2); width: 100%; max-width: 560px; max-height: 88vh; display:flex; flex-direction:column; }
.modal.lg { max-width: 720px; }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--border); display:flex; align-items:center; justify-content:space-between; }
.modal-h h3 { font-size: 16px; }
.modal-b { padding: 20px; overflow-y: auto; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--border); display:flex; justify-content:flex-end; gap: 10px; }
.x-close { background:none; border:none; font-size: 22px; line-height:1; color: var(--muted); cursor:pointer; }

/* Toast */
#toast-root { position: fixed; bottom: 20px; right: 20px; display:flex; flex-direction:column; gap:10px; z-index: 100; }
.toast { background:#101828; color:#fff; padding: 11px 16px; border-radius: 9px; box-shadow: var(--shadow); font-weight: 500; animation: slidein .2s; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes slidein { from { transform: translateY(8px); opacity:0; } }

/* Pipeline board */
.board { display:grid; grid-template-columns: repeat(4, minmax(220px,1fr)); gap: 14px; align-items:start; overflow-x:auto; }
.board-col { background: var(--surface-2); border:1px solid var(--border); border-radius: 10px; min-height: 120px; }
.board-col.dragover { outline: 2px dashed var(--brand); outline-offset: -2px; background: var(--brand-tint); }
.board-col-h { padding: 11px 13px; font-weight: 650; font-size: 13px; display:flex; justify-content:space-between; border-bottom:1px solid var(--border); }
.board-col-h .sum { color: var(--muted); font-weight: 550; }
.board-col-b { padding: 10px; display:flex; flex-direction:column; gap:9px; }
.deal-card { background:#fff; border:1px solid var(--border); border-radius: 8px; padding: 11px; box-shadow: var(--shadow); cursor: grab; }
.deal-card:active { cursor: grabbing; }
.deal-card .title { font-weight: 600; margin-bottom: 4px; }
.deal-card .meta { font-size: 12px; color: var(--muted); display:flex; justify-content:space-between; margin-top:7px; }

/* Misc */
.page-head { display:flex; align-items:center; justify-content:space-between; margin-bottom: 18px; gap: 14px; flex-wrap: wrap; }
.filters { display:flex; gap: 8px; align-items:center; flex-wrap: wrap; }
.filters input, .filters select { padding: 8px 11px; border:1px solid var(--border); border-radius: 8px; background:#fff; }
.search { min-width: 240px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }
.empty { text-align:center; padding: 44px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.crumb a { color: var(--muted); }
.tag { display:inline-block; background:var(--surface-2); border:1px solid var(--border); border-radius:6px; padding:1px 7px; font-size:11.5px; color:#475467; margin-right:4px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color:#fff; display:inline-flex; align-items:center; justify-content:center; font-size:12px; font-weight:650; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; margin: 4px 0 10px; }
.kv { display:grid; grid-template-columns: 130px 1fr; gap: 8px 14px; }
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; }
.list-item { padding: 11px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.flex { display:flex; align-items:center; gap: 10px; }
.between { justify-content: space-between; }
.gap-sm { gap: 6px; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.due-over { color: var(--danger); font-weight: 600; }
.due-soon { color: var(--warn); font-weight: 600; }

/* Login */
.login-wrap { min-height: 100vh; display:flex; align-items:center; justify-content:center; background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 45%, var(--brand) 100%); padding: 20px; }
.login-card { background:#fff; border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.28); width: 100%; max-width: 390px; padding: 30px 30px; }
.login-brand { text-align:center; margin-bottom: 20px; }
.login-logo { max-width: 260px; width: 100%; height: auto; margin: 0 auto; display: block; }
.login-card .sub { text-align:center; color: var(--muted); margin: 12px 0 22px; font-size: 13px; }
.login-err { background:#fdecea; color:#b42318; border:1px solid #f7cfca; padding:9px 12px; border-radius:8px; margin-bottom:14px; font-size:13px; }

/* --- Calendar month grid --- */
.cal-toolbar { display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom:14px; }
.cal-title { font-size:20px; font-weight:700; margin:0; min-width:190px; }
.cal-nav { display:inline-flex; gap:6px; }
.cal-legend { display:flex; gap:14px; flex-wrap:wrap; margin-left:auto; font-size:12px; color:var(--muted); align-items:center; }
.cal-legend .dot { display:inline-block; width:9px; height:9px; border-radius:3px; margin-right:5px; vertical-align:middle; }
.cal-grid { display:grid; grid-template-columns:repeat(7,1fr); background:var(--border); border:1px solid var(--border); border-radius:var(--radius); overflow:hidden; }
.cal-dow { background:var(--surface-2); text-align:center; font-size:11.5px; font-weight:600; text-transform:uppercase; letter-spacing:.03em; color:var(--muted); padding:8px 4px; }
.cal-cell { background:var(--surface); min-height:112px; padding:5px 6px 6px; display:flex; flex-direction:column; gap:3px; cursor:pointer; position:relative; transition:background .1s; }
.cal-cell:hover { background:var(--brand-tint); }
.cal-cell.other-month { background:#fbfcfe; }
.cal-cell.other-month .cal-daynum { color:#c0c7d4; }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--brand); }
.cal-daynum { font-size:12.5px; font-weight:600; color:var(--text); align-self:flex-start; padding:1px 5px; border-radius:6px; }
.cal-cell.today .cal-daynum { background:var(--brand); color:#fff; }
.cal-ev { font-size:11.5px; line-height:1.25; padding:2px 6px; border-radius:5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; cursor:pointer; border-left:3px solid transparent; }
.cal-ev:hover, .cal-ag:hover { filter:brightness(.96); }
/* event color classes shared by month chips (.cal-ev) and week/day agenda rows (.cal-ag) */
.ev-google { background:var(--blue-tint); color:var(--blue-dark); border-left-color:var(--blue); }
.ev-task { background:var(--brand-tint); color:var(--brand-dark); border-left-color:var(--brand); }
.ev-task.done { text-decoration:line-through; opacity:.6; }
.ev-double { background:#fef3e2; color:#9a5b00; border-left-color:#d97706; }
.ev-overdue { background:#fdecea; color:#b42318; border-left-color:var(--danger); }
.cal-more { font-size:11px; color:var(--muted); padding:1px 6px; cursor:pointer; }
.cal-more:hover { color:var(--accent); }
.ev-detail-row { display:flex; gap:8px; font-size:13px; margin:6px 0; }
.ev-detail-row .k { color:var(--muted); min-width:74px; flex:0 0 auto; }

/* view switcher */
.cal-seg { display:inline-flex; border:1px solid var(--border); border-radius:8px; overflow:hidden; }
.cal-seg button { border:none; background:var(--surface); padding:6px 13px; font-weight:600; font-size:13px; cursor:pointer; color:var(--muted); }
.cal-seg button + button { border-left:1px solid var(--border); }
.cal-seg button.active { background:var(--brand); color:#fff; }

/* week / day agenda columns */
.cal-cols { display:grid; gap:1px; background:var(--border); border:1px solid var(--border); border-radius:var(--radius); overflow:hidden; }
.cal-daycol { background:var(--surface); display:flex; flex-direction:column; min-height:420px; }
.cal-daycol-h { padding:8px 6px; text-align:center; border-bottom:1px solid var(--border); font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:.03em; color:var(--muted); cursor:pointer; }
.cal-daycol-h .dnum { display:block; font-size:19px; color:var(--text); font-weight:700; line-height:1.15; text-transform:none; }
.cal-daycol.today .cal-daycol-h { background:var(--brand-tint); }
.cal-daycol.today .cal-daycol-h .dnum { color:var(--brand-dark); }
.cal-daycol-b { padding:6px; display:flex; flex-direction:column; gap:5px; flex:1; cursor:pointer; }
.cal-ag { display:flex; gap:8px; align-items:baseline; font-size:12.5px; padding:6px 9px; border-radius:6px; border-left:3px solid transparent; cursor:pointer; line-height:1.3; }
.cal-ag .cal-ag-time { font-weight:600; font-size:11px; white-space:nowrap; opacity:.85; flex:0 0 auto; }
.cal-empty-day { color:#b4bcc9; font-size:12px; padding:8px 6px; text-align:center; }
@media (max-width:720px){ .cal-cell { min-height:76px; } .cal-ev { font-size:10.5px; } }
