:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --line: #dfe5ec;
  --line-strong: #cbd5df;
  --text: #18202b;
  --muted: #667085;
  --muted-2: #8a94a3;
  --teal: #0f8f7e;
  --teal-dark: #0b6c60;
  --blue: #2563eb;
  --green: #23835a;
  --amber: #b7791f;
  --red: #c2414b;
  --ink: #101828;
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.08);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 16px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0f8f7e, #2563eb);
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 0 10px 26px rgba(15, 143, 126, 0.24);
}

.brand-name {
  font-size: 17px;
  font-weight: 800;
}

.brand-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  text-align: left;
}

.nav-item:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.nav-item.is-active {
  background: #edf8f6;
  border-color: #b7e3dd;
  color: var(--teal-dark);
  font-weight: 700;
}

.nav-icon {
  width: 30px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: #eef2f6;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.nav-item.is-active .nav-icon {
  background: #d4f0eb;
  color: var(--teal-dark);
}

.side-card {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--panel-soft);
}

.side-card-title {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 10px;
}

.status-row {
  min-height: 30px;
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status-row strong {
  color: var(--text);
  font-size: 12px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted-2);
  box-shadow: 0 0 0 4px rgba(138, 148, 163, 0.14);
}

.status-dot.is-live {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(35, 131, 90, 0.16);
}

.status-dot.is-warn {
  background: var(--amber);
  box-shadow: 0 0 0 4px rgba(183, 121, 31, 0.16);
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 4px;
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
  letter-spacing: 0;
}

.product-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0;
  row-gap: 4px;
}

.title-credit {
  color: var(--muted);
  font-size: clamp(13px, 1.7vw, 18px);
  font-weight: 700;
  line-height: 1.25;
}

.flag {
  position: relative;
  display: inline-block;
  width: 1.38em;
  height: 0.92em;
  margin: 0 3px;
  border: 1px solid #cbd5df;
  border-radius: 2px;
  background: #ffffff;
  vertical-align: -0.1em;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.flag-japan::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.42em;
  height: 0.42em;
  border-radius: 50%;
  background: #bc002d;
  transform: translate(-50%, -50%);
}

.credit-link {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 6px;
  font-size: 15px;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  max-width: 720px;
}

.topbar-actions,
.composer-actions,
.composer-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.small-button,
.icon-button,
.action-button {
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 13px;
  background: #ffffff;
  color: var(--text);
  font-weight: 700;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.primary-button {
  background: var(--teal);
  border-color: var(--teal);
  color: #ffffff;
}

.secondary-button:hover,
.small-button:hover,
.icon-button:hover,
.action-button:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.primary-button:hover {
  background: var(--teal-dark);
  transform: translateY(-1px);
}

.icon-button {
  width: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 18px;
}

.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

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

.metric-card {
  min-height: 112px;
  padding: 16px;
  display: grid;
  gap: 7px;
}

.metric-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric-card strong {
  font-size: 30px;
  line-height: 1;
}

.metric-trend {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.metric-trend.is-good {
  background: #e7f6ef;
  color: var(--green);
}

.metric-trend.is-watch {
  background: #fff5df;
  color: var(--amber);
}

.view-panel {
  display: none;
}

.view-panel.is-active {
  display: block;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(230px, 0.75fr) minmax(560px, 1.8fr) minmax(260px, 0.85fr);
  gap: 14px;
  align-items: start;
}

.section-grid {
  display: grid;
  gap: 14px;
}

.section-grid.two-col {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.panel {
  padding: 16px;
  min-width: 0;
}

.panel-stack {
  display: grid;
  gap: 14px;
}

.panel-heading {
  min-height: 44px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.is-ready {
  background: #e7f6ef;
  color: var(--green);
}

.badge.is-risk {
  background: #fff1f2;
  color: var(--red);
}

.checklist,
.knowledge-list,
.guardrail-list,
.automation-list,
.channel-list,
.routing-board,
.settings-list,
.source-list {
  display: grid;
  gap: 9px;
}

.check-item,
.knowledge-item,
.guardrail-item,
.automation-item,
.channel-item,
.routing-item,
.setting-row,
.source-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #ffffff;
}

.check-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 8px;
  align-items: start;
}

.check-mark {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e7f6ef;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
}

.check-item strong,
.knowledge-item strong,
.automation-item strong,
.channel-item strong,
.routing-item strong,
.setting-row strong,
.source-item strong {
  display: block;
  font-size: 13px;
  margin-bottom: 3px;
}

.check-item span,
.knowledge-item span,
.automation-item span,
.channel-item span,
.routing-item span,
.setting-row span,
.source-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.platform-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.platform-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.platform-button.is-active {
  border-color: #85d4ca;
  background: #edf8f6;
  color: var(--teal-dark);
}

.embed-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 11px;
  border-radius: 8px;
  border: 1px dashed var(--line-strong);
  background: #f8fbfd;
}

.field-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

code {
  display: block;
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inbox-panel {
  min-height: 760px;
}

.search-box input {
  width: 180px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 10px;
  background: var(--panel-soft);
}

.inbox-layout {
  display: grid;
  grid-template-columns: minmax(210px, 0.85fr) minmax(320px, 1.4fr);
  gap: 12px;
  min-height: 670px;
}

.ticket-list {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: 670px;
  overflow: auto;
  padding-right: 4px;
}

.ticket-item {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 11px;
  text-align: left;
  display: grid;
  gap: 8px;
}

.ticket-item:hover,
.ticket-item.is-active {
  border-color: #85d4ca;
  background: #f2fbf9;
}

.ticket-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.ticket-id {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.ticket-priority {
  border-radius: 999px;
  padding: 3px 7px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.ticket-priority.high {
  background: #fff1f2;
  color: var(--red);
}

.ticket-priority.medium {
  background: #fff5df;
  color: var(--amber);
}

.ticket-title {
  font-size: 13px;
  line-height: 1.35;
  font-weight: 800;
}

.ticket-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.conversation {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(210px, 1fr) auto;
  gap: 12px;
}

.conversation-header {
  min-height: 74px;
  padding: 12px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.conversation-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 7px;
}

.conversation-title-row strong {
  font-size: 16px;
}

.conversation-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.pill.is-blue {
  background: #e8f0ff;
  color: var(--blue);
}

.pill.is-green {
  background: #e7f6ef;
  color: var(--green);
}

.pill.is-amber {
  background: #fff5df;
  color: var(--amber);
}

.conversation-body {
  display: grid;
  gap: 10px;
  align-content: start;
  max-height: 300px;
  overflow: auto;
}

.message {
  width: min(92%, 580px);
  border-radius: 8px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  background: #ffffff;
}

.message.agent {
  justify-self: end;
  background: #edf8f6;
  border-color: #b7e3dd;
}

.message strong {
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}

.message p {
  margin: 0;
  color: var(--text);
  line-height: 1.55;
  font-size: 13px;
}

.reply-composer {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  display: grid;
  gap: 9px;
}

.composer-toolbar {
  justify-content: space-between;
}

select,
textarea,
.setting-row input,
.setting-row textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
}

select {
  min-height: 32px;
  padding: 0 9px;
}

textarea {
  width: 100%;
  min-height: 172px;
  resize: vertical;
  padding: 11px;
  line-height: 1.55;
}

.quality-strip {
  min-height: 34px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-right: auto;
}

.right-panel {
  display: grid;
  gap: 14px;
}

.customer-card {
  display: grid;
  gap: 10px;
}

.customer-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.customer-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.customer-row span {
  color: var(--muted);
  font-size: 12px;
}

.customer-row strong {
  font-size: 13px;
  text-align: right;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.action-button {
  min-height: 52px;
  white-space: normal;
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.integration-card {
  min-height: 138px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 8px;
  background: #ffffff;
}

.integration-card strong {
  font-size: 15px;
}

.integration-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.connector-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #edf8f6;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 900;
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5df;
  transition: 150ms ease;
}

.slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: #ffffff;
  transition: 150ms ease;
  box-shadow: 0 2px 5px rgba(16, 24, 40, 0.22);
}

.switch input:checked + .slider {
  background: var(--teal);
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
}

.bar-row {
  display: grid;
  grid-template-columns: 112px 1fr 54px;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  font-size: 13px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #e8edf2;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.setting-row {
  display: grid;
  gap: 8px;
}

.setting-row input,
.setting-row textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  min-height: 46px;
  display: none;
  align-items: center;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--ink);
  color: #ffffff;
  box-shadow: var(--shadow);
  z-index: 10;
}

.toast.is-visible {
  display: flex;
}

@media (max-width: 1280px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .inbox-panel {
    min-height: auto;
  }

  .integration-grid {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
  }
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .side-card {
    margin-top: 0;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric-grid,
  .section-grid.two-col,
  .inbox-layout,
  .integration-grid {
    grid-template-columns: 1fr;
  }

  .ticket-list {
    max-height: none;
  }
}

@media (max-width: 560px) {
  .main {
    padding: 14px;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-grid,
  .platform-picker,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .composer-actions,
  .composer-toolbar {
    width: 100%;
  }

  .primary-button,
  .secondary-button,
  .small-button {
    flex: 1 1 auto;
  }

  .search-box,
  .search-box input {
    width: 100%;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }
}
