:root {
  --navy: #0d1b2a;
  --navy-soft: #1b2c3f;
  --green: #006241;
  --green-soft: #e5f2ed;
  --paper: #f4f5f3;
  --surface: #ffffff;
  --line: #d8dcd8;
  --line-dark: #bcc3be;
  --ink: #17211c;
  --muted: #657069;
  --danger: #a33a31;
  --font: "Pretendard Variable", Pretendard, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
  letter-spacing: -0.01em;
  line-height: 1.6;
  word-break: keep-all;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background: var(--paper);
}

button,
input,
textarea {
  font: inherit;
  letter-spacing: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(0, 98, 65, 0.28);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.section-number,
.eyebrow,
.brand-index,
.app-brand-index,
.history-label,
.sidebar-footer,
.conversation-heading p,
.message-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.login-body {
  background:
    linear-gradient(90deg, rgba(13, 27, 42, 0.035) 1px, transparent 1px) 0 0 / 48px 48px,
    var(--paper);
}

.login-shell {
  display: grid;
  min-height: 100vh;
}

.login-intro {
  display: flex;
  min-height: 40vh;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 22px 28px;
  color: white;
  background: var(--navy);
  border-bottom: 5px solid var(--green);
}

.brand-lockup {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  align-items: center;
  max-width: 360px;
}

.brand-lockup p {
  grid-column: 1 / -1;
  margin: 0;
  color: #aeb9c3;
  font-size: 0.67rem;
  letter-spacing: 0.13em;
}

.brand-rule {
  height: 1px;
  background: #506071;
}

.eyebrow {
  margin: 42px 0 2px;
  color: #77bda3;
}

.login-intro h1 {
  margin: 0;
  font-size: clamp(3.4rem, 16vw, 7.4rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.login-description {
  max-width: 460px;
  margin: 24px 0 0;
  color: #d6dde3;
  font-size: 1rem;
}

.security-note {
  margin: 36px 0 0;
  padding-left: 14px;
  color: #9fabb5;
  border-left: 2px solid var(--green);
  font-size: 0.76rem;
}

.login-panel {
  display: grid;
  align-items: center;
  padding: 38px 22px 54px;
}

.login-card {
  width: min(100%, 440px);
  margin: 0 auto;
}

.section-number {
  margin: 0 0 13px;
  color: var(--green);
}

.login-card h2 {
  margin: 0;
  color: var(--navy);
  font-size: 1.65rem;
  line-height: 1.25;
}

.form-description {
  margin: 8px 0 30px;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-card form {
  display: grid;
  gap: 8px;
}

.login-card label {
  margin-top: 12px;
  color: var(--navy);
  font-size: 0.8rem;
  font-weight: 700;
}

.login-card input {
  width: 100%;
  height: 50px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-dark);
  border-radius: 2px;
}

.login-card input:focus {
  border-color: var(--green);
}

.form-error {
  min-height: 24px;
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 0.8rem;
}

.primary-button {
  height: 52px;
  color: white;
  background: var(--green);
  border: 0;
  border-radius: 2px;
  font-weight: 800;
}

.primary-button:hover:not(:disabled),
.send-button:hover:not(:disabled) {
  background: #004f35;
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.login-footnote {
  margin: 20px 0 0;
  color: #7a837d;
  font-size: 0.72rem;
}

.app-body {
  overflow: hidden;
}

.app-shell {
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  display: flex;
  width: min(82vw, 304px);
  flex-direction: column;
  color: #e8ecef;
  background: var(--navy);
  transform: translateX(-102%);
  transition: transform 180ms ease;
}

.sidebar[data-open="true"] {
  transform: translateX(0);
}

.sidebar-scrim {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: none;
  padding: 0;
  background: rgba(8, 17, 27, 0.48);
  border: 0;
}

.sidebar-scrim[data-open="true"] {
  display: block;
}

.sidebar-header {
  display: flex;
  min-height: 74px;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid #2c3c4b;
}

.app-brand {
  display: flex;
  gap: 11px;
  align-items: center;
  color: white;
  text-decoration: none;
}

.app-brand-index {
  color: #72bda0;
  font-size: 0.6rem;
}

.app-brand strong {
  letter-spacing: 0.03em;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  padding: 9px;
  place-items: center;
  color: currentColor;
  background: transparent;
  border: 1px solid transparent;
}

.icon-button svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.7;
}

.new-conversation-button {
  height: 46px;
  margin: 18px;
  color: white;
  background: var(--green);
  border: 0;
  border-radius: 2px;
  font-weight: 750;
  text-align: left;
  padding: 0 14px;
}

.new-conversation-button span {
  margin-right: 8px;
  font-size: 1.1rem;
}

.history-label {
  display: flex;
  justify-content: space-between;
  padding: 6px 20px 10px;
  color: #82909d;
  font-size: 0.62rem;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 20px;
}

.history-item {
  display: grid;
  width: 100%;
  gap: 6px;
  padding: 11px 10px;
  color: #d5dce2;
  background: transparent;
  border: 0;
  border-left: 2px solid transparent;
  text-align: left;
}

.history-item:hover,
.history-item[data-active="true"] {
  color: white;
  background: #172a3b;
  border-left-color: #55a98b;
}

.history-item strong {
  overflow: hidden;
  font-size: 0.82rem;
  font-weight: 620;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item > span {
  display: flex;
  justify-content: space-between;
  color: #84919c;
  font-size: 0.66rem;
}

.history-empty {
  padding: 16px 10px;
  color: #84919c;
  font-size: 0.76rem;
}

.sidebar-footer {
  display: flex;
  min-height: 54px;
  gap: 9px;
  align-items: center;
  padding: 0 20px;
  color: #83929e;
  border-top: 1px solid #2c3c4b;
  font-size: 0.58rem;
}

.readonly-dot {
  width: 7px;
  height: 7px;
  background: #55a98b;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(85, 169, 139, 0.12);
}

.chat-main {
  display: grid;
  height: 100dvh;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background:
    linear-gradient(90deg, rgba(13, 27, 42, 0.024) 1px, transparent 1px) 0 0 / 64px 64px,
    var(--paper);
}

.topbar {
  z-index: 10;
  display: grid;
  min-height: 72px;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--line);
}

.conversation-heading {
  min-width: 0;
}

.conversation-heading p {
  margin: 0;
  color: var(--green);
  font-size: 0.56rem;
}

.conversation-heading h1 {
  overflow: hidden;
  margin: 1px 0 0;
  color: var(--navy);
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-cluster {
  display: flex;
  gap: 8px;
  align-items: center;
}

.user-copy {
  display: grid;
  justify-items: end;
}

.user-copy strong {
  max-width: 92px;
  overflow: hidden;
  color: var(--navy);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-badge {
  padding: 1px 7px;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid #bcd8cd;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 750;
}

.role-badge[data-role="master"] {
  color: var(--navy);
  background: #e8edf1;
  border-color: #c8d1d8;
}

.text-button {
  display: none;
  padding: 6px 2px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line-dark);
  font-size: 0.7rem;
}

.message-region {
  overflow-y: auto;
  overscroll-behavior: contain;
}

.empty-state {
  width: min(100% - 36px, 680px);
  margin: clamp(50px, 12vh, 120px) auto 40px;
  padding: 24px 0;
  border-top: 2px solid var(--navy);
}

.empty-state[hidden] {
  display: none;
}

.empty-state h2 {
  margin: 0;
  color: var(--navy);
  font-size: clamp(1.8rem, 8vw, 3.3rem);
  line-height: 1.2;
  letter-spacing: -0.04em;
}

.empty-state > p:not(.section-number) {
  max-width: 570px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.prompt-examples {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.prompt-examples button {
  min-height: 46px;
  padding: 9px 12px;
  color: var(--navy);
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
  font-size: 0.78rem;
}

.prompt-examples button:hover {
  border-color: var(--green);
}

.messages {
  width: min(100%, 860px);
  margin: 0 auto;
  padding: 30px 16px 40px;
}

.message {
  display: grid;
  gap: 6px;
  margin-bottom: 24px;
}

.message-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.58rem;
}

.message-bubble {
  max-width: min(92%, 720px);
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 2px 14px 14px 14px;
  box-shadow: 0 4px 18px rgba(13, 27, 42, 0.035);
}

.message-user {
  justify-items: end;
}

.message-user .message-bubble {
  color: white;
  background: var(--navy);
  border-color: var(--navy);
  border-radius: 14px 2px 14px 14px;
}

.message-text {
  margin: 0;
  white-space: pre-wrap;
  font-size: 0.88rem;
}

.source-details {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.source-details summary {
  color: var(--green);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 750;
}

.source-item {
  margin-top: 10px;
  padding: 10px;
  background: #f7f8f6;
  border-left: 2px solid var(--green);
}

.source-head {
  display: flex;
  justify-content: space-between;
  color: var(--navy);
  font-size: 0.72rem;
}

.source-head span,
.source-time {
  color: var(--muted);
  font-size: 0.65rem;
}

.source-time {
  display: block;
  overflow-wrap: anywhere;
}

.table-wrap {
  max-height: 260px;
  margin-top: 9px;
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.66rem;
  white-space: nowrap;
}

th,
td {
  padding: 7px 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  color: white;
  background: var(--navy-soft);
  font-weight: 700;
}

.csv-button,
.xlsx-button,
.retry-button {
  display: inline-block;
  margin-top: 9px;
  padding: 6px 10px;
  color: var(--green);
  background: white;
  border: 1px solid #a8cbbd;
  font-size: 0.68rem;
  font-weight: 700;
  text-decoration: none;
}

.message-error .message-bubble {
  background: #fff7f5;
  border-color: #dfb5ae;
}

.loading-dots {
  display: flex;
  width: 66px;
  gap: 5px;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: loading-pulse 900ms ease-in-out infinite;
}

.loading-dots span:nth-child(2) {
  animation-delay: 120ms;
}

.loading-dots span:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes loading-pulse {
  0%, 100% { opacity: 0.28; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

.composer {
  z-index: 10;
  position: sticky;
  bottom: 0;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  background: rgba(244, 245, 243, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.composer-inner {
  display: grid;
  width: min(100%, 860px);
  margin: 0 auto;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line-dark);
  box-shadow: 0 6px 24px rgba(13, 27, 42, 0.06);
}

.composer textarea {
  min-height: 40px;
  max-height: 144px;
  resize: none;
  padding: 9px 8px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 0.86rem;
}

.send-button {
  min-width: 64px;
  height: 40px;
  padding: 0 12px;
  color: white;
  background: var(--green);
  border: 0;
  border-radius: 2px;
  font-size: 0.78rem;
  font-weight: 800;
}

.composer > p {
  width: min(100%, 860px);
  margin: 5px auto 0;
  color: #78817c;
  font-size: 0.59rem;
  text-align: center;
}

@media (min-width: 620px) {
  .login-intro,
  .login-panel {
    padding-right: 7vw;
    padding-left: 7vw;
  }

  .text-button {
    display: block;
  }

  .user-copy strong {
    max-width: 160px;
  }

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

  .messages {
    padding-right: 28px;
    padding-left: 28px;
  }
}

@media (min-width: 880px) {
  .login-shell {
    grid-template-columns: minmax(460px, 1.05fr) minmax(420px, 0.95fr);
  }

  .login-intro {
    min-height: 100vh;
    padding: 40px 5vw;
    border-right: 5px solid var(--green);
    border-bottom: 0;
  }

  .login-panel {
    padding: 50px 6vw;
  }

  .app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .sidebar {
    position: relative;
    width: 280px;
    transform: none;
  }

  .sidebar-scrim,
  .mobile-only {
    display: none !important;
  }

  .topbar {
    min-height: 78px;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 10px 24px;
  }

  .conversation-heading h1 {
    font-size: 1.05rem;
  }

  .empty-state {
    margin-top: clamp(80px, 16vh, 160px);
  }

  .composer {
    padding: 14px 24px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
