:root {
  --sidebar-bg: #3d35a0;
  --sidebar-bg-active: rgba(255, 255, 255, 0.1);
  --sidebar-text: #f0eefb;
  --sidebar-text-muted: #b3aee0;
  --sidebar-border: rgba(255, 255, 255, 0.1);
  --auth-bg-from: #4740c4;
  --auth-bg-to: #2e2a78;

  --accent: #f0652f;
  --accent-hover: #d9531f;
  --accent-soft: #fde7dc;

  --bg: #f5f6fa;
  --surface: #ffffff;
  --text: #1a1b2e;
  --muted: #6b6e85;
  --border: #e5e7f0;
  --radius: 10px;

  --danger: #c0392b;
  --danger-soft: #fbeaea;
  --success: #2fa360;
  --success-soft: #e6f6ec;
  --warn: #b4690c;
  --warn-soft: #fdecd3;

  --navy: var(--sidebar-bg);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* --- App shell (authenticated pages: sidebar + content) --- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1.4rem 1.3rem 1.2rem;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: block;
  object-fit: cover;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 1.02rem; }
.brand-text small { color: var(--sidebar-text-muted); font-size: 0.72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-nav { flex: 1; padding: 0.5rem 0.8rem; display: flex; flex-direction: column; gap: 0.15rem; }

.nav-section-label {
  color: var(--sidebar-text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.9rem 0.7rem 0.3rem;
}

.nav-item {
  display: block;
  padding: 0.55rem 0.7rem;
  border-radius: 7px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.88rem;
}
.nav-item:hover { background: var(--sidebar-bg-active); }
.nav-item.active { background: var(--sidebar-bg-active); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  border-top: 1px solid var(--sidebar-border);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-meta { flex: 1; min-width: 0; line-height: 1.2; }
.user-meta strong { display: block; font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { color: var(--sidebar-text-muted); font-size: 0.72rem; }

.icon-button {
  background: none;
  border: none;
  color: var(--sidebar-text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem;
  line-height: 1;
}
.icon-button:hover { color: #fff; }

.app-content { flex: 1; min-width: 0; padding: 2rem 2.2rem; }

/* --- Standalone pages (login: no sidebar) --- */

.standalone-content {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--auth-bg-from), var(--auth-bg-to));
  padding: 2rem;
}

.auth-header { text-align: center; margin-bottom: 1.6rem; }
.auth-brand-mark { width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 1rem; }
.auth-title { color: #fff; font-size: 1.6rem; margin: 0 0 0.3rem; }
.auth-subtitle { color: var(--sidebar-text-muted); font-size: 0.86rem; margin: 0; }

/* --- Shared components --- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 2px rgba(20, 20, 50, 0.03);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.4rem;
}
.page-header h1 { margin: 0 0 0.2rem; }
.page-header p.hint { margin: 0; }

h1 { font-size: 1.35rem; margin-top: 0; color: var(--navy); }
h2 { font-size: 1.02rem; color: var(--navy); }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--navy); color: #fff; font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; }
th:first-child { border-top-left-radius: 6px; }
th:last-child { border-top-right-radius: 6px; }
tr:hover td { background: #fafafd; }

.day-group-row td {
  background: #f1f1f8;
  font-weight: 700;
  color: var(--navy);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.45rem 0.7rem;
}

.badge { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }
.badge-answered { background: var(--success-soft); color: var(--success); }
.badge-missed { background: var(--danger-soft); color: var(--danger); }
.badge-voicemail { background: var(--warn-soft); color: var(--warn); }
.badge-active { background: var(--success-soft); color: var(--success); }
.badge-inactive { background: var(--warn-soft); color: var(--warn); }

label { display: block; font-size: 0.83rem; margin-bottom: 0.3rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=datetime-local], input[type=date], select, textarea {
  width: 100%; padding: 0.5rem 0.65rem; border: 1px solid var(--border);
  border-radius: 7px; font-size: 0.88rem; margin-bottom: 0.9rem; background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

textarea { min-height: 3.5rem; resize: vertical; }

button, .button {
  display: inline-block; background: var(--accent); color: #fff; border: none;
  padding: 0.55rem 1.15rem; border-radius: 7px; font-size: 0.88rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
button:hover, .button:hover { background: var(--accent-hover); }
button.secondary, .button.secondary {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); font-weight: 500;
}
button.secondary:hover, .button.secondary:hover { background: #f8f8fb; }
button.danger, .button.danger { background: var(--surface); color: var(--danger); border: 1px solid var(--danger); font-weight: 500; }
button.danger:hover { background: var(--danger-soft); }

.error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f0c9c4; border-radius: 7px; padding: 0.6rem 0.9rem; margin-bottom: 1rem; font-size: 0.88rem; }
.hint { color: var(--muted); font-size: 0.82rem; }

.login-card { width: 380px; }
.login-card h2 { margin-top: 0; margin-bottom: 1.2rem; }
.login-card input[type=email], .login-card input[type=password] { border-radius: 999px; padding: 0.6rem 1.1rem; }
.login-card button { border-radius: 999px; padding: 0.7rem 1.15rem; }

.filters { display: flex; gap: 0.8rem; flex-wrap: wrap; align-items: end; margin-bottom: 1.2rem; }
.filters > div { flex: 1; min-width: 160px; }
.filters button, .filters .button { margin-bottom: 0.9rem; }

.segmented { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 0.2rem; }
.segmented a {
  padding: 0.4rem 1rem; border-radius: 999px; font-size: 0.82rem; font-weight: 600;
  color: var(--muted); text-decoration: none;
}
.segmented a.active { background: var(--navy); color: #fff; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.reason-form { display: flex; gap: 0.4rem; }
.reason-form textarea { margin-bottom: 0; }

.logo-preview { max-height: 44px; display: block; margin-bottom: 0.8rem; }

.zone-danger { border-color: #f0c9c4; background: var(--danger-soft); }
.zone-danger h2 { color: var(--danger); }

a.link { color: var(--accent); }

/* --- Sidebar report badge --- */

.nav-item-badge { display: flex; align-items: center; justify-content: space-between; }
.nav-badge {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.flash-success {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid #bfe6cf;
  border-radius: 7px;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1.2rem;
  font-size: 0.88rem;
}

/* --- Floating report widget --- */

.report-widget { position: fixed; bottom: 1.6rem; right: 1.6rem; z-index: 60; }

.report-widget summary {
  list-style: none;
  cursor: pointer;
}
.report-widget summary::-webkit-details-marker { display: none; }

.report-fab {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(217, 83, 31, 0.45);
}
.report-fab:hover { background: var(--accent-hover); }

.report-panel {
  position: absolute;
  bottom: 58px;
  right: 0;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(20, 20, 50, 0.18);
  padding: 1rem;
}

.report-tab-radio { display: none; }

.report-tabs {
  display: flex;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.9rem;
}
.report-tabs label {
  padding: 0 0 0.6rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.report-panel:has(#report-tab-new:checked) .report-tabs label[for="report-tab-new"],
.report-panel:has(#report-tab-mine:checked) .report-tabs label[for="report-tab-mine"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.report-tab-panel { display: none; max-height: 320px; overflow-y: auto; }
.report-panel:has(#report-tab-new:checked) .report-tab-panel-new { display: block; }
.report-panel:has(#report-tab-mine:checked) .report-tab-panel-mine { display: block; }

.report-type-toggle { display: flex; gap: 0.6rem; margin-bottom: 0.8rem; }
.report-type-toggle label {
  flex: 1;
  display: block;
  text-align: center;
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text);
}
.report-type-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.report-type-toggle label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
}

.report-tab-panel-new textarea { min-height: 5rem; }
.report-tab-panel-new button { width: 100%; }

.report-mine-item { border-bottom: 1px solid var(--border); padding: 0.6rem 0; font-size: 0.84rem; }
.report-mine-item:last-child { border-bottom: none; }
.report-mine-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem; }
.report-mine-item p { margin: 0.2rem 0; }

/* --- Admin reports page --- */

.resolved-reports summary { cursor: pointer; font-weight: 700; color: var(--navy); padding: 0.7rem 0.9rem; background: #f1f1f8; border-radius: 7px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.resolved-reports[open] summary { border-radius: 7px 7px 0 0; }

select.auto-submit { margin-bottom: 0; width: auto; }

/* --- Client cards --- */

.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }

.client-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(20, 20, 50, 0.03);
}
.client-card:hover { border-color: var(--accent); }

.client-card-head { display: flex; align-items: center; gap: 0.7rem; }

.client-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  object-fit: cover;
}
.client-avatar-fallback {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.client-card-head strong { display: block; font-size: 0.95rem; }
.client-card-badge { margin-left: auto; }
.client-card-date { margin-top: 0.7rem; }

/* --- Modal + wizard (checkbox/radio only, no JS) --- */

.modal-toggle, .wizard-step-radio { display: none; }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-toggle:checked ~ .modal-overlay { display: flex; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 18, 46, 0.55);
  cursor: pointer;
}

.modal-panel {
  position: relative;
  width: 420px;
  max-width: calc(100vw - 2rem);
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(20, 20, 50, 0.3);
  padding: 1.5rem;
}

.modal-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal-panel-head h2 { margin: 0; }
.modal-close { cursor: pointer; font-size: 1.3rem; color: var(--muted); line-height: 1; }
.modal-close:hover { color: var(--text); }

.wizard-steps-indicator { display: flex; gap: 1rem; border-bottom: 1px solid var(--border); margin-bottom: 1.1rem; }
.wizard-step-label {
  padding: 0 0 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.modal-panel:has(#wizard-step-1:checked) .wizard-step-label[for="wizard-step-1"],
.modal-panel:has(#wizard-step-2:checked) .wizard-step-label[for="wizard-step-2"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.wizard-panel { display: none; }
.modal-panel:has(#wizard-step-1:checked) .wizard-panel-1 { display: block; }
.modal-panel:has(#wizard-step-2:checked) .wizard-panel-2 { display: block; }

.wizard-panel .button { width: 100%; text-align: center; }
.wizard-actions { display: flex; gap: 0.6rem; }
.wizard-actions .button, .wizard-actions button { flex: 1; text-align: center; }
