:root {
  --bg: #f4f6f5;
  --panel: #ffffff;
  --ink: #18221e;
  --muted: #6d7872;
  --line: #dfe5e1;
  --green: #138a5b;
  --green-dark: #0d6844;
  --green-soft: #e7f5ed;
  --amber: #a96809;
  --amber-soft: #fff4dc;
  --red: #b23a36;
  --red-soft: #fcebea;
  --shadow: 0 14px 40px rgba(28, 47, 38, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  min-height: 88px;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: #10281f;
  color: white;
  box-shadow: 0 6px 24px rgba(8, 30, 20, .18);
}
.brand, .topbar-actions, .detail-heading, .section-heading, .form-actions { display: flex; align-items: center; }
.brand { gap: 14px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(145deg, #23b77c, #0f7c50); font-size: 22px; font-weight: 800;
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 20px; margin-bottom: 0; font-weight: 650; }
h2 { font-size: 23px; margin-bottom: 0; }
h3 { font-size: 17px; margin-bottom: 0; }
.eyebrow { display: block; font-size: 10px; letter-spacing: .14em; font-weight: 800; color: #78d7ad; margin-bottom: 4px; }
.topbar-actions { gap: 14px; }
.health { color: #c8d7d0; font-size: 13px; white-space: nowrap; }
.health i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #e2a935; margin-right: 6px; }
.health.ok i { background: #3ed58f; box-shadow: 0 0 0 5px rgba(62, 213, 143, .12); }
.health.error i { background: #ef615d; }

.button { border: 1px solid transparent; border-radius: 10px; padding: 10px 15px; font-weight: 650; }
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { background: white; border-color: var(--line); color: var(--ink); }
.topbar .button.secondary { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.22); color: white; }
.button.ghost { background: transparent; color: #c8d7d0; border-color: transparent; padding-left: 8px; padding-right: 8px; }
.current-user { color: white; font-size: 13px; font-weight: 650; white-space: nowrap; }
.text-button, .icon-button { border: 0; background: none; color: var(--green); font-weight: 650; }
.icon-button { width: 36px; height: 36px; border-radius: 9px; font-size: 20px; }
.icon-button:hover { background: var(--green-soft); }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding: 20px 28px 14px; }
.summary-grid article { background: var(--panel); padding: 17px 19px; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 6px 20px rgba(28,47,38,.04); }
.summary-grid span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 7px; }
.summary-grid strong { font-size: 25px; }

.workspace { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 16px; padding: 0 28px 30px; min-height: calc(100vh - 196px); }
.call-panel, .detail-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; }
.panel-heading { padding: 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.panel-heading h2 { font-size: 18px; }
.call-list { overflow-y: auto; max-height: calc(100vh - 284px); }
.call-item { width: 100%; border: 0; border-bottom: 1px solid #edf0ee; background: white; text-align: left; padding: 15px 17px; transition: .15s ease; }
.call-item:hover { background: #f8fbf9; }
.call-item.active { background: var(--green-soft); box-shadow: inset 3px 0 var(--green); }
.call-line { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.call-phone { font-weight: 750; font-size: 15px; }
.call-time { color: var(--muted); font-size: 11px; }
.call-summary { color: var(--muted); font-size: 12px; margin: 8px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.detail-panel { padding: 22px; overflow-y: auto; max-height: calc(100vh - 210px); }
.empty, .empty-detail { color: var(--muted); text-align: center; padding: 30px; }
.empty-detail { min-height: 430px; display: grid; place-content: center; }
.empty-icon { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 16px; background: var(--green-soft); color: var(--green); font-size: 24px; }
.hidden { display: none !important; }
.detail-heading { justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.detail-heading h2 { margin: 8px 0 5px; }
.muted { color: var(--muted); margin-bottom: 0; }
.badge { display: inline-flex; padding: 5px 8px; border-radius: 999px; color: var(--green-dark); background: var(--green-soft); font-size: 11px; font-weight: 750; }
.badge.neutral { background: #eef1ef; color: #667069; }
.badge.warning { background: var(--amber-soft); color: var(--amber); }
.badge.approved { background: var(--green-soft); color: var(--green-dark); }
.notice { display: none; padding: 11px 13px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; }
.notice.show { display: block; background: var(--amber-soft); color: #725119; border: 1px solid #f1d496; }
.notice.error { background: var(--red-soft); color: var(--red); border-color: #efc1bf; }
.card { border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 14px; background: #fff; }
.section-heading { justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.recording-card audio { width: 100%; height: 40px; }
textarea, input, select { width: 100%; border: 1px solid #ccd5d0; border-radius: 9px; padding: 10px 11px; background: #fbfcfb; color: var(--ink); outline: none; }
textarea { resize: vertical; line-height: 1.45; }
textarea:focus, input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(19,138,91,.1); background: white; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
label { color: #46514b; font-size: 12px; font-weight: 650; }
label input, label textarea, label select { display: block; margin-top: 6px; font-weight: 400; }
.wide { grid-column: 1 / -1; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { color: #46514b; font-size: 12px; font-weight: 650; margin-bottom: 9px; }
.service-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.service-option { display: flex; gap: 8px; align-items: flex-start; padding: 9px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfb; font-weight: 500; }
.service-option input { width: auto; margin: 2px 0 0; accent-color: var(--green); }
.service-option small { display: block; color: var(--muted); margin-top: 2px; font-weight: 400; }
.form-actions { justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); padding-top: 16px; margin-top: 17px; }
.form-message { margin-right: auto; color: var(--muted); font-size: 12px; }
.payload-card summary { cursor: pointer; font-weight: 650; }
.payload-card pre { white-space: pre-wrap; word-break: break-word; color: #415048; font-size: 12px; max-height: 320px; overflow: auto; }
.toast { position: fixed; right: 24px; bottom: 24px; padding: 12px 16px; border-radius: 10px; background: #15261f; color: white; box-shadow: var(--shadow); transform: translateY(90px); opacity: 0; transition: .2s ease; z-index: 10; }
.toast.show { transform: translateY(0); opacity: 1; }

.auth-gate { position: fixed; inset: 0; z-index: 100; background: rgba(10, 30, 22, .88); backdrop-filter: blur(8px); display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(430px, 100%); background: white; border-radius: 20px; padding: 32px; box-shadow: 0 24px 70px rgba(0,0,0,.3); }
.auth-logo { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; margin-bottom: 20px; color: white; background: linear-gradient(145deg, #23b77c, #0f7c50); font-size: 25px; font-weight: 800; }
.auth-card h2 { margin-bottom: 8px; }
.auth-form { display: grid; gap: 14px; margin-top: 22px; }
.auth-form .button { margin-top: 4px; padding: 12px 16px; }
.auth-error { min-height: 20px; margin: 14px 0 0; color: var(--red); font-size: 13px; }
.password-hint { margin: -6px 0 0; color: var(--muted); font-size: 12px; }

.settings-dialog { width: min(980px, calc(100vw - 30px)); max-height: calc(100vh - 30px); padding: 0; border: 0; border-radius: 18px; color: var(--ink); box-shadow: 0 30px 80px rgba(0,0,0,.28); }
.settings-dialog::backdrop { background: rgba(10, 30, 22, .72); backdrop-filter: blur(4px); }
.dialog-heading { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; background: white; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { font-size: 22px; }
.settings-tabs { position: sticky; top: 81px; z-index: 2; display: flex; gap: 4px; padding: 10px 24px 0; background: white; border-bottom: 1px solid var(--line); }
.settings-tab { border: 0; border-bottom: 3px solid transparent; background: transparent; padding: 11px 14px; color: var(--muted); font-weight: 650; }
.settings-tab.active { color: var(--green); border-bottom-color: var(--green); }
.settings-section { padding: 24px; }
.settings-intro { padding: 15px 17px; margin-bottom: 18px; border-radius: 12px; background: var(--green-soft); }
.settings-intro h3 { margin-bottom: 5px; }
.settings-intro p { color: #476455; margin-bottom: 0; line-height: 1.5; }
.settings-group { padding: 18px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 13px; }
.settings-group h3 { margin-bottom: 12px; }
.settings-group > p { margin: -5px 0 14px; font-size: 12px; }
.settings-group code { background: #edf1ef; padding: 2px 5px; border-radius: 4px; }
.users-list { display: grid; gap: 12px; }
.user-row { display: grid; grid-template-columns: 1.1fr 1.2fr .8fr .55fr 1.2fr auto; gap: 10px; align-items: end; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfb; }
.user-row label { min-width: 0; }
.user-role { height: 40px; display: flex; align-items: center; padding: 0 10px; border-radius: 9px; background: #eef2ef; color: #4d5a53; font-size: 12px; font-weight: 700; }
.toggle-label { height: 40px; display: flex; align-items: center; gap: 8px; }
.toggle-label input { width: auto; margin: 0; accent-color: var(--green); }
.password-form { display: grid; gap: 14px; max-width: 480px; }
.password-form .button { justify-self: start; }

@media (max-width: 800px) {
  .user-row { grid-template-columns: 1fr 1fr; }
  .settings-tabs { overflow-x: auto; }
}

@media (max-width: 900px) {
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-direction: column; align-items: flex-end; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .workspace { grid-template-columns: 1fr; }
  .call-list, .detail-panel { max-height: none; }
  .call-panel { max-height: 360px; }
}
@media (max-width: 600px) {
  .topbar, .workspace { padding-left: 14px; padding-right: 14px; }
  .topbar { flex-direction: column; }
  .topbar-actions { align-items: stretch; width: 100%; }
  .summary-grid { padding-left: 14px; padding-right: 14px; }
  .form-grid, .service-list { grid-template-columns: 1fr; }
  .detail-heading, .form-actions { align-items: stretch; flex-direction: column; }
  .settings-section, .dialog-heading { padding-left: 16px; padding-right: 16px; }
  .user-row { grid-template-columns: 1fr; }
}
