:root {
  --green: #2f6f4f;
  --green-dark: #245540;
  --green-light: #e8f2ec;
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1d2b24;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --warn: #d97706;
  --blue: #2563eb;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* topbar */
.topbar {
  background: var(--green); color: #fff; display: flex; align-items: center;
  padding: 0 20px; height: 56px; gap: 18px; position: sticky; top: 0; z-index: 50;
}
.topbar .logo { font-weight: 700; font-size: 17px; color: #fff; letter-spacing: .3px; white-space: nowrap; }
.topbar .logo span { opacity: .75; font-weight: 400; }
.topbar nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.topbar nav a {
  color: #d9e8e0; padding: 6px 11px; border-radius: 6px; font-size: 14px; white-space: nowrap;
}
.topbar nav a:hover { background: rgba(255,255,255,.12); text-decoration: none; color: #fff; }
.topbar nav a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.topbar .who { font-size: 13px; text-align: right; line-height: 1.3; white-space: nowrap; }
.topbar .who .role-tag { opacity: .8; font-size: 12px; }
.topbar .signout { color: #fff; font-size: 13px; background: rgba(255,255,255,.15); padding: 6px 12px; border-radius: 6px; }
.topbar .bell { position: relative; color: #fff; font-size: 17px; }
.topbar .bell .count {
  position: absolute; top: -6px; right: -8px; background: #ef4444; color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 99px; padding: 1px 5px;
}
.notif-drop { position: relative; }
.notif-panel {
  display: none; position: absolute; right: 0; top: 34px; width: 320px; background: #fff; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 8px; z-index: 100;
}
.notif-drop:hover .notif-panel, .notif-drop:focus-within .notif-panel { display: block; }
.notif-panel .n-item { padding: 8px 10px; border-radius: 6px; font-size: 13px; display: block; }
.notif-panel .n-item:hover { background: var(--green-light); text-decoration: none; }
.notif-panel .n-empty { padding: 12px; color: var(--muted); font-size: 13px; text-align: center; }

/* layout */
.wrap { max-width: 1240px; margin: 0 auto; padding: 22px 20px 60px; }
.page-title { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.page-title h1 { font-size: 22px; margin: 0; }
.page-title .sub { color: var(--muted); font-size: 14px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.card h2 { font-size: 15px; margin: 0 0 12px; color: var(--text); }
.card h2 .badge { margin-left: 6px; }
.card .more { font-size: 13px; }

/* stat tiles */
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 2px; }
.stat .value.danger { color: var(--danger); }
.stat .value.ok { color: var(--green); }
.stat .hint { font-size: 12px; color: var(--muted); }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--border); }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr.rowlink:hover td { background: var(--green-light); cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }

/* badges */
.badge {
  display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 9px;
  border-radius: 99px; background: #e2e8f0; color: #334155; white-space: nowrap;
}
.badge.lead { background: #ede9fe; color: #6d28d9; }
.badge.estimate { background: #dbeafe; color: #1d4ed8; }
.badge.proposal { background: #fef3c7; color: #b45309; }
.badge.planning { background: #cffafe; color: #0e7490; }
.badge.scheduling { background: #dcfce7; color: #15803d; }
.badge.field_execution { background: #d1fae5; color: #047857; }
.badge.completion_review { background: #ffedd5; color: #c2410c; }
.badge.approval { background: #fce7f3; color: #be185d; }
.badge.closed { background: #e2e8f0; color: #475569; }
.badge.rejected, .badge.declined, .badge.void, .badge.overdue { background: #fee2e2; color: #b91c1c; }
.badge.open { background: #fef3c7; color: #b45309; }
.badge.partial { background: #dbeafe; color: #1d4ed8; }
.badge.paid { background: #dcfce7; color: #15803d; }
.badge.sent, .badge.viewed { background: #fef3c7; color: #b45309; }
.badge.accepted { background: #dcfce7; color: #15803d; }
.badge.scheduled { background: #dbeafe; color: #1d4ed8; }
.badge.in_progress { background: #fef3c7; color: #b45309; }
.badge.completed { background: #dcfce7; color: #15803d; }
.badge.reviewed { background: #e2e8f0; color: #475569; }
.badge.unscheduled { background: #fee2e2; color: #b91c1c; }

/* buttons & forms */
.btn {
  display: inline-block; background: var(--green); color: #fff; border: none; cursor: pointer;
  padding: 8px 16px; border-radius: 7px; font-size: 14px; font-weight: 600;
}
.btn:hover { background: var(--green-dark); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--bg); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn.big { padding: 12px 22px; font-size: 16px; width: 100%; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px;
  font: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; min-height: 70px; }
label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form > div { flex: 1; min-width: 110px; }
.inline-form .btn { flex: 0; }

/* flash */
.flash {
  background: var(--green-light); border: 1px solid #bcd8c9; color: var(--green-dark);
  padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px;
}

/* kanban */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kanban .col { min-width: 230px; width: 230px; background: #eceff0; border-radius: var(--radius); padding: 10px; flex-shrink: 0; }
.kanban .col h3 { font-size: 12.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 2px 4px 10px; display: flex; justify-content: space-between; }
.kcard { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; display: block; color: var(--text); }
.kcard:hover { text-decoration: none; border-color: var(--green); box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.kcard .t { font-weight: 600; font-size: 13.5px; line-height: 1.35; }
.kcard .c { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kcard .v { font-size: 12.5px; font-weight: 600; color: var(--green); margin-top: 4px; }

/* schedule grid */
.sched { display: grid; gap: 6px; font-size: 13px; overflow-x: auto; }
.sched .cell { background: #fff; border: 1px solid var(--border); border-radius: 8px; min-height: 64px; padding: 6px; }
.sched .head { background: none; border: none; font-weight: 600; font-size: 12px; text-align: center; color: var(--muted); min-height: 0; }
.sched .head.today { color: var(--green); }
.sched .crewname { display: flex; align-items: center; gap: 7px; font-weight: 600; border: none; background: none; }
.sched .dot { width: 10px; height: 10px; border-radius: 99px; flex-shrink: 0; }
.vchip { display: block; border-radius: 6px; padding: 5px 7px; margin-bottom: 4px; font-size: 12px; line-height: 1.3; color: #fff; }
.vchip:hover { text-decoration: none; filter: brightness(1.1); }
.vchip .vc { opacity: .85; font-size: 11px; }

/* mobile field UI */
.field-wrap { max-width: 560px; margin: 0 auto; padding: 16px 14px 70px; }
.visit-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; display: block; color: var(--text); }
.visit-card:hover { text-decoration: none; border-color: var(--green); }
.visit-card .vt { font-weight: 700; font-size: 15px; display: flex; justify-content: space-between; gap: 8px; }
.visit-card .va { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 22px 0 8px; font-weight: 700; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--border); position: relative; font-size: 13.5px; }
.timeline li::before { content: ''; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 99px; background: var(--green); }
.timeline .when { color: var(--muted); font-size: 12px; }

/* bar chart (CSS) */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; }
.bars .bar .fill { width: 100%; max-width: 54px; background: var(--green); border-radius: 5px 5px 0 0; min-height: 3px; }
.bars .bar .bl { font-size: 11px; color: var(--muted); }
.bars .bar .bv { font-size: 11.5px; font-weight: 600; }

/* login */
.login-bg { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(150deg, #1e3a2c, #2f6f4f); padding: 20px; }
.login-card { background: #fff; border-radius: 14px; padding: 34px 34px 28px; width: 100%; max-width: 420px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-card h1 { margin: 0 0 2px; font-size: 22px; }
.login-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.login-err { background: #fee2e2; color: #b91c1c; border-radius: 8px; padding: 9px 12px; font-size: 13.5px; margin-bottom: 12px; }
.demo-table { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 14px; }
.demo-table h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); }
.demo-table table { font-size: 12.5px; }
.demo-table td { padding: 4px 6px; }
.demo-table .fill-link { cursor: pointer; color: var(--green); font-weight: 600; }

/* portal */
.portal-topbar { background: #1e3a2c; }
.pay-box { text-align: center; padding: 10px 0 4px; }
.pay-amount { font-size: 34px; font-weight: 800; color: var(--green); }
.stub-note { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; border-radius: 8px; padding: 10px 14px; font-size: 13px; margin: 14px 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 14px; }
.mb0 { margin-bottom: 0; }
.right { text-align: right; }
.empty { color: var(--muted); font-size: 13.5px; padding: 14px 4px; text-align: center; }
details.actions { margin-top: 8px; }
details.actions summary { cursor: pointer; font-size: 13px; color: var(--green); font-weight: 600; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
