:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #18202f;
  --muted: #697386;
  --line: #dbe1ea;
  --teal: #0f766e;
  --teal-soft: #e6f5f3;
  --indigo: #3547a6;
  --amber: #b46a16;
  --coral: #b64040;
  --green: #25805b;
  --shadow: 0 10px 30px rgba(26, 36, 54, 0.08);
  font-family:
    "Yu Gothic UI", "Meiryo", "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.14), transparent 34%),
    linear-gradient(300deg, rgba(180, 106, 22, 0.12), transparent 36%),
    #f7f8fb;
}

.login-panel {
  width: min(1040px, 100%);
  min-height: 620px;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 36px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 52px;
}

.brand-lockup h1 {
  margin: 10px 0 18px;
  max-width: 620px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.1;
  letter-spacing: 0;
}

.lead {
  max-width: 560px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.75;
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

.login-form {
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.login-form label,
.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

textarea {
  min-height: 118px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.login-form button,
.primary-button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--teal);
  color: #fff;
  padding: 10px 16px;
  font-weight: 700;
}

.secondary-button,
.ghost-button,
.icon-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 14px;
  font-weight: 700;
}

.ghost-button {
  color: var(--teal);
  background: var(--teal-soft);
  border-color: #bfe0dc;
}

.icon-button {
  width: 42px;
  padding: 0;
}

.login-foot {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  background: #202736;
  color: #fff;
  padding: 22px 16px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px;
}

.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  background: #f3f7f6;
  color: var(--teal);
  font-weight: 800;
}

.sidebar-brand strong,
.sidebar-brand small {
  display: block;
}

.sidebar-brand small,
.sidebar-status small,
.sidebar-status span {
  color: #b6bfce;
}

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

.nav-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #dce3ee;
  padding: 10px 11px;
  text-align: left;
  font-weight: 700;
}

.nav-list button span {
  display: grid;
  place-items: center;
  width: 22px;
  color: #96e2d8;
}

.nav-list button.active,
.nav-list button:hover {
  background: #2d384b;
  color: #fff;
}

.sidebar-status {
  margin-top: auto;
  display: grid;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 78px;
  display: flex;
  align-items: center;
  gap: 18px;
  justify-content: space-between;
  padding: 16px 28px;
  background: rgba(246, 247, 249, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar h2 {
  margin: 3px 0 0;
  font-size: 24px;
}

#menuToggle {
  display: none;
}

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

.screen-host {
  padding: 26px 28px 46px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.panel,
.metric,
.item,
.chat-window,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(26, 36, 54, 0.02);
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.panel h3,
.metric h3 {
  margin: 0;
  font-size: 17px;
}

.panel p,
.item p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.metric {
  padding: 16px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
  line-height: 1;
}

.metric small {
  color: var(--muted);
}

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

.badge.teal {
  color: #0f5f58;
  background: var(--teal-soft);
}

.badge.amber {
  color: #8c4d08;
  background: #fff2de;
}

.badge.coral {
  color: #963233;
  background: #ffe8e8;
}

.badge.indigo {
  color: #304099;
  background: #e9ecff;
}

.badge.green {
  color: #1d6849;
  background: #e7f5ee;
}

.item {
  padding: 14px;
}

.output-card {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.output-card p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

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

.list {
  display: grid;
  gap: 10px;
}

.table-wrap {
  overflow: auto;
}

.empty-state {
  display: grid;
  gap: 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 24px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.sync-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}

.sync-summary span {
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  background: #fbfcfe;
}

td {
  font-size: 14px;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
}

.chat-window {
  min-height: 580px;
  display: flex;
  flex-direction: column;
}

.messages {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 18px;
  overflow: auto;
}

.message {
  max-width: 78%;
  padding: 12px 14px;
  border-radius: 8px;
  line-height: 1.65;
}

.message.ai {
  background: var(--teal-soft);
}

.message.user {
  justify-self: end;
  background: #eceff5;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.split-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.timeline {
  position: relative;
  display: grid;
  gap: 12px;
}

.timeline-item {
  border-left: 3px solid var(--teal);
  padding: 2px 0 2px 12px;
}

.level-hero {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: stretch;
}

.level-ring {
  display: grid;
  place-items: center;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: conic-gradient(var(--teal) 0 var(--level-progress, 0%), #e6ebf2 var(--level-progress, 0%) 100%);
}

.helper-text {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.ring-inner {
  display: grid;
  place-items: center;
  width: 172px;
  height: 172px;
  border-radius: 50%;
  background: #fff;
  text-align: center;
}

.ring-inner strong {
  font-size: 46px;
}

.progress-bar {
  height: 10px;
  border-radius: 99px;
  background: #e6ebf2;
  overflow: hidden;
}

.progress-bar span {
  display: block;
  height: 100%;
  width: var(--value, 35%);
  background: var(--teal);
}

.setting-row {
  display: grid;
  grid-template-columns: 220px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.setting-note {
  justify-self: end;
  min-width: 92px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.compact-list {
  margin: 6px 0 0;
  padding-left: 18px;
}

.compact-list li {
  margin: 4px 0;
  color: var(--muted);
  line-height: 1.55;
}

.mini-block + .mini-block {
  margin-top: 12px;
}

.mini-table {
  width: 100%;
  min-width: 0;
  margin-top: 8px;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.mini-table th,
.mini-table td {
  border-top: 1px solid var(--border);
  padding: 8px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.mini-table th {
  color: var(--muted);
  font-weight: 800;
}

.switch {
  position: relative;
  width: 48px;
  height: 26px;
  border-radius: 999px;
  border: 0;
  background: #ccd4df;
}

.switch.on {
  background: var(--teal);
}

.switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.16s ease;
}

.switch.on::after {
  transform: translateX(22px);
}

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

  .sidebar {
    position: fixed;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    width: 280px;
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  #menuToggle {
    display: inline-grid;
    place-items: center;
  }

  .grid.three,
  .grid.four,
  .chat-layout,
  .level-hero,
  .split-form {
    grid-template-columns: 1fr;
  }

  .login-panel {
    grid-template-columns: 1fr;
    padding: 30px;
  }
}

@media (max-width: 700px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 14px;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions button {
    flex: 1;
  }

  .screen-host {
    padding: 16px 14px 34px;
  }

  .grid.two {
    grid-template-columns: 1fr;
  }

  .login-view {
    padding: 12px;
  }

  .login-panel {
    min-height: auto;
    padding: 22px;
  }

  .login-foot,
  .item-row,
  .output-card,
  .panel-header,
  .setting-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .message {
    max-width: 94%;
  }
}
