:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --ink: #17211f;
  --muted: #66736f;
  --line: #dbe3df;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --warm: #f59e0b;
  --soft: #ecfdf5;
  font-family: "Microsoft JhengHei", "PingFang TC", "Noto Sans TC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

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

.sidebar {
  background: #102522;
  color: white;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--warm);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 20px;
}

.tabs,
.tool-grid {
  display: grid;
  gap: 10px;
}

.tool-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 16px;
}

.tab,
.tool,
.primary,
.secondary {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.tab,
.tool {
  text-align: left;
  padding: 12px 14px;
  color: #d8e7e3;
  background: rgba(255, 255, 255, 0.08);
}

.tool {
  color: var(--ink);
  background: #edf4f1;
  text-align: center;
}

.tab.active,
.tool.active {
  background: var(--warm);
  color: #1f1604;
  font-weight: 700;
}

.status {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  color: #c9d9d5;
  font-size: 14px;
}

.workspace {
  padding: 28px;
}

.view {
  display: none;
  gap: 20px;
}

.view.active {
  display: grid;
}

#ordersView,
#aiView {
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.05fr);
  align-items: start;
}

#profileView {
  max-width: 980px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 10px 30px rgba(20, 35, 31, 0.06);
}

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

.primary,
.secondary {
  min-height: 42px;
  padding: 0 18px;
  font-weight: 700;
  white-space: nowrap;
}

.primary {
  color: white;
  background: var(--accent);
}

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

.primary:disabled {
  opacity: 0.65;
  cursor: wait;
}

.secondary {
  color: var(--accent-dark);
  background: var(--soft);
  border: 1px solid #b7e4d4;
}

.small {
  min-height: 36px;
  padding: 0 12px;
}

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

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: #31413d;
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd9d5;
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fbfdfc;
  outline: none;
}

textarea {
  resize: vertical;
}

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

.output-panel {
  min-height: calc(100vh - 56px);
}

.reply-helper,
.reply-actions {
  display: none;
  border: 1px solid #b7e4d4;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
  background: var(--soft);
  color: #24423b;
}

.reply-helper.visible,
.reply-actions.visible {
  display: block;
}

.reply-helper p,
.reply-actions p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.reply-actions {
  margin-top: 14px;
}

.reply-actions .primary {
  width: 100%;
}

pre {
  margin: 0;
  padding: 18px;
  min-height: 560px;
  white-space: pre-wrap;
  word-break: break-word;
  background: #0d1b19;
  color: #e6f4ef;
  border-radius: 8px;
  line-height: 1.65;
}

.order-list {
  display: grid;
  gap: 12px;
}

.order-card,
.empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfc;
}

.order-card > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.order-card span,
.order-card p,
.empty,
.notes {
  color: var(--muted);
}

.order-card span {
  font-size: 13px;
}

.order-card p {
  margin: 8px 0;
}

.order-actions {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}

@media (max-width: 1080px) {
  .app,
  #ordersView,
  #aiView {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .workspace {
    padding: 18px;
  }
}

@media (max-width: 720px) {
  .grid,
  .tool-grid,
  .order-actions {
    grid-template-columns: 1fr;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .primary,
  .secondary {
    width: 100%;
  }
}
