/* MMC365 design system — business, square-cornered, professional.
   Light-first, restrained palette (slate ink + navy accent), semantic badges. */

:root {
  /* Neutrals */
  --bg: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --border: #d3d8df;
  --border-strong: #b7bfc9;
  --ink: #17202a;
  --ink-2: #445162;
  --ink-3: #6b7683;

  /* Brand */
  --navy: #14304d;
  --navy-2: #1d3f63;
  --accent: #1f6feb;
  --accent-ink: #ffffff;

  /* Semantic */
  --info: #4a5a6a;
  --plan: #b45309;      /* Plan for Change (amber/brown) */
  --stay: #1f6feb;      /* Stay Informed (blue) */
  --fix: #b42318;       /* Prevent or Fix Issues (red) */
  --ok: #227148;
  --warn: #9a6a00;

  --radius: 2px;
  --shadow: 0 1px 0 rgba(16,24,40,.04), 0 1px 2px rgba(16,24,40,.06);
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Top bar ---- */
.topbar {
  background: var(--navy);
  color: #fff;
  border-bottom: 3px solid var(--accent);
}
.topbar-inner {
  max-width: 1360px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 28px; height: 54px;
}
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: #fff; }
.brand:hover { text-decoration: none; }
/* Logo is navy — sit it on a white chip so it stays visible on the navy bar. */
.brand-logo { height: 40px; width: auto; display: block; background: #fff; padding: 3px 7px; border-radius: 3px; }
.brand-sub { color: #c7d2de; font-size: 12px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; }
@media (max-width: 560px) { .brand-sub { display: none; } }
.nav { display: flex; gap: 2px; margin-left: auto; height: 100%; }
.nav a {
  color: #c7d2de; text-decoration: none; display: flex; align-items: center;
  padding: 0 16px; font-size: 13px; font-weight: 600; letter-spacing: .3px;
  border-bottom: 3px solid transparent; margin-bottom: -3px; text-transform: uppercase;
}
.nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav a.active { color: #fff; border-bottom-color: var(--accent); }

/* DE|EN language toggle (customer/public topbar) */
.lang-toggle { display: flex; align-items: center; gap: 2px; margin-left: 12px; }
.lang-btn {
  background: rgba(255,255,255,.08); color: #c7d2de; border: 1px solid rgba(255,255,255,.14);
  font-size: 11px; font-weight: 700; letter-spacing: .4px; padding: 3px 8px; cursor: pointer;
  border-radius: 4px;
}
.lang-btn:hover { color: #fff; background: rgba(255,255,255,.16); }
.lang-btn.active { color: #fff; background: var(--accent); border-color: var(--accent); }

/* ---- Layout ---- */
.wrap { max-width: 1360px; margin: 0 auto; padding: 20px; }
.page-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px; }
.page-head h1 { font-size: 20px; margin: 0; font-weight: 700; }
.page-head .sub { color: var(--ink-3); font-size: 13px; }

/* ---- KPI strip (business, not demo cards) ---- */
.kpis { display: flex; gap: 0; border: 1px solid var(--border); background: var(--surface); margin-bottom: 16px; }
.kpi { flex: 1; padding: 12px 16px; border-right: 1px solid var(--border); }
.kpi:last-child { border-right: 0; }
.kpi .label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-3); font-weight: 600; }
.kpi .value { font-size: 24px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi .value.accent { color: var(--accent); }
.kpi .value.warn { color: var(--fix); }

/* ---- Toolbar ---- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  padding: 10px; margin-bottom: 14px;
}
.toolbar .grow { flex: 1 1 220px; }
.toolbar .spacer { flex: 1; }

input, select, textarea, button {
  font-family: var(--sans); font-size: 13px; color: var(--ink);
}
input[type=text], input[type=search], input[type=date], select, textarea {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 7px 9px; height: 34px;
}
textarea { height: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); user-select: none; cursor: pointer; }
label.check > input[type=checkbox] { flex: 0 0 auto; margin: 0; }

.btn {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  padding: 7px 13px; height: 34px; border-radius: var(--radius); cursor: pointer; font-weight: 600;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1a5fd0; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 28px; padding: 4px 9px; font-size: 12px; }

/* ---- Cards (public/customer) ---- */
.list { display: grid; gap: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--border-strong);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.card.changed { border-left-color: var(--fix); }
.card.newmsg { border-left-color: var(--accent); }
.card h3 { margin: 0 0 6px; font-size: 15px; font-weight: 650; }
/* Meta rows (id + badges + small text) — flex everywhere so gaps are consistent across
   cards, tables, the reader and the admin side panel. */
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--ink-3); font-size: 12px; }
.card .id { font-family: var(--mono); font-size: 12px; color: var(--ink-3); }
/* MC id: isolate selection so a click/double-click grabs exactly the id, not neighbouring labels. */
.id { font-family: var(--mono); -webkit-user-select: all; user-select: all; }
.openlink {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 22px; text-decoration: none; font-size: 15px; line-height: 1;
  color: var(--accent); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); user-select: none;
}
.openlink:hover { border-color: var(--accent); background: #f0f6ff; }
/* MC meta row (presentation list, not a .card): make it a flex container so gap applies. */
.mcmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
/* Presentation row: bold title, optional summary line above the meta row. */
.t.title { font-weight: 600; }
.summary-line { font-size: 12px; color: var(--ink-2); line-height: 1.35; margin: 2px 0; }
.card .row-links { display: flex; gap: 8px; margin-top: 10px; }

/* ---- Service filter-bar (presentation view) ---- */
.filter-bar {
  display: flex; gap: 12px; align-items: stretch;
  margin: 0 0 10px; padding: 8px 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.filter-bar-left { flex: 0 0 15%; min-width: 140px; display: flex; flex-direction: column; gap: 6px; }
.filter-bar-left .btn { width: 100%; justify-content: center; white-space: nowrap; }
.filter-bar-svcs {
  flex: 1 1 auto; display: flex; flex-wrap: wrap; gap: 4px 14px;
  align-content: flex-start; border-left: 1px solid var(--border); padding-left: 12px;
}
.filter-bar-svcs label { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; white-space: nowrap; cursor: pointer; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px; padding: 2px 7px; border-radius: var(--radius);
  border: 1px solid transparent; white-space: nowrap;
}
.badge.cat-informational { background: #eef1f4; color: var(--info); border-color: #dbe1e8; }
.badge.cat-plan-for-change { background: #fdf2e3; color: var(--plan); border-color: #f5dcb3; }
.badge.cat-stay-informed { background: #e8f1fe; color: var(--stay); border-color: #cfe0fb; }
.badge.cat-prevent-or-fix-issues { background: #fdecea; color: var(--fix); border-color: #f6cfca; }
.badge.impact-3 { background: #fdecea; color: var(--fix); border-color: #f6cfca; }
.badge.impact-2 { background: #fdf2e3; color: var(--plan); border-color: #f5dcb3; }
.badge.impact-1 { background: #eef1f4; color: var(--info); border-color: #dbe1e8; }
.badge.impact-0 { background: #f4f5f7; color: var(--ink-3); border-color: var(--border); }
.badge.new { background: var(--accent); color: #fff; }
.badge.changed { background: var(--fix); color: #fff; }
.badge.major { background: #2a2f36; color: #fff; }
.badge.critical { background: #d92d20; color: #fff; border-color: #b42318; }
.tag { font-size: 11px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; }

/* ---- Data table (admin) ---- */
.table-wrap { border: 1px solid var(--border); background: var(--surface); overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.grid thead th {
  position: sticky; top: 0; background: var(--surface-2); z-index: 1;
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-3);
  border-bottom: 2px solid var(--border-strong); cursor: default; white-space: nowrap;
}
table.grid tbody tr:hover { background: #f3f7fd; }
table.grid td.title { max-width: 460px; }
table.grid td.title .t { font-weight: 600; }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid .rowbtn { cursor: pointer; }

/* ---- Panel / drawer ---- */
.overlay { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: none; z-index: 40; }
.overlay.open { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(1080px, 92vw);
  background: var(--surface); border-left: 1px solid var(--border-strong);
  box-shadow: -8px 0 24px rgba(16,24,40,.18); transform: translateX(100%);
  transition: transform .18s ease; z-index: 50; display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }

/* Dual-panel editor: readable change on the left (slides in from the left), settings on the
   right (as before), ~10% clickable gap in the middle (the overlay) to dismiss. */
.drawer.dual-right { width: 45vw; }
.drawer.dual-left {
  left: 0; right: auto; width: 45vw; transform: translateX(-100%);
  border-left: 0; border-right: 1px solid var(--border-strong);
  box-shadow: 8px 0 24px rgba(16,24,40,.18);
}
.drawer.dual-left.open { transform: translateX(0); }
.drawer.dual-left .body { padding: 22px 26px; }
.drawer header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.drawer header h2 { font-size: 15px; margin: 0; }
.drawer .body { padding: 16px 18px; overflow-y: auto; }
.drawer .actions { margin-top: auto; padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-3); font-weight: 600; margin-bottom: 5px; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea { width: 100%; }
.field .hint { color: var(--ink-3); font-size: 12px; margin-top: 3px; }
/* Two-column form rows (backup settings). */
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .row2 { grid-template-columns: 1fr; } }
/* Inline status text (settings save/test feedback). */
.ok { color: var(--ok); font-size: 13px; }
.warn { color: var(--fix); font-size: 13px; }
/* RATING group: label left, impact segments start at the dropdown column (like the round rows). */
.rating-row { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.rating-lbl { min-width: 150px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-3); font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; border-right: 1px solid var(--border-strong); background: var(--surface); padding: 6px 12px; cursor: pointer; font-weight: 600; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--navy); color: #fff; }

.msgbody { font-size: 13px; color: var(--ink-2); border: 1px solid var(--border); background: var(--surface-2); padding: 10px; max-height: 220px; overflow: auto; }
.msgbody * { max-width: 100%; }

/* ---- Reader (single-change page) ---- */
.reader { max-width: 880px; margin: 0 auto; }
.reader .backlink { display: inline-block; margin-bottom: 12px; font-weight: 600; }
.reader h1 { font-size: 26px; line-height: 1.25; margin: 6px 0 10px; }
.reader-h { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-3); font-weight: 700; margin: 22px 0 8px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.reader-body { max-height: none; overflow: visible; font-size: 15px; line-height: 1.65; padding: 4px 2px; background: transparent; border: 0; }
.reader-body p { margin: 0 0 12px; }
.reader-body ul, .reader-body ol { margin: 0 0 12px; padding-left: 22px; }
.reader-body a { word-break: break-word; }
.reader section { margin-bottom: 6px; }
.reader-hist { margin: 4px 0 0; padding-left: 20px; font-size: 13px; color: var(--ink-3); line-height: 1.7; }

.empty { padding: 40px; text-align: center; color: var(--ink-3); border: 1px dashed var(--border-strong); background: var(--surface); }
.loading { padding: 30px; text-align: center; color: var(--ink-3); }
.muted { color: var(--ink-3); }
.count { color: var(--ink-3); font-size: 13px; margin-left: auto; }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }

/* ---- Responsive (phones / narrow) ---- */
@media (max-width: 760px) {
  .topbar-inner { height: auto; flex-wrap: wrap; gap: 10px; padding: 8px 14px; }
  .nav { margin-left: 0; width: 100%; }
  .nav a { padding: 8px 12px; }
  .wrap { padding: 12px; }
  .page-head { flex-wrap: wrap; gap: 6px; }
  .kpis { flex-wrap: wrap; }
  .kpi { flex: 1 0 45%; border-right: 0; border-bottom: 1px solid var(--border); }
  .toolbar { padding: 8px; }
  .toolbar .grow { flex-basis: 100%; }
  .drawer { width: 100vw; }
}

/* ---- Workloads: 3-column master/detail ---- */
.wl-cols { display: grid; grid-template-columns: 260px 1fr 1fr; gap: 12px; margin-top: 12px; align-items: start; }
.wl-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: 72vh; min-height: 160px; }
.wl-col.wl-over { outline: 2px solid var(--accent); outline-offset: -2px; }
.wl-col-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; background: var(--navy); color: #fff; border-radius: var(--radius) var(--radius) 0 0; position: sticky; top: 0; }
.wl-col-head span:first-child { font-weight: 600; word-break: break-word; }
.wl-col-body { overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.wl-count { background: rgba(255,255,255,.18); border-radius: 10px; padding: 1px 8px; font-size: 12px; flex: 0 0 auto; }
.wl-empty { font-size: 12px; padding: 14px; border: 1px dashed var(--border-strong); text-align: center; }
/* workload rows (left) */
.wl-wl { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 9px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; }
.wl-wl:hover { border-color: var(--border-strong); }
.wl-wl.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.wl-wl.active .wl-count { background: rgba(255,255,255,.25); }
.wl-wl.wl-over { outline: 2px solid var(--accent); outline-offset: -2px; }
.wl-wl-name { word-break: break-word; }
.wl-wl .wl-count { background: var(--border); color: var(--ink-2); }
/* service chips (middle/right) */
.wl-chip { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 8px; cursor: grab; }
.wl-chip.wl-drag { opacity: .5; }
.wl-chip-name { flex: 1; word-break: break-word; }
.wl-chip-count { color: var(--ink-3); font-size: 12px; min-width: 22px; text-align: right; }
.wl-move { flex: 0 0 auto; max-width: 40px; }
@media (max-width: 800px) { .wl-cols { grid-template-columns: 1fr; } .wl-col { max-height: 40vh; } }

/* ---- Import page ---- */
.badge.ok { background: #e7f4ec; color: var(--ok); border-color: #bfe0cc; }
.badge.warn { background: #fdf2e3; color: var(--warn); border-color: #f5dcb3; }
.imp-drop { border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); padding: 28px; text-align: center; margin: 12px 0; }
.imp-drop.imp-over { border-color: var(--accent); background: #f0f6ff; }
.imp-drop-inner { display: flex; flex-direction: column; gap: 8px; align-items: center; }
tr.imp-synced { opacity: .6; }
tr.imp-unknown { background: #fdf7ec; }
.imp-box { margin: 18px 0 8px; padding-top: 14px; border-top: 1px solid var(--border); }
.imp-box h2 { margin-bottom: 4px; }

/* ---- Presentation view: importance radios ---- */
.imp-radio { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--ink-2); margin-right: 4px; cursor: pointer; }
.imp-radio > input { margin: 0; }

/* ---- Client GUID login ---- */
.guidbox { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#clientLogin { display: flex; align-items: center; }

/* Excel export button — icon + green accent for prominence. */
.btn-excel { display: inline-flex; align-items: center; gap: 8px; border-color: #1D6F42; font-weight: 700; }
.btn-excel:hover { background: #eaf3ee; }
.btn-excel svg { flex: 0 0 auto; display: block; }

/* ---- Presentation evaluation (admin "Auswertung") ---- */
.eval-avg { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.eval-votes { color: var(--ink-3); font-size: 12px; margin-top: 2px; }
/* dotted underline = "hover for the tenant name" (no help-cursor "?"). */
.eval-votes span[title] { border-bottom: 1px dotted var(--border-strong); }
.eval-cmt { margin: 2px 0; }
.eval-cmt[title] { border-bottom: 1px dotted var(--border-strong); display: inline-block; }

/* Import preview: status group header row. */
tr.group-head td { background: var(--surface-2); font-weight: 700; color: var(--ink-2); border-top: 2px solid var(--border-strong); }
