:root {
  --ink: #0b1220;
  --ink-2: #152033;
  --ink-3: #1e2d45;
  --panel: #f4f7fb;
  --card: #ffffff;
  --line: #e5ebf3;
  --muted: #64748b;
  --text: #0f172a;
  --accent: #ff6a3d;
  --accent-2: #ff8a5c;
  --accent-soft: rgba(255, 106, 61, 0.12);
  --good: #16a34a;
  --bad: #dc2626;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  --radius: 18px;
  --sidebar: 268px;
  --font: "Sora", system-ui, sans-serif;
  --display: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--panel);
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; display: block; }

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

.sidebar {
  width: var(--sidebar);
  background: linear-gradient(180deg, var(--ink) 0%, #101a2e 55%, #0d1626 100%);
  color: #dbe4f0;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 22px;
}
.brand-mark {
  width: 40px; height: 40px; border-radius: 14px;
  background: linear-gradient(145deg, var(--accent), #ff9a6b);
  display: grid; place-items: center;
  box-shadow: 0 10px 24px rgba(255,106,61,.35);
  color: white; font-weight: 700;
}
.brand-name {
  font-family: var(--display);
  font-size: 1.45rem;
  color: white;
  letter-spacing: -0.03em;
}

.nav-list { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px;
  color: #a8b6c9; transition: .18s ease;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: white; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(255,106,61,.22), rgba(255,106,61,.06));
  color: white;
  box-shadow: inset 0 0 0 1px rgba(255,106,61,.25);
}
.nav-ico { width: 20px; opacity: .9; }

.sidebar-user {
  margin-top: 14px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent); color: white;
  display: grid; place-items: center; font-weight: 700;
}
.sidebar-user .meta { flex: 1; min-width: 0; }
.sidebar-user .meta strong { display: block; color: white; font-size: .92rem; }
.sidebar-user .meta span { display: block; color: #8ea0b8; font-size: .78rem; }

.main {
  flex: 1;
  min-width: 0;
  padding: 28px;
}

.page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 22px;
}
.page-head h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 2rem;
  letter-spacing: -0.03em;
}
.page-head p { margin: 6px 0 0; color: var(--muted); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--accent-soft); color: #c2410c;
  font-size: .82rem; font-weight: 600;
}

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.stat-card {
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: "";
  position: absolute; right: -20px; top: -20px;
  width: 90px; height: 90px; border-radius: 50%;
  background: var(--accent-soft);
}
.stat-label { color: var(--muted); font-size: .88rem; }
.stat-value {
  font-family: var(--display);
  font-size: 2.1rem;
  margin-top: 8px;
  letter-spacing: -0.03em;
}

.btn {
  appearance: none; border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; border-radius: 12px;
  font-weight: 600; transition: .15s ease;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #ff814f);
  color: white;
  box-shadow: 0 10px 24px rgba(255,106,61,.28);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost {
  background: white; border: 1px solid var(--line); color: var(--text);
}
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-sm { padding: 8px 12px; font-size: .88rem; border-radius: 10px; }
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: .86rem; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: #fdba8c;
  box-shadow: 0 0 0 4px rgba(255,106,61,.12);
}

.alert {
  padding: 12px 14px; border-radius: 12px; margin-bottom: 14px;
  background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0;
}
.alert-error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab {
  padding: 9px 14px; border-radius: 999px; background: white;
  border: 1px solid var(--line); color: var(--muted); font-weight: 600;
}
.tab.active { background: var(--ink); color: white; border-color: var(--ink); }

.badge {
  display: inline-flex; align-items: center;
  padding: 4px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700;
}
.badge-ok { background: #dcfce7; color: #15803d; }
.badge-warn { background: var(--accent-soft); color: #c2410c; }
.badge-muted { background: #e2e8f0; color: #475569; }

.progress {
  height: 8px; background: #eef2f7; border-radius: 999px; overflow: hidden;
}
.progress > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent), #ffb089);
}

.inbox-layout {
  display: grid;
  grid-template-columns: 320px 1fr 280px;
  gap: 14px;
  min-height: calc(100vh - 120px);
}
.inbox-list, .inbox-chat, .inbox-side {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex; flex-direction: column;
}
.thread {
  padding: 14px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.thread:hover { background: #fafcff; }
.thread.active { background: var(--accent-soft); }
.thread strong { display: block; font-size: .95rem; }
.thread small { color: var(--muted); }

.chat-head {
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
}
.chat-body {
  flex: 1; overflow: auto; padding: 18px; background:
    radial-gradient(circle at top right, rgba(255,106,61,.06), transparent 40%),
    #fbfcfe;
}
.msg {
  max-width: 75%;
  margin-bottom: 12px;
  padding: 11px 13px;
  border-radius: 16px;
  line-height: 1.45;
  font-size: .95rem;
}
.msg.visitor { background: white; border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.agent { background: var(--accent); color: white; margin-left: auto; border-bottom-right-radius: 6px; }
.msg.system {
  margin: 12px auto; max-width: 90%;
  background: transparent; color: var(--muted); text-align: center; font-size: .82rem;
}
.chat-compose {
  border-top: 1px solid var(--line);
  padding: 12px;
  display: flex; gap: 8px;
}
.chat-compose input { flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.inbox-side { padding: 16px; }
.detail-row { margin-bottom: 12px; }
.detail-row label { display: block; color: var(--muted); font-size: .78rem; margin-bottom: 3px; }
.detail-row strong { font-size: .95rem; }

.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  background: var(--ink);
}
.auth-visual {
  padding: 48px;
  color: white;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,106,61,.35), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(56,189,248,.18), transparent 35%),
    linear-gradient(160deg, #0b1220, #152033);
  display: flex; flex-direction: column; justify-content: space-between;
}
.auth-visual h1 {
  font-family: var(--display);
  font-size: clamp(2.4rem, 5vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
  max-width: 12ch;
}
.auth-panel {
  background: var(--panel);
  display: grid; place-items: center;
  padding: 32px;
}
.auth-card {
  width: min(420px, 100%);
  background: white;
  border-radius: 24px;
  padding: 28px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.landing {
  background: #071018;
  color: white;
  min-height: 100vh;
  overflow: hidden;
}
.landing-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px clamp(20px, 5vw, 72px);
}
.landing-hero {
  min-height: calc(100vh - 84px);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px 20px 80px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,106,61,.28), transparent 45%),
    radial-gradient(ellipse at 80% 80%, rgba(14,165,233,.12), transparent 40%),
    #071018;
}
.landing-hero .brand-name { font-size: clamp(3rem, 8vw, 6rem); }
.landing-hero h2 {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  max-width: 18ch;
  margin: 18px auto 10px;
  letter-spacing: -0.03em;
}
.landing-hero p { color: #9fb0c5; max-width: 42ch; margin: 0 auto 28px; }
.landing-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }

.empty {
  padding: 48px 20px; text-align: center; color: var(--muted);
}

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .inbox-layout { grid-template-columns: 280px 1fr; }
  .inbox-side { display: none; }
}
.pagination { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0; flex-wrap: wrap; }
.pagination .page-link, .pagination li a, .pagination li span {
  display: inline-flex; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: white; color: var(--text);
}
.pagination .active span, .pagination li.active span {
  background: var(--ink); color: white; border-color: var(--ink);
}

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { padding: 16px; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .grid-3, .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .inbox-layout { grid-template-columns: 1fr; }
}
