:root {
  --navy: #1d3557;
  --navy-dark: #16283f;
  --accent: #e76f51;
  --blue: #2e6da4;
  --bg: #f4f6f9;
  --border: #d9dee5;
  --text: #243041;
  --list-font: 9pt;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--navy); color: #fff; display: flex; flex-direction: column; flex-shrink: 0; }
.brand { font-size: 1.3rem; font-weight: 700; padding: 18px 16px; background: var(--navy-dark); }
.brand span { color: var(--accent); }
.sidebar nav { display: flex; flex-direction: column; padding: 10px 0; flex: 1; }
.sidebar nav a { color: #cfd8e3; text-decoration: none; padding: 11px 16px; font-size: .95rem; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a.active { background: var(--blue); color: #fff; }
.sidebar-footer { padding: 14px 16px; font-size: .85rem; border-top: 1px solid rgba(255,255,255,.15); }
.sidebar-footer a { color: #cfd8e3; }
.me { font-weight: 600; margin-bottom: 4px; }

.content { flex: 1; padding: 14px 18px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 9px; }
.page-head h1 { margin: 0; font-size: 1.25rem; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

input, select, textarea {
  font: inherit; font-size: .88rem; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; width: 100%;
}
label { display: block; font-size: .78rem; font-weight: 600; margin: 6px 0 2px; }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: 400; }
.filters select, .filters input { width: auto; }
.check { display: flex; align-items: center; gap: 6px; font-weight: 400; white-space: nowrap; }
.check input { width: auto; }

.btn {
  font: inherit; padding: 8px 14px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; cursor: pointer;
}
.btn:hover { background: #eef1f5; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #275d8c; }
.btn-danger { background: #d9534f; border-color: #d9534f; color: #fff; }
.btn-success { background: #2db47d; border-color: #2db47d; color: #fff; }
.btn-block { display: block; width: 100%; text-align: center; margin: 8px 0; text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: .85rem; }

/* task list filter bar — compact single row */
.filter-bar { margin-bottom: 10px; padding: 8px 10px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.filter-row label { font-size: .72rem; font-weight: 600; margin: 0; display: flex; flex-direction: column; gap: 2px; flex: 0 1 110px; min-width: 0; }
.filter-row label.grow { flex: 1 1 140px; }
.filter-row input, .filter-row select { padding: 4px 6px; font-size: .82rem; width: 100%; }
.filter-actions { display: flex; gap: 6px; align-items: flex-end; }
.filter-actions .btn { margin: 0; }
.btn-xs { padding: 2px 7px; font-size: .8rem; line-height: 1.2; }

/* dashboard */
.inline-month { display: flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 600; margin: 0; }
.inline-month select { width: auto; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; margin-bottom: 14px; }
.dash-grid .card { margin-bottom: 0; }
.kpi, .card { position: relative; }
.card h3 { padding-right: 22px; }
.widget-x { position: absolute; top: 6px; right: 8px; border: none; background: none; color: #c2cad6;
  font-size: 1.15rem; line-height: 1; cursor: pointer; padding: 2px 5px; border-radius: 4px; }
.widget-x:hover { color: #d9534f; background: #f6e9e9; }
.mini-row { display: flex; gap: 8px; align-items: baseline; font-size: .85rem; padding: 3px 0; border-bottom: 1px solid #f0f2f5; }
.mini-row:last-child { border-bottom: none; }
.mini-row .mini-date { color: #68748a; white-space: nowrap; min-width: 92px; font-size: .78rem; }
.mini-row a { color: var(--blue); text-decoration: none; }
.mini-row a:hover { text-decoration: underline; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; border-top: 3px solid var(--blue); }
.kpi-call { border-top-color: #5b8def; }
.kpi-sc { border-top-color: #d9534f; }
.kpi-label { font-size: .8rem; color: #68748a; font-weight: 600; }
.kpi-value { font-size: 2rem; font-weight: 700; color: var(--navy); line-height: 1.1; margin: 4px 0 2px; }
.kpi-unit { font-size: 1rem; font-weight: 600; color: #9aa6b2; margin-left: 2px; }
.kpi-sub { font-size: .8rem; color: #68748a; }
.kpi-sub .up { color: #2db47d; } .kpi-sub .down { color: #d9534f; }

.hbar-row { display: grid; grid-template-columns: 130px 1fr 78px; align-items: center; gap: 8px; margin: 6px 0; }
.hbar-label { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { background: #eef1f5; border-radius: 4px; height: 16px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 4px; min-width: 2px; }
.hbar-val { font-size: .82rem; text-align: right; white-space: nowrap; }

.legend { font-size: .72rem; font-weight: 400; color: #68748a; float: right; }
.legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 3px 0 8px; }
.trend { display: flex; align-items: flex-end; gap: 6px; height: 200px; padding-top: 10px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.trend-bars { display: flex; flex-direction: column-reverse; width: 70%; min-height: 1px; }
.trend-seg { width: 100%; }
.trend-seg:first-child { border-radius: 0 0 3px 3px; }
.trend-seg:last-child { border-radius: 3px 3px 0 0; }
.trend-total { font-size: .7rem; color: #68748a; margin-top: 3px; }
.trend-label { font-size: .72rem; color: #68748a; margin-top: 1px; }
.trend-sm { height: 150px; }

/* telephone support panel */
.call-panel { border-top: 3px solid #5b8def; }
.call-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.call-stat { background: #f5f8fe; border: 1px solid #e3ecfb; border-radius: 6px; padding: 8px 12px; }
.call-stat-val { font-size: 1.6rem; font-weight: 700; color: var(--navy); line-height: 1.1; }
.call-stat-lbl { font-size: .74rem; color: #68748a; }
.call-stat-lbl .up { color: #2db47d; } .call-stat-lbl .down { color: #d9534f; }
.call-stat-value { background: #eafaf930; border-color: #b8e6d4; }
.call-stat-value .call-stat-val { color: #1c7a52; }
.panel-sub { font-size: .82rem; font-weight: 600; color: var(--navy); margin-bottom: 4px; }

/* segmented Open/Closed/All toggle */
.seg-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg-toggle a { padding: 6px 14px; font-size: .85rem; text-decoration: none; color: var(--text); background: #fff; border-left: 1px solid var(--border); }
.seg-toggle a:first-child { border-left: none; }
.seg-toggle a:hover { background: #eef1f5; }
.seg-toggle a.active { background: var(--blue); color: #fff; }

/* compact list table (task list) — font size comes from --list-font */
.list.compact td a { font-weight: 500; }
.initials { display: inline-block; min-width: 22px; text-align: center; padding: 1px 4px;
  border-radius: 4px; color: #fff; font-size: calc(var(--list-font) - 2pt); font-weight: 700; letter-spacing: .02em; }
.btn-row { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; }

/* tables */
table.list { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.list th, .list td { padding: 3px 8px; text-align: left; border-bottom: 1px solid var(--border); font-size: var(--list-font); }
.list th { background: #eef1f5; font-size: calc(var(--list-font) - 1pt); text-transform: uppercase; letter-spacing: .03em; position: relative; }
.hist-filter { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; padding: 8px 10px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
.hist-filter .check { font-weight: 400; font-size: .85rem; }
.col-resizer { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; user-select: none; }
.col-resizer:hover { background: var(--blue); opacity: .35; }
.table-wrap { overflow-x: auto; }
.list th.sortable { cursor: pointer; user-select: none; }
.list th.sortable:hover { background: #e2e8f0; }
.sort-ind { color: var(--blue); font-size: .85em; }
.list.resizable { table-layout: fixed; }
.list.resizable th, .list.resizable td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list.resizable th { padding-right: 10px; }
.list tr:hover td { background: #f6f9fc; }
.list a { color: var(--blue); text-decoration: none; font-weight: 600; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 7.5pt; color: #fff; background: var(--blue); }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,30,45,.5); display: flex; justify-content: flex-end; z-index: 50; }
.modal-backdrop[hidden] { display: none; }
.modal { background: #fff; width: min(720px, 100%); height: 100%; overflow-y: auto; box-shadow: -4px 0 24px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; z-index: 2; }
.modal-head h2 { margin: 0; font-size: 1.25rem; }
.modal-body { padding: 10px 22px 30px; }
.modal-body h3 { margin: 18px 0 6px; font-size: .95rem; color: var(--navy); text-transform: uppercase; letter-spacing: .04em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.grid4 { display: grid; grid-template-columns: 1.2fr 1fr 1.2fr .8fr; gap: 10px; }
.span2 { grid-column: span 2; }
.checks { display: flex; flex-direction: column; justify-content: end; gap: 4px; padding-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { background: #e8eef5; border-radius: 99px; padding: 4px 10px; font-size: .85rem; display: inline-flex; align-items: center; gap: 6px; }
.chip button { border: none; background: none; cursor: pointer; font-size: 1rem; line-height: 1; color: #667; }
.typeahead { position: absolute; background: #fff; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 6px 16px rgba(0,0,0,.12); max-height: 220px; overflow-y: auto; z-index: 10; width: min(500px, 90%); }
.typeahead div { padding: 8px 12px; cursor: pointer; font-weight: 400; }
.typeahead div:hover { background: #eef1f5; }
.error { background: #fdecea; color: #b71c1c; padding: 8px 12px; border-radius: 6px; margin-top: 10px; }
.conflict-warning { background: #fff4e0; border: 1px solid #f0a202; color: #8a5a00; padding: 8px 12px; border-radius: 6px; margin: 4px 0 6px; font-size: .9rem; }
.conflict-warning strong { display: block; margin-bottom: 4px; }
.conflict-warning ul { margin: 0; padding-left: 18px; }
.modal-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

/* detail pages */
.card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.card h3 { margin: 0 0 7px; font-size: .9rem; color: var(--navy); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.muted { color: #68748a; }
.small { font-size: .82rem; }
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin: 12px 0 0; }
.tabs button { font: inherit; font-size: .9rem; border: none; background: none; padding: 6px 14px; cursor: pointer; border-bottom: 3px solid transparent; font-weight: 600; color: #556; }
.tabs button.active { color: var(--blue); border-bottom-color: var(--blue); }
.tabpanel { display: none; padding-top: 8px; }
.tabpanel.active { display: block; }

/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--navy); }
.login-card { background: #fff; border-radius: 12px; padding: 34px 38px; width: 380px; box-shadow: 0 18px 50px rgba(0,0,0,.35); }
.login-card h1 { margin: 0; }
.login-card h1 span { color: var(--accent); }
.divider { text-align: center; color: #99a; margin: 14px 0; }

/* FullCalendar tweaks */
#calendar { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.fc .fc-button-primary { background: var(--blue); border-color: var(--blue); }
.fc .fc-toolbar-title { font-size: 1.15rem; }
