:root {
  --ink: #1e2624;
  --muted: #66706d;
  --soft: #f3f6f4;
  --line: #dde5e1;
  --white: #fff;
  --lime: #b8dc43;
  --lime-dark: #789919;
  --forest: #183d34;
  --teal: #296f61;
  --gold: #d7a33f;
  --red: #b94a4a;
  --shadow: 0 18px 50px rgba(21, 45, 38, .09);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: #edf2ef; font-family: "DM Sans", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 252px 1fr; }
.sidebar { background: #000; color: white; padding: 28px 18px; display: flex; flex-direction: column; gap: 28px; }
.brand { padding: 0 12px; }
.brand-logo-box { display: grid; place-items: center; width: 92px; height: 104px; padding: 8px; background: #000; border-radius: 12px; }
.brand-logo-box img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.brand h1 { margin: 14px 0 4px; font: 800 20px Manrope; letter-spacing: -.02em; }
.brand p { margin: 0; color: #abc2bb; font-size: 12px; }
.nav { display: grid; gap: 7px; }
.nav button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 13px; color: #c7d8d2; background: transparent; border: 0; border-radius: 11px; text-align: left; }
.nav button:hover, .nav button.active { color: white; background: rgba(255,255,255,.1); }
.nav button.active::before { content: ""; width: 5px; height: 20px; border-radius: 5px; background: var(--lime); }
.sidebar-foot { margin-top: auto; padding: 14px; border-radius: 14px; background: rgba(255,255,255,.07); }
.sidebar-foot small { color: #abc2bb; }

.main { min-width: 0; }
.topbar { height: 82px; display: flex; align-items: center; justify-content: space-between; padding: 0 34px; background: rgba(255,255,255,.88); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 5; }
.eyebrow { color: var(--teal); font-weight: 700; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.topbar h2 { margin: 3px 0 0; font: 800 24px Manrope; }
.user-tools { display: flex; align-items: center; gap: 12px; }
.user-tools select { border: 1px solid var(--line); background: white; border-radius: 10px; padding: 9px 12px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--forest); color: var(--lime); font-weight: 800; }
.content { padding: 30px 34px 60px; max-width: 1500px; margin: auto; }

.hero { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.hero h3 { margin: 0; font: 800 34px Manrope; letter-spacing: -.04em; }
.hero p { margin: 8px 0 0; color: var(--muted); }
.btn { border: 0; border-radius: 10px; padding: 10px 15px; font-weight: 700; }
.btn.primary { color: #173027; background: var(--lime); }
.btn.secondary { color: var(--forest); background: white; border: 1px solid var(--line); }
.btn.danger { color: var(--red); background: #fff2f2; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 22px; }
.stat, .panel { background: white; border: 1px solid var(--line); border-radius: 17px; box-shadow: var(--shadow); }
.stat { padding: 20px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat strong { display: block; margin-top: 8px; font: 800 29px Manrope; }
.stat .delta { margin-top: 7px; color: var(--teal); font-size: 12px; font-weight: 700; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.panel { padding: 22px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 18px; }
.panel h4 { margin: 0; font: 800 18px Manrope; }
.muted { color: var(--muted); }

.dept-bars { display: grid; gap: 18px; }
.dept-row { display: grid; grid-template-columns: 120px 1fr 85px; gap: 14px; align-items: center; }
.bar { height: 10px; border-radius: 10px; background: var(--soft); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--teal),var(--lime)); }
.activity { display: grid; gap: 13px; }
.activity-item { display: grid; grid-template-columns: 10px 1fr auto; gap: 11px; align-items: start; }
.activity-item i { width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: var(--lime); }
.activity-item p { margin: 0; font-size: 13px; }
.activity-item time { color: var(--muted); font-size: 11px; }
.quote-performance { margin-bottom:22px; }
.quote-performance .panel-head select { padding:9px 12px; border:1px solid var(--line); border-radius:9px; background:white; }
.performance-stats { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:10px; margin-bottom:18px; }
.performance-stats div { padding:12px; border-radius:11px; background:var(--soft); }
.performance-stats span { display:block; color:var(--muted); font-size:11px; }
.performance-stats strong { display:block; margin-top:5px; font:800 18px Manrope; }
.performance-legend { display:flex; justify-content:flex-end; gap:18px; margin-bottom:8px; font-size:11px; font-weight:700; }
.performance-legend span::before { content:""; display:inline-block; width:9px; height:9px; margin-right:6px; border-radius:2px; }
.accepted-key::before { background:var(--teal); }.rejected-key::before { background:var(--red); }
.performance-chart { display:grid; grid-template-columns:repeat(auto-fit,minmax(48px,1fr)); gap:10px; height:220px; padding:12px 8px 0; border-left:1px solid var(--line); border-bottom:1px solid var(--line); }
.performance-column { min-width:0; display:grid; grid-template-rows:1fr auto auto; gap:4px; text-align:center; }
.performance-bars { display:flex; align-items:flex-end; justify-content:center; gap:4px; min-height:145px; }
.performance-bars i { display:block; width:min(18px,38%); border-radius:5px 5px 0 0; }
.accepted-bar { background:linear-gradient(180deg,var(--lime),var(--teal)); }.rejected-bar { background:var(--red); opacity:.82; }
.performance-column b { overflow:hidden; color:var(--muted); font-size:10px; text-overflow:ellipsis; white-space:nowrap; }.performance-column small { font-size:9px; }
.performance-note { margin:10px 0 0; color:var(--muted); font-size:10px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.search { flex: 1; max-width: 460px; border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; background: white; }
.filters { display: flex; gap: 9px; }
.filters select { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: white; }
.table-wrap { overflow: auto; background: white; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th { color: var(--muted); background: #f7f9f8; padding: 13px 16px; font-size: 11px; text-align: left; text-transform: uppercase; letter-spacing: .06em; }
td { padding: 15px 16px; border-top: 1px solid var(--line); font-size: 13px; }
tr:hover td { background: #fbfcfb; }
.name { font-weight: 700; }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 20px; padding: 5px 9px; font-size: 11px; font-weight: 700; background: var(--soft); color: var(--teal); }
.badge.yorkshire { background: #edf6d6; color: #5b7418; }
.badge.hertfordshire { background: #e3f1ed; color: #1f6658; }
.badge.draft { background: #fff4d8; color: #8b6415; }
.badge.active { background: #e4f4e9; color: #237343; }
.row-actions { display: flex; gap: 7px; }
.icon-btn { border: 1px solid var(--line); background: white; border-radius: 8px; padding: 6px 9px; }
.document-register-table { overflow-x: hidden; }
.document-register-table table { table-layout: fixed; }
.document-register-table th, .document-register-table td { padding-left: 8px; padding-right: 8px; overflow-wrap: anywhere; }
.document-register-table th:nth-child(1) { width: 12%; }
.document-register-table th:nth-child(2) { width: 8%; }
.document-register-table th:nth-child(3) { width: 11%; }
.document-register-table th:nth-child(4) { width: 10%; }
.document-register-table th:nth-child(5) { width: 8%; }
.document-register-table th:nth-child(6) { width: 8%; }
.document-register-table th:nth-child(7) { width: 6%; }
.document-register-table th:nth-child(8) { width: 8%; }
.document-register-table th:nth-child(9) { width: 29%; }
.document-register-table td:last-child > .row-actions,
.document-register-table td:last-child > .row-actions > .row-actions { flex-wrap: wrap; gap: 4px; }
.document-register-table td:last-child .icon-btn { padding: 5px 7px; font-size: 11px; line-height: 1.15; white-space: normal; }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); }

.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(13,31,26,.62); }
.modal { width: min(700px,100%); max-height: 90vh; overflow: auto; background: white; border-radius: 19px; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.document-modal { width: calc(100vw - 48px); height: calc(100vh - 48px); max-height: none; }
.document-modal .modal-head { position: sticky; top: 0; z-index: 3; background: white; }
.document-modal .form { grid-template-columns: repeat(4,minmax(180px,1fr)); align-items: start; }
.document-modal .form > .full, .document-modal .form > .form-actions { grid-column: 1 / -1; }
.document-modal .field { align-self: start; }
.document-modal .document-builder { overflow-x: auto; }
.document-modal .line-head, .document-modal .document-line { grid-template-columns: minmax(330px,3fr) 85px 90px 125px 100px 85px 120px 116px; }
.payment-modal { width: min(920px,100%); }
.payment-modal .modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 21px 24px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font: 800 21px Manrope; }
.close { border: 0; background: var(--soft); width: 34px; height: 34px; border-radius: 50%; }
.form { padding: 22px 24px 25px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { color: var(--muted); font-size: 12px; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: white; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 9px; padding-top: 5px; }
.document-builder { border: 1px solid var(--line); border-radius: 13px; padding: 14px; background: #f8fbf9; }
.line-head, .document-line { display: grid; grid-template-columns: minmax(180px,2fr) 65px 75px 100px 85px 75px 105px 108px; gap: 8px; align-items: center; }
.line-head { padding: 0 5px 8px; color: var(--muted); font-size: 11px; font-weight: 700; }
.document-line { padding: 8px 0; border-top: 1px solid var(--line); }
.document-line input, .document-line select { min-width: 0; width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px; background: white; }
.document-line strong { text-align: right; font-size: 12px; }
.line-order-actions { display:flex; justify-content:flex-end; gap:4px; }
.line-order-actions .icon-btn { min-width:32px; padding:7px 6px; font-weight:800; }
.document-line-section + .document-line-section { margin-top:22px; }
.document-line-section h4 { margin:0 0 8px; padding:8px 5px; color:#759900; border-bottom:2px solid #b7dd30; font:800 15px Manrope,sans-serif; }
.section-add { margin-top:10px; }
@media (max-width: 760px) {
  .modal-backdrop { padding: 8px; }
  .document-modal { width: calc(100vw - 16px); height: calc(100vh - 16px); }
  .document-modal .form { grid-template-columns: 1fr; padding: 16px; }
  .document-modal .line-head, .document-modal .document-line { min-width: 1120px; }
  .performance-stats { grid-template-columns:1fr 1fr; }
  .performance-chart { overflow-x:auto; grid-template-columns:repeat(12,minmax(46px,1fr)); }
}
.document-totals { margin-left: auto; width: min(390px,100%); display: grid; gap: 8px; padding: 16px; border-radius: 13px; background: var(--soft); }
.document-totals span { display: flex; justify-content: space-between; gap: 20px; color: var(--muted); }
.document-totals b { color: var(--ink); }
.document-totals .section-total { color:var(--ink); font-weight:700; }
.document-totals .grand { padding-top: 9px; border-top: 1px solid var(--line); color: var(--ink); font-size: 16px; font-weight: 800; }
.document-totals .balance { color: var(--teal); font-weight: 800; }
.acceptance { overflow: hidden; border: 1px solid var(--line); border-radius: 14px; }
.acceptance-head { padding: 15px 17px; color: white; background: #000; }
.acceptance-head h4, .acceptance-head p { margin: 0; }
.acceptance-head h4 { font: 800 17px Manrope; color: var(--lime); }
.acceptance-head p { margin-top: 4px; color: #cbd2ce; font-size: 12px; }
.signature-columns { display: grid; grid-template-columns: 1fr 1fr; }
.signature-columns > div { display: grid; gap: 12px; padding: 17px; }
.signature-columns > div + div { border-left: 1px solid var(--line); }
.signature-columns h5 { margin: 0 0 2px; font: 800 14px Manrope; }
.acceptance-note { margin: 0; padding: 12px 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.signature-pad-field { grid-column:1 / -1; }
.admin-signature-canvas { display:block; width:100%; height:110px; border:1px solid var(--line); border-radius:10px; background:#fff; cursor:crosshair; touch-action:none; }
.signature-pad-field small { color:var(--muted); font-size:11px; }
.clear-signature { justify-self:start; padding:7px 10px; }
.legal-review-note { margin: -7px 0 0; padding: 10px 12px; border-left: 3px solid #9fc928; border-radius: 7px; background: #f4f8e9; color: #53613c; font-size: 11px; line-height: 1.45; }
.pdf-preview-overlay { position: fixed; inset: 0; z-index: 100; display: grid; grid-template-rows: auto 1fr; padding: 14px; background: #17201ded; }
.pdf-preview-toolbar { display: flex; align-items: center; gap: 10px; padding: 10px 13px; border-radius: 12px 12px 0 0; background: white; }
.pdf-preview-toolbar strong { font: 800 15px Manrope; }
.pdf-preview-toolbar span { margin-right: auto; color: var(--muted); font-size: 12px; }
.pdf-preview-frame { width: 100%; height: 100%; border: 0; border-radius: 0 0 12px 12px; background: white; }
.notice { padding: 13px 15px; border-radius: 11px; background: #eff7df; color: #536a19; font-size: 13px; }
.cloud-banner { display:flex; align-items:center; gap:10px; margin-bottom:16px; padding:10px 13px; border-radius:10px; font-size:12px; }
.cloud-banner b { font:800 12px Manrope; }
.cloud-banner span { margin-right:auto; }
.cloud-banner.cloud { color:#275c1e; background:#eaf7e4; }
.cloud-banner.local { color:#674f0d; background:#fff5d5; }
.cloud-banner.connecting { color:#315d6b; background:#e9f4f7; }
.cloud-banner.error { color:#862b26; background:#fff0ef; }
.calendar-actions,.calendar-legend { display:flex; align-items:center; gap:9px; }
.calendar-legend { margin:0 0 12px; color:var(--muted); font-size:12px; }
.calendar-legend span { display:flex; align-items:center; gap:6px; }
.calendar-legend i { width:10px; height:10px; border-radius:3px; background:#dff0ab; }
.calendar-legend i.leave { background:#d9eaf7; }
.calendar { overflow:hidden; border:1px solid var(--line); border-radius:14px; background:white; }
.calendar-weekdays,.calendar-grid { display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); }
.calendar-weekdays b { padding:11px; border-bottom:1px solid var(--line); color:var(--muted); text-align:center; font-size:11px; }
.calendar-day { min-height:122px; padding:8px; border-right:1px solid var(--line); border-bottom:1px solid var(--line); }
.calendar-day:nth-child(7n) { border-right:0; }
.calendar-day.outside { background:#f7f9f8; color:#9da8a2; }
.calendar-day.today .calendar-date { display:grid; place-items:center; width:25px; height:25px; border-radius:50%; color:#142019; background:var(--lime); }
.calendar-date { margin-bottom:6px; font-weight:800; font-size:12px; }
.calendar-events { display:grid; gap:5px; }
.calendar-event { display:grid; gap:2px; width:100%; padding:6px 7px; border:0; border-left:3px solid #82a918; border-radius:6px; background:#f1f7df; color:var(--ink); text-align:left; }
.calendar-event.leave { border-left-color:#4284a8; background:#eaf4fa; }
.calendar-event b,.calendar-event small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.calendar-event b { font-size:11px; }
.calendar-event small { color:var(--muted); font-size:9px; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 86px 1fr; }
  .brand h1, .brand p, .nav button span, .sidebar-foot { display:none; }
  .brand { padding:0; text-align:center; }
  .nav button { justify-content:center; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 680px) {
  .shell { display:block; }
  .sidebar { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; padding: 8px; overflow-x:auto; overflow-y:hidden; }
  .brand, .sidebar-foot { display:none; }
  .nav { display:grid; width:100%; grid-template-columns:repeat(7,minmax(0,1fr)); gap:4px; }
  .nav button { min-width:0; width:100%; height:40px; justify-content:center; padding:6px 2px; font-size:18px; }
  .nav button.active::before { width:4px; height:18px; }
  .topbar { min-height:72px; height:auto; padding:10px 12px; gap:8px; }
  .topbar > div:first-child { min-width:0; }
  .eyebrow { display:none; }
  .topbar h2 { font-size:20px; white-space:nowrap; }
  .user-tools { min-width:0; gap:6px; }
  .user-tools select { min-width:0; width:150px; padding:8px; }
  .user-tools .btn { padding:8px; font-size:12px; }
  .user-tools .avatar { display:none; }
  .content { padding: 22px 16px 130px; }
  .stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .stat { min-width:0; padding:16px; overflow:hidden; }
  .stat strong { font-size:24px; }
  .grid-2 > *, .panel, .table-wrap { min-width:0; max-width:100%; }
  .table-wrap { width:100%; }
  .hero { align-items:flex-start; flex-direction:column; }
  .toolbar { align-items:stretch; flex-direction:column; }
  .search { max-width:none; }
  .form { grid-template-columns:1fr; }
  .field.full { grid-column:auto; }
  .line-head { display:none; }
  .document-line { grid-template-columns: 1fr 1fr; }
  .document-line input[name="description"] { grid-column:1 / -1; }
  .signature-columns { grid-template-columns:1fr; }
  .signature-columns > div + div { border-left:0; border-top:1px solid var(--line); }
  .pdf-preview-overlay { padding: 0; }
  .pdf-preview-toolbar { flex-wrap: wrap; border-radius: 0; }
  .pdf-preview-toolbar span { display: none; }
  .pdf-preview-frame { border-radius: 0; }
  .calendar { overflow-x:auto; }
  .calendar-weekdays,.calendar-grid { min-width:760px; }
}
