:root {
  --bg: #edf4f7;
  --surface: #ffffff;
  --soft: #f7fafc;
  --ink: #17212b;
  --muted: #637282;
  --line: #d8e1ea;
  --primary: #0f766e;
  --primary-dark: #0b4f4a;
  --blue: #2563eb;
  --nav: #102f45;
  --nav-2: #0b2234;
  --gold: #d8a329;
  --amber: #b7791f;
  --red: #b42318;
  --shadow: 0 12px 28px rgba(18, 48, 71, .10);
  --shadow-strong: 0 24px 60px rgba(16, 47, 69, .20);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #f6fafb 0%, var(--bg) 56%, #e7eff4 100%);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--blue); font-weight: 800; text-decoration: none; }

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 14px 24px;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, var(--primary) 0%, #18a08f 58%, var(--gold) 100%);
  color: #fff;
  font-weight: 950;
  box-shadow: 0 10px 22px rgba(15,118,110,.24);
}
.brand-avatar {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 14px;
  border: 2px solid rgba(15,118,110,.18);
  box-shadow: 0 10px 22px rgba(15,118,110,.18);
  flex: 0 0 auto;
}

.brand strong { display: block; font-size: 18px; }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 26px;
  align-items: center;
  padding: 56px 24px 118px;
  background:
    radial-gradient(circle at 80% 10%, rgba(216,163,41,.24), transparent 30%),
    linear-gradient(135deg, var(--nav) 0%, var(--nav-2) 100%);
  color: #fff;
}

.hero-copy { max-width: 780px; }
.eyebrow { color: #0f766e; font-size: 12px; font-weight: 950; text-transform: uppercase; }
.hero .eyebrow, .admin-sidebar .eyebrow { color: #6ee7b7; }
.hero h1 { margin: 8px 0 12px; font-size: clamp(34px, 6vw, 58px); line-height: 1; letter-spacing: 0; }
.hero p { margin: 0; color: #d6e5f2; font-size: 17px; line-height: 1.55; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.trust-row span {
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: #eaf6fb;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 850;
}

.hero-panel {
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  padding: 20px;
  box-shadow: var(--shadow-strong);
}

.hero-panel strong { display: block; font-size: 18px; }
.hero-panel span { display: block; font-size: 58px; font-weight: 950; margin: 12px 0 4px; }
.hero-panel p { font-size: 14px; }
.susi-hero-avatar {
  width: 128px;
  height: 128px;
  object-fit: cover;
  border-radius: 22px;
  display: block;
  margin: -4px 0 16px;
  border: 2px solid rgba(255,255,255,.38);
  box-shadow: 0 18px 38px rgba(0,0,0,.22);
}
.demo-screen {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
}
.demo-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255,255,255,.42);
}

.btn, .mini-btn, .ghost-btn, .icon-btn {
  border-radius: 8px;
  font-weight: 900;
}

.btn {
  border: 0;
  background: linear-gradient(135deg, var(--primary), #119b8b);
  color: #fff;
  padding: 10px 14px;
  box-shadow: 0 10px 18px rgba(15,118,110,.16);
  transition: transform .16s ease, box-shadow .16s ease;
}
.btn:hover, .mini-btn:hover, .ghost-btn:hover { transform: translateY(-1px); }

.btn.light { background: var(--primary); color: #fff; }
.btn.secondary { border: 1px solid rgba(255,255,255,.3); background: transparent; }
.btn.secondary-dark { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.btn.small { padding: 8px 10px; font-size: 13px; }
.ghost-btn, .icon-btn { border: 0; background: transparent; color: var(--ink); padding: 9px 10px; }
.mini-btn { border: 1px solid var(--line); background: #fff; color: var(--primary-dark); padding: 8px 10px; }
.text-btn { border: 0; background: transparent; color: var(--primary); padding: 0; font-weight: 900; justify-self: start; }

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 0 24px;
  margin-top: -70px;
}

.service-card, .card, .login-card, .metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.service-card {
  min-height: 154px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.service-card:hover {
  transform: translateY(-3px);
  border-color: rgba(15,118,110,.28);
  box-shadow: 0 18px 34px rgba(18,48,71,.14);
}

.service-card h3, .card h2 { margin: 0 0 8px; }
.service-card p, .card p, .login-card p { margin: 0; color: var(--muted); line-height: 1.5; }

.citizen-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 20px 24px 90px;
}

.card { padding: 18px; }
.card-head, .admin-section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.form-stack { display: grid; gap: 12px; }
label { display: grid; gap: 6px; color: #344456; font-size: 13px; font-weight: 850; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.12); }

.result-card {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
}
.empty-state { color: var(--muted); }
.iptu-line { display: grid; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--line); }

.floating-chat {
  position: fixed;
  right: 22px;
  bottom: 20px;
  z-index: 50;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), #10a192);
  color: #fff;
  padding: 12px 16px;
  font-weight: 950;
  box-shadow: var(--shadow);
}

.chat-widget {
  position: fixed;
  right: 22px;
  bottom: 76px;
  z-index: 60;
  width: min(430px, calc(100vw - 28px));
  max-height: min(720px, calc(100vh - 110px));
  display: none;
  grid-template-rows: auto auto minmax(180px, 1fr) auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(18, 48, 71, .22);
  overflow: hidden;
}

.chat-widget.open { display: grid; }
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background:
    linear-gradient(135deg, var(--nav), var(--primary-dark));
  color: #fff;
}
.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,.38);
  flex: 0 0 auto;
}
.chat-header small { display: block; color: #b9d1e5; margin-top: 2px; }
.chat-header .icon-btn { color: #fff; }

.quick-sector-row {
  display: flex;
  gap: 6px;
  padding: 10px;
  overflow: auto;
  border-bottom: 1px solid var(--line);
}
.quick-sector-row button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  padding: 7px 9px;
  font-weight: 800;
  color: var(--primary-dark);
}

.chat-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  overflow: auto;
  background: #f5f8fb;
}
.message {
  max-width: 86%;
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fff;
}
.message.user { justify-self: end; background: #e9f7f5; border-color: rgba(15,118,110,.24); }
.message.susi { justify-self: start; }
.message p { margin: 0; line-height: 1.45; }
.protocol-chip { display: inline-block; margin-top: 8px; color: var(--primary-dark); }
.pdf-link { display: inline-block; margin-top: 8px; }

.chat-form {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.chat-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.chat-file-row { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.file-pill {
  display: inline-flex;
  width: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--soft);
  color: var(--primary-dark);
}
.file-pill input { display: none; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(430px, 100%); display: grid; gap: 14px; padding: 24px; }
.login-avatar {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 270px 1fr; }
.admin-sidebar {
  background:
    linear-gradient(180deg, var(--nav) 0%, var(--nav-2) 100%);
  color: #fff;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.admin-brand small { color: #c7d7e6; }
.super-sidebar {
  background:
    radial-gradient(circle at top, rgba(37,99,235,.18), transparent 34%),
    linear-gradient(180deg, #08192a 0%, #0e2740 100%);
}
.admin-nav { display: grid; gap: 6px; }
.admin-nav button {
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px;
  background: transparent;
  color: #e5eef7;
  padding: 10px;
  text-align: left;
  font-weight: 850;
}
.admin-nav button:hover { background: rgba(255,255,255,.10); }
.sidebar-btn { margin-top: auto; }
.admin-main { min-width: 0; padding: 20px; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.admin-topbar h1 { margin: 4px 0 0; }
.admin-topbar small { display: block; color: var(--muted); margin-top: 4px; }
.topbar-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tenant-select {
  min-width: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.metric { padding: 16px; }
.metric span { display: block; color: var(--muted); font-size: 12px; font-weight: 950; text-transform: uppercase; }
.metric strong { display: block; font-size: 28px; margin-top: 8px; }
.admin-grid { display: grid; gap: 14px; }
.admin-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.compact-grid { margin-top: 12px; }
.compact-grid h3 { margin: 0 0 8px; font-size: 15px; }
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr)) auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 14px;
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 780px; }
th, td { padding: 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
th { background: var(--soft); color: var(--muted); font-size: 11px; text-transform: uppercase; }
.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(37,99,235,.10);
  color: var(--blue);
  font-weight: 900;
  font-size: 12px;
}
.status.open { background: rgba(183,121,31,.12); color: var(--amber); }
.status.closed { background: rgba(15,118,110,.12); color: var(--primary-dark); }
.status.waiting_human { background: rgba(180,35,24,.12); color: var(--red); }
.status.bot_handled { background: rgba(15,118,110,.12); color: var(--primary-dark); }
.status.active { background: rgba(15,118,110,.12); color: var(--primary-dark); }
.status.inactive { background: rgba(100,116,139,.14); color: #475569; }
.history-list { display: grid; gap: 10px; }
.history-list div { border: 1px solid var(--line); border-radius: 8px; background: var(--soft); padding: 10px; }
.history-list strong { display: block; }
.history-list p { margin: 6px 0; color: var(--muted); }
.history-list small { color: var(--muted); }
.panel-note { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.admin-section-head.compact { margin-top: 18px; }
.conversations p b { color: var(--primary-dark); }
.metric-list div { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.metric-list p { margin: 0; }
.super-shell .metric strong { font-size: 26px; }
.super-shell .card h2 { letter-spacing: 0; }
.error-page { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 24px; }

@media (max-width: 1080px) {
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero, .citizen-grid, .admin-grid.two { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  body { background: #f4f8fb; }
  .site-header, .admin-topbar { align-items: flex-start; flex-direction: column; }
  .header-actions { width: 100%; }
  .header-actions button { flex: 1 1 auto; }
  .hero { padding-bottom: 34px; }
  .hero h1 { font-size: 36px; }
  .quick-actions { grid-template-columns: 1fr; margin-top: 0; padding-top: 18px; }
  .citizen-grid { grid-template-columns: 1fr; padding-bottom: 96px; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { min-height: auto; }
  .metrics, .chat-fields { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
  .chat-widget { right: 14px; bottom: 70px; }
}
