:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #dfe4ea;
  --primary: #1b74e4;
  --primary-dark: #125bb4;
  --success: #16845b;
  --warn: #b45309;
  --danger: #b42318;
  --teal: #0f766e;
  --shadow: 0 16px 36px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(27, 116, 228, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(15, 118, 110, 0.08), transparent 28%),
    var(--bg);
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 18px;
  width: min(1180px, calc(100vw - 28px));
  min-height: calc(100vh - 28px);
  margin: 14px auto;
}

.assistant-panel,
.draft-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(223, 228, 234, 0.88);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.assistant-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.draft-panel {
  padding: 20px;
  align-self: stretch;
}

.topbar,
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  margin-top: 4px;
  font-size: 20px;
  line-height: 1.25;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
}

.status-pill {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid #bad6ff;
  border-radius: 999px;
  color: var(--primary);
  background: #eef6ff;
  font-size: 13px;
}

.conversation {
  flex: 1;
  min-height: 310px;
  padding: 22px;
  overflow: auto;
}

.message {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.message.user {
  justify-content: flex-end;
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #eaf2ff;
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
}

.message.user .avatar {
  order: 2;
  background: #e8f5f2;
  color: var(--teal);
}

.bubble {
  max-width: min(620px, 78%);
  padding: 12px 14px;
  border-radius: 8px;
  background: #f0f5ff;
  line-height: 1.55;
}

.message.user .bubble {
  background: #f2f7f5;
}

.drop-zone {
  margin: 0 22px 18px;
  border: 1px dashed #9bbbea;
  border-radius: 8px;
  background: #f8fbff;
}

.drop-zone.dragover {
  border-color: var(--primary);
  background: #eef6ff;
}

.file-input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.drop-zone label {
  display: grid;
  place-items: center;
  min-height: 132px;
  padding: 18px;
  text-align: center;
  cursor: pointer;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: 8px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 28px;
  line-height: 1;
}

.drop-zone small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.files-list {
  display: grid;
  gap: 10px;
  padding: 0 22px 22px;
}

.file-card {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.file-type {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #fff;
  background: var(--teal);
  font-size: 12px;
  font-weight: 700;
}

.file-name {
  overflow-wrap: anywhere;
  font-weight: 650;
}

.file-meta {
  color: var(--muted);
  font-size: 13px;
}

.tag {
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--success);
  background: #e9f8f1;
  font-size: 12px;
}

.expense-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 116, 228, 0.12);
}

textarea {
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hint-block {
  padding: 12px;
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  background: #f7fbff;
}

.hint-block strong {
  display: block;
  margin-bottom: 5px;
}

.hint-block p {
  color: var(--muted);
  line-height: 1.5;
}

.risk-box {
  padding: 12px;
  border: 1px solid #d9e8ff;
  border-radius: 8px;
  background: #f6faff;
}

.risk-box strong {
  display: block;
  margin-bottom: 6px;
}

.risk-box p {
  color: var(--muted);
  line-height: 1.5;
}

.risk-box.warn {
  border-color: #f5c987;
  background: #fff8ec;
}

.risk-box.warn strong {
  color: var(--warn);
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.summary-row div {
  display: grid;
  gap: 4px;
  padding: 11px;
  background: #fbfcfe;
}

.summary-row div + div {
  border-left: 1px solid var(--line);
}

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

.summary-row strong {
  font-size: 17px;
}

.primary-button,
.icon-button {
  border: 0;
  cursor: pointer;
}

.primary-button {
  min-height: 46px;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  font-weight: 700;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: var(--muted);
  background: #f2f4f7;
  font-size: 22px;
}

dialog {
  width: min(680px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(31, 41, 51, 0.28);
}

dialog::backdrop {
  background: rgba(17, 24, 39, 0.32);
}

.dialog-content {
  display: grid;
  gap: 14px;
  padding: 20px;
}

pre {
  max-height: 280px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

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

  .draft-panel {
    order: -1;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: 100%;
    min-height: 100vh;
    margin: 0;
    gap: 0;
  }

  .assistant-panel,
  .draft-panel {
    border-radius: 0;
    box-shadow: none;
  }

  .topbar {
    padding: 16px;
  }

  .conversation {
    padding: 16px;
  }

  .drop-zone {
    margin-inline: 16px;
  }

  .files-list {
    padding-inline: 16px;
  }

  .form-grid,
  .summary-row {
    grid-template-columns: 1fr;
  }

  .summary-row div + div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}
