:root {
  --navy: #0b2e4f;
  --navy-2: #123c63;
  --teal: #0e7c86;
  --teal-light: #e6f2f3;
  --slate: #3c4a5a;
  --grey: #6b7785;
  --line: #dde5ea;
  --bg: #f4f7f9;
  --white: #ffffff;
  --amber: #b5651d;
  --amber-bg: #fbebd9;
  --green: #2e7d5b;
  --green-bg: #e4f2ea;
  --red: #b5543f;
  --red-bg: #f7e5e1;
  --shadow: 0 1px 2px rgba(11, 46, 79, 0.06), 0 8px 24px rgba(11, 46, 79, 0.05);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: #1f2933;
  font-size: 15px;
  line-height: 1.45;
}

button { font: inherit; cursor: pointer; }

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  background: var(--navy);
  color: var(--white);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.brand .mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--teal);
  color: var(--white);
  font-weight: 800;
  font-size: 22px;
}
.brand strong { display: block; font-size: 16px; letter-spacing: 0.2px; }
.brand span { display: block; font-size: 12px; color: #b9cbd8; }

.tenant { display: flex; align-items: center; gap: 10px; flex: 1; font-weight: 600; }
.tenant .muted { font-weight: 400; color: #b9cbd8; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #5ad1a0; box-shadow: 0 0 0 3px rgba(90, 209, 160, 0.2); }

.actions { display: flex; gap: 8px; }

.ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: var(--white);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
}
.ghost:hover { background: rgba(255, 255, 255, 0.08); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 0 28px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.tab {
  border: 0;
  background: transparent;
  padding: 14px 16px 12px;
  color: var(--grey);
  font-weight: 600;
  border-bottom: 3px solid transparent;
}
.tab:hover { color: var(--navy); }
.tab.active { color: var(--navy); border-bottom-color: var(--teal); }

main { max-width: 1240px; margin: 0 auto; padding: 24px 28px 60px; }
.panel { display: block; }
.panel[hidden] { display: none; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .label { color: var(--grey); font-size: 12px; letter-spacing: 0.3px; text-transform: uppercase; }
.stat .value { font-size: 30px; font-weight: 700; color: var(--navy); margin-top: 4px; }
.stat .hint { color: var(--grey); font-size: 12px; margin-top: 2px; }

.banner {
  background: var(--amber-bg);
  border-left: 4px solid var(--amber);
  color: #5c3a12;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 16px;
}
.banner a { color: var(--amber); font-weight: 700; }

.split {
  display: grid;
  grid-template-columns: 1.65fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 10px;
}
.card-head h2 { margin: 0; font-size: 16px; color: var(--navy); }
.muted { color: var(--grey); font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--grey);
  padding: 8px 18px;
  background: #f8fafb;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 11px 18px; border-bottom: 1px solid #edf1f4; vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f7fbfc; }
.cell-strong { font-weight: 600; color: var(--navy); }
.cell-sub { display: block; color: var(--grey); font-size: 12px; margin-top: 1px; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.confirmed, .badge.booked, .badge.answered { background: var(--green-bg); color: var(--green); }
.badge.checked_in, .badge.in_progress, .badge.task { background: var(--teal-light); color: var(--teal); }
.badge.pending, .badge.not_started { background: #eef2f5; color: var(--slate); }
.badge.waiting_parts, .badge.transferred { background: var(--amber-bg); color: var(--amber); }
.badge.cancelled, .badge.abandoned, .badge.spam { background: var(--red-bg); color: var(--red); }
.badge.ready { background: #e8f1fb; color: #2b5f9e; }

.tasks { list-style: none; margin: 0; padding: 0 18px 12px; }
.tasks li { padding: 12px 0; border-bottom: 1px solid #edf1f4; }
.tasks li:last-child { border-bottom: 0; }
.task-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.task-top .task-summary { flex: 1; }
.task-summary { font-size: 13.5px; }
.task-meta { color: var(--grey); font-size: 12px; margin-top: 3px; }
.task-done {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--teal);
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 600;
  margin-left: auto;
}
.task-done:hover { background: var(--teal-light); }
.priority { font-size: 10.5px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; padding: 2px 7px; border-radius: 4px; }
.priority.urgent { background: var(--red-bg); color: var(--red); }
.priority.high { background: var(--amber-bg); color: var(--amber); }
.priority.normal { background: #eef2f5; color: var(--slate); }
.priority.low { background: #f4f7f9; color: var(--grey); }

.empty { color: var(--grey); font-size: 13px; padding: 16px 18px; margin: 0; }

.details { margin: 0; padding: 0 18px 18px; display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; }
.details dt { color: var(--grey); font-size: 13px; }
.details dd { margin: 0; font-size: 13.5px; }

dialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  width: min(760px, calc(100vw - 32px));
  box-shadow: 0 24px 64px rgba(11, 46, 79, 0.25);
}
dialog::backdrop { background: rgba(11, 46, 79, 0.35); }
.dialog-head { display: flex; justify-content: space-between; gap: 16px; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0 0 2px; font-size: 17px; color: var(--navy); }
.dialog-head .ghost { border-color: var(--line); color: var(--slate); }
#dialog-body { padding: 16px 20px 22px; max-height: 65vh; overflow-y: auto; }
.turn { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid #edf1f4; }
.turn:last-child { border-bottom: 0; }
.turn .who { font-weight: 700; font-size: 12px; color: var(--navy); }
.turn.caller .who { color: var(--grey); }
.turn .msg { font-size: 13.5px; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--navy);
  color: var(--white);
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: var(--shadow);
  max-width: 360px;
}

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 12px; }
  .tenant { order: 3; flex-basis: 100%; }
  main { padding: 18px 16px 48px; }
  .tabs { padding: 0 16px; }
}
