:root {
  --ink: #e8f3ff;
  --muted: #93a4b8;
  --dim: #66768b;
  --bg: #070b12;
  --bg2: #0c1320;
  --panel: rgba(14, 23, 38, 0.86);
  --panel2: rgba(19, 31, 52, 0.88);
  --line: rgba(130, 166, 213, 0.22);
  --line2: rgba(130, 166, 213, 0.36);
  --blue: #54b6ff;
  --cyan: #52ffe0;
  --green: #62f28f;
  --amber: #ffcd66;
  --orange: #ff8f55;
  --red: #ff6170;
  --purple: #b68cff;
  --shadow: 0 24px 80px rgba(0,0,0,.45);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 18% -8%, rgba(84,182,255,.28), transparent 32rem),
    radial-gradient(circle at 88% 10%, rgba(182,140,255,.20), transparent 30rem),
    radial-gradient(circle at 56% 108%, rgba(82,255,224,.16), transparent 34rem),
    linear-gradient(135deg, #060911, #0a1220 55%, #050914);
  overflow-x: hidden;
}

.scanlines,
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.scanlines {
  background: repeating-linear-gradient(to bottom, rgba(255,255,255,.024), rgba(255,255,255,.024) 1px, transparent 1px, transparent 4px);
  mix-blend-mode: soft-light;
}
.noise {
  opacity: .08;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 220 220' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.65'/%3E%3C/svg%3E");
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1780px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar,
.command-strip,
.workspace,
.panel,
.modal-card {
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(135deg, rgba(13,22,37,.94), rgba(9,15,25,.78));
  box-shadow: var(--shadow);
}

.brand-block { display: flex; align-items: center; gap: 16px; }
.brand-mark {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-weight: 900;
  letter-spacing: -1px;
  color: #06101c;
  background: conic-gradient(from 160deg, var(--cyan), var(--blue), var(--purple), var(--cyan));
  box-shadow: 0 0 32px rgba(84,182,255,.3), inset 0 0 20px rgba(255,255,255,.32);
}
.eyebrow {
  margin: 0 0 3px;
  color: var(--cyan);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .18em;
  font-weight: 800;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; font-size: clamp(1.5rem, 3vw, 2.35rem); letter-spacing: -.05em; }
h1 span { color: var(--blue); }
h2 { margin-bottom: 0; font-size: 1.02rem; letter-spacing: -.02em; }
h3 { margin-bottom: 0; font-size: .88rem; }

.shift-controls { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.btn {
  border: 1px solid var(--line2);
  border-radius: 14px;
  padding: 11px 14px;
  color: var(--ink);
  background: rgba(255,255,255,.05);
  font-weight: 850;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease, opacity .18s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,.16);
}
.btn:hover:not(:disabled) { transform: translateY(-2px); border-color: rgba(82,255,224,.55); background: rgba(82,255,224,.09); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { color: #04101a; border: 0; background: linear-gradient(135deg, var(--cyan), var(--blue)); }
.btn.danger { color: var(--red); }
.btn.ghost { background: rgba(255,255,255,.035); }
.btn.wide { justify-content: center; text-align: center; min-height: 62px; }

.command-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.metric-card {
  min-height: 106px;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 15px;
  background: linear-gradient(180deg, rgba(20,33,55,.84), rgba(10,17,29,.66));
  box-shadow: 0 16px 40px rgba(0,0,0,.2);
  position: relative;
  overflow: hidden;
}
.metric-card.hot::after {
  content: "";
  position: absolute;
  inset: auto -30px -44px auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(82,255,224,.2);
  filter: blur(10px);
}
.metric-label { display: block; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 800; }
.metric-card strong { display: block; margin-top: 8px; font-family: var(--mono); font-size: clamp(1.35rem, 2.3vw, 2.05rem); line-height: 1; }
.metric-card small { display: block; margin-top: 8px; color: var(--dim); font-size: .78rem; }
.meter { height: 8px; margin-top: 14px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.meter span { display: block; height: 100%; width: 82%; background: linear-gradient(90deg, var(--red), var(--amber), var(--green)); transition: width .4s ease; }

.workspace { display: grid; grid-template-columns: 310px minmax(0, 1fr) 350px; gap: 14px; align-items: start; }
.left-rail, .right-rail { display: grid; gap: 14px; }
.panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: 0 18px 58px rgba(0,0,0,.28);
  padding: 16px;
}
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-title.compact { margin-bottom: 10px; }
.panel-title span { color: var(--muted); font-family: var(--mono); font-size: .78rem; }
.live-pill { color: #05120d !important; background: var(--green); padding: 3px 8px; border-radius: 999px; font-weight: 900; animation: glow 1.4s ease-in-out infinite alternate; }
@keyframes glow { from { box-shadow: 0 0 0 rgba(98,242,143,0); } to { box-shadow: 0 0 20px rgba(98,242,143,.45); } }

.queue-list, .event-feed, .kb-list, .achievement-list { display: grid; gap: 9px; }
.queue-list { max-height: 520px; overflow: auto; padding-right: 3px; }
.queue-item, .event-item, .kb-item, .achievement-item {
  border: 1px solid rgba(130,166,213,.16);
  border-radius: 16px;
  background: rgba(255,255,255,.045);
  padding: 12px;
}
.queue-item { cursor: pointer; border-left: 4px solid var(--blue); }
.queue-item.active { background: rgba(84,182,255,.11); border-color: rgba(84,182,255,.45); }
.queue-item.critical { border-left-color: var(--red); }
.queue-item.high { border-left-color: var(--amber); }
.queue-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 850; }
.queue-meta, .event-item, .kb-item p, .achievement-item p { color: var(--muted); font-size: .82rem; line-height: 1.45; }
.queue-meta { margin-top: 6px; font-family: var(--mono); }

.ticket-console { min-height: 720px; }
.ticket-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.ticket-badges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.badge, .timer {
  border: 1px solid var(--line2);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--blue);
  background: rgba(84,182,255,.08);
  font-family: var(--mono);
  font-size: .8rem;
  font-weight: 900;
  text-transform: uppercase;
}
.badge.muted { color: var(--muted); background: rgba(255,255,255,.04); }
.badge.high { color: var(--amber); background: rgba(255,205,102,.11); }
.badge.critical { color: var(--red); background: rgba(255,97,112,.11); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .58; } }
.timer.danger { color: var(--red); }
.timer.warn { color: var(--amber); }

.customer-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  border: 1px solid rgba(130,166,213,.16);
  border-radius: 20px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(255,255,255,.065), rgba(255,255,255,.028));
}
.avatar {
  width: 54px; height: 54px; border-radius: 18px;
  display: grid; place-items: center;
  color: #07101c; font-family: var(--mono); font-size: 1.35rem; font-weight: 1000;
  background: linear-gradient(135deg, var(--amber), var(--orange));
}
#customerDomain { display: block; color: var(--cyan); font-family: var(--mono); font-size: .84rem; margin-top: 4px; }
.customer-mood { color: var(--muted); font-size: .82rem; font-weight: 800; }
.customer-message {
  margin: 14px 0;
  padding: 18px;
  border-left: 4px solid var(--cyan);
  border-radius: 18px;
  background: rgba(82,255,224,.055);
  color: #dcebff;
  font-size: 1rem;
  line-height: 1.58;
}

.diagnostic-layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 14px; }
.toolbox, .terminal, .resolution-zone, .reply-zone {
  border: 1px solid rgba(130,166,213,.15);
  border-radius: 20px;
  background: rgba(4,8,14,.36);
  padding: 14px;
}
.tool-grid { display: grid; gap: 8px; }
.tool-btn, .action-btn, .reply-btn, .quiz-btn {
  width: 100%;
  border: 1px solid rgba(130,166,213,.2);
  border-radius: 15px;
  padding: 11px;
  color: var(--ink);
  background: rgba(255,255,255,.045);
  text-align: left;
  cursor: pointer;
  transition: .18s ease;
}
.tool-btn:hover, .action-btn:hover, .reply-btn:hover, .quiz-btn:hover { background: rgba(82,255,224,.08); border-color: rgba(82,255,224,.5); transform: translateY(-1px); }
.tool-btn.used { border-color: rgba(98,242,143,.45); background: rgba(98,242,143,.08); }
.tool-btn strong, .action-btn strong, .reply-btn strong { display: block; font-size: .88rem; }
.tool-btn span, .action-btn span, .reply-btn span { display: block; margin-top: 4px; color: var(--muted); font-size: .78rem; line-height: 1.35; }

.terminal { min-height: 290px; padding: 0; overflow: hidden; }
.terminal-bar {
  display: flex; align-items: center; gap: 7px;
  padding: 11px 13px;
  background: rgba(255,255,255,.06);
  border-bottom: 1px solid rgba(130,166,213,.14);
  font-family: var(--mono);
  font-size: .82rem;
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.red { background: var(--red); } .dot.yellow { background: var(--amber); } .dot.green { background: var(--green); }
.link-btn { margin-left: auto; border: 0; color: var(--cyan); background: none; cursor: pointer; font-family: var(--mono); }
pre {
  margin: 0;
  padding: 15px;
  min-height: 242px;
  max-height: 350px;
  overflow: auto;
  color: #d8ffe9;
  font-family: var(--mono);
  font-size: .83rem;
  line-height: 1.55;
  white-space: pre-wrap;
}
.terminal .ok { color: var(--green); }
.terminal .bad { color: var(--red); }
.terminal .warn { color: var(--amber); }
.terminal .info { color: var(--blue); }

.resolution-zone, .reply-zone { margin-top: 14px; }
.action-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.action-btn.correct { border-color: var(--green); background: rgba(98,242,143,.12); }
.action-btn.wrong { border-color: var(--red); background: rgba(255,97,112,.12); }
.reply-options { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; }

.search-input {
  width: 100%;
  margin-bottom: 12px;
  border: 1px solid rgba(130,166,213,.22);
  border-radius: 14px;
  padding: 11px 12px;
  color: var(--ink);
  background: rgba(255,255,255,.05);
  outline: none;
}
.search-input:focus { border-color: rgba(82,255,224,.58); box-shadow: 0 0 0 4px rgba(82,255,224,.08); }
.kb-list { max-height: 325px; overflow: auto; padding-right: 3px; }
.kb-item h4, .achievement-item h4 { margin: 0 0 7px; font-size: .9rem; }
.kb-item button { margin-top: 8px; }
.quiz-box p { color: var(--muted); line-height: 1.55; }
.quiz-options { display: grid; gap: 8px; margin-top: 12px; }
.quiz-btn.correct { border-color: var(--green); background: rgba(98,242,143,.12); }
.quiz-btn.wrong { border-color: var(--red); background: rgba(255,97,112,.12); }
.achievement-item.locked { opacity: .47; filter: grayscale(1); }

.empty-state { margin: 0; color: var(--dim); font-style: italic; line-height: 1.45; }
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 12;
  max-width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line2);
  border-radius: 18px;
  padding: 14px 16px;
  color: var(--ink);
  background: rgba(12,19,32,.96);
  box-shadow: var(--shadow);
  animation: toastIn .25s ease, toastOut .25s ease 4.2s forwards;
}
.toast.good { border-color: rgba(98,242,143,.55); }
.toast.bad { border-color: rgba(255,97,112,.55); }
.toast strong { display: block; margin-bottom: 4px; }
@keyframes toastIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastOut { to { transform: translateY(20px); opacity: 0; } }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2,6,12,.78);
}
.modal.hidden { display: none; }
.modal-card {
  width: min(720px, 100%);
  max-height: 88vh;
  overflow: auto;
  border: 1px solid var(--line2);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(16,27,46,.98), rgba(8,13,23,.98));
  box-shadow: var(--shadow);
  padding: 24px;
  position: relative;
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px;
  border-radius: 50%; border: 1px solid var(--line2);
  color: var(--ink); background: rgba(255,255,255,.05);
  cursor: pointer; font-size: 1.4rem;
}
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.summary-tile { border: 1px solid var(--line); border-radius: 18px; padding: 14px; background: rgba(255,255,255,.045); }
.summary-tile span { display: block; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; }
.summary-tile strong { display: block; margin-top: 8px; font-family: var(--mono); font-size: 1.45rem; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,.035); border-radius: 999px; }
::-webkit-scrollbar-thumb { background: rgba(130,166,213,.28); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(82,255,224,.4); }

@media (max-width: 1320px) {
  .workspace { grid-template-columns: 290px minmax(0,1fr); }
  .right-rail { grid-column: 1 / -1; grid-template-columns: repeat(3, minmax(0,1fr)); }
  .kb-list { max-height: 270px; }
}
@media (max-width: 980px) {
  .command-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .workspace { grid-template-columns: 1fr; }
  .right-rail { grid-template-columns: 1fr; }
  .diagnostic-layout { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .app-shell { width: min(100vw - 16px, 1780px); padding-top: 8px; }
  .topbar, .ticket-toolbar, .customer-card { grid-template-columns: 1fr; flex-direction: column; align-items: stretch; }
  .command-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card { min-height: 94px; }
  .action-grid, .reply-options, .summary-grid { grid-template-columns: 1fr; }
  .shift-controls { justify-content: stretch; }
  .shift-controls .btn { flex: 1; }
}
