:root {
  --bg: #eef2f6;
  --panel: #ffffff;
  --line: #dbe3ec;
  --text: #17202c;
  --muted: #66758a;
  --primary: #1f6feb;
  --primary-dark: #1959bc;
  --danger: #c2410c;
  --soft: #f7f9fc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  background: #111827;
  color: #ffffff;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--primary);
  font-weight: 700;
}

.brand h1 {
  font-size: 20px;
}

.brand p {
  margin-top: 3px;
  color: #aab6c8;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 7px;
  margin-top: 18px;
}

.nav-item {
  justify-content: flex-start;
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  color: #d7deea;
}

.nav-item:hover,
.nav-item.active {
  background: #1f2937;
  border-color: rgba(255, 255, 255, .12);
  color: #ffffff;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 76px;
  padding: 14px 24px;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--line);
}

.top-actions,
.language-switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-actions {
  flex-wrap: wrap;
}

.auth-box {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.auth-box input {
  width: 120px;
  min-height: 36px;
  padding: 0 10px;
}

.auth-box span {
  color: #526175;
  font-size: 13px;
  white-space: nowrap;
}

.notification-box {
  position: relative;
}

.bell-btn {
  position: relative;
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.bell-icon {
  font-weight: 800;
}

.notification-count {
  position: absolute;
  top: -7px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc2626;
  color: #ffffff;
  font-size: 11px;
  line-height: 18px;
  font-weight: 800;
}

.notification-popover {
  position: absolute;
  top: 46px;
  right: 0;
  z-index: 60;
  width: min(420px, 92vw);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .22);
}

.notification-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.notification-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

.notification-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  width: 100%;
  height: auto;
  padding: 10px;
  border: 1px solid #dbe5ef;
  border-radius: 7px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  white-space: normal;
}

.notification-item.unread {
  border-color: #bfdbfe;
  background: #f0f7ff;
}

.notification-item strong,
.notification-detail-card strong {
  display: block;
  margin-bottom: 4px;
}

.notification-item small,
.notification-detail-card small {
  color: var(--muted);
  line-height: 1.4;
}

.notification-item em {
  align-self: start;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef5ff;
  color: var(--primary);
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.notification-item.read em {
  background: #f1f5f9;
  color: #64748b;
}

.notification-detail {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.notification-detail-card {
  padding: 12px;
  border: 1px solid #dbe5ef;
  border-radius: 8px;
  background: #ffffff;
}

.notification-detail-card p {
  margin-top: 8px;
  color: #263445;
  line-height: 1.6;
  white-space: pre-wrap;
}

.notification-pager {
  justify-content: space-between;
}

.language-switch .lang-btn {
  min-height: 32px;
  padding: 0 10px;
}

.language-switch .lang-btn.active {
  background: var(--primary);
  color: #ffffff;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}

.topbar h2 {
  font-size: 22px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  background: #e9f5ee;
  color: #176b3a;
  font-size: 13px;
}

.content {
  padding: 18px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.two-col {
  grid-template-columns: minmax(0, 1.05fr) minmax(420px, .95fr);
}

.lower-grid {
  margin-top: 16px;
}

.stack {
  display: grid;
  gap: 16px;
  align-content: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.narrow-panel {
  max-width: 980px;
}

.section-title,
.inline-controls,
.items-head,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

h3 {
  font-size: 16px;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid #c9d4e1;
  border-radius: 6px;
  padding: 9px 10px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
  margin-top: 12px;
  line-height: 1.45;
}

label {
  display: block;
  color: #526175;
  font-size: 13px;
}

label input,
label textarea {
  margin-top: 6px;
}

button,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--primary);
  border-radius: 6px;
  padding: 0 13px;
  background: var(--primary);
  color: #ffffff;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

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

button.secondary,
.download-link {
  background: #ffffff;
  color: var(--primary);
}

button.secondary:hover,
.download-link:hover {
  background: #eef5ff;
}

.download-link.disabled {
  pointer-events: none;
  opacity: .48;
}

button:disabled {
  cursor: wait;
  opacity: .72;
}

pre {
  min-height: 260px;
  max-height: 380px;
  overflow: auto;
  padding: 12px;
  background: #101828;
  color: #d8f3dc;
  border-radius: 6px;
  white-space: pre-wrap;
  line-height: 1.42;
}

.hidden {
  display: none !important;
}

.parsed-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.quote-document-panel {
  grid-column: 1 / -1;
}

.summary-item {
  min-height: 70px;
  padding: 11px;
  border: 1px solid #e0e7ef;
  border-radius: 7px;
  background: var(--soft);
}

.summary-item span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.summary-item strong {
  display: block;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
}

.parsed-field {
  color: var(--muted);
}

.parsed-field input,
.parsed-field select,
.parsed-field textarea {
  margin-top: 7px;
  background: #ffffff;
}

.parsed-field textarea {
  min-height: 92px;
}

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

.inquiry-meta textarea {
  min-height: 84px;
}

.zh-details {
  margin-top: 10px;
  border: 1px solid #e0e7ef;
  border-radius: 7px;
  background: var(--soft);
}

.zh-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.zh-details textarea {
  margin-top: 0;
  border: 0;
  border-top: 1px solid #e0e7ef;
  border-radius: 0 0 7px 7px;
  background: #f3f6fa;
  color: #66758a;
}

.zh-details textarea.editable {
  background: #ffffff;
  color: var(--text);
}

.source-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid #c8e6d3;
  border-radius: 999px;
  background: #eefaf2;
  color: #176b3a;
  font-size: 12px;
  font-weight: 600;
}

.source-badge.custom {
  border-color: #f5d7a8;
  background: #fff7ed;
  color: #9a3412;
}

.zh-edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e0e7ef;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.form-grid.small {
  grid-template-columns: 1fr 160px;
}

.wide-label {
  margin-top: 12px;
}

.items-head {
  margin-top: 18px;
}

.quote-item {
  display: grid;
  grid-template-columns: 1.5fr 1.3fr .65fr .8fr .55fr 38px;
  gap: 10px;
  align-items: end;
  margin-top: 10px;
  padding: 10px;
  background: var(--soft);
  border: 1px solid #e1e8f0;
  border-radius: 8px;
}

.remove-item {
  min-width: 36px;
  padding: 0;
  border-color: var(--danger);
  background: var(--danger);
}

.remove-item:hover {
  background: #9a3412;
}

.list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.list-card,
.empty {
  padding: 12px;
  border: 1px solid #e0e7ef;
  border-radius: 7px;
  background: var(--soft);
}

.list-card strong {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.list-card span {
  color: var(--primary);
  font-size: 12px;
  font-weight: 400;
}

.list-card p,
.list-card small,
.empty {
  color: var(--muted);
  line-height: 1.45;
}

.notice {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #c8e6d3;
  border-radius: 7px;
  background: #eefaf2;
  color: #176b3a;
  font-size: 13px;
  line-height: 1.45;
}

.notice-warning {
  border-color: #f5d7a8;
  background: #fff7ed;
  color: #9a3412;
}

.suggestion-form {
  grid-template-columns: 1.2fr 1.2fr 160px;
}

.suggestion-card p {
  white-space: pre-wrap;
}

.history {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.usage-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  margin-bottom: 16px;
}

.metric {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 26px;
}

.admin-table {
  overflow-x: auto;
}

.admin-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.admin-table th,
.admin-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  word-break: break-word;
}

.admin-table th {
  background: #f8fafc;
  color: var(--muted);
  font-weight: 600;
}

.usage-time {
  white-space: nowrap;
  color: #344054;
}

.usage-col-time {
  width: 180px;
}

.usage-col-action {
  width: 190px;
}

.usage-col-ip {
  width: 130px;
}

.usage-col-status {
  width: 86px;
}

.usage-action {
  display: inline-flex;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef5ff;
  color: var(--primary);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.usage-endpoint {
  color: #526175;
  overflow-wrap: anywhere;
}

.usage-ip {
  width: 120px;
  color: #526175;
}

.usage-status {
  display: inline-flex;
  min-width: 48px;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 700;
}

.usage-status.ok {
  background: #eefaf2;
  color: #176b3a;
}

.usage-status.fail {
  background: #fff7ed;
  color: #9a3412;
}

.compact-history {
  margin-top: 18px;
}

.history-search {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.inquiry-history {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.inquiry-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid #e0e7ef;
  border-radius: 7px;
  background: var(--soft);
}

.inquiry-row strong {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}

.inquiry-row strong span {
  padding: 2px 8px;
  border-radius: 999px;
  background: #e9f5ee;
  color: #176b3a;
  font-size: 12px;
  font-weight: 600;
}

.inquiry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.inquiry-tags span {
  padding: 4px 8px;
  border: 1px solid #dbe5ef;
  border-radius: 999px;
  background: #ffffff;
  color: #526175;
  font-size: 12px;
}

.inquiry-row p,
.inquiry-row small {
  color: var(--muted);
  line-height: 1.45;
}

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

.list-actions {
  justify-content: flex-end;
  margin-top: 10px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

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

.history-column {
  display: grid;
  gap: 10px;
  align-content: start;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: none;
  max-width: 360px;
  padding: 12px 14px;
  background: #111827;
  color: #ffffff;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .48);
}

.modal-backdrop.active {
  display: flex;
}

.app-modal {
  width: min(520px, 100%);
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 14px;
  padding: 20px;
  border: 1px solid #dbe5ef;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 22px 70px rgba(15, 23, 42, .28);
}

.modal-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff7ed;
  color: #b45309;
  font-weight: 800;
}

.modal-copy h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.modal-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.missing-field-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.missing-field-list span {
  padding: 6px 10px;
  border: 1px solid #fed7aa;
  border-radius: 999px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 13px;
  font-weight: 600;
}

.modal-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

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

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

  .brand {
    padding-bottom: 12px;
  }

  .nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-item {
    width: auto;
    justify-content: center;
  }

  .two-col,
  .history,
  .history-search,
  .inquiry-row {
    grid-template-columns: 1fr;
  }

  .row-actions,
  .pager,
  .modal-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

@media (max-width: 760px) {
  .topbar,
  .section-title,
  .inline-controls,
  .button-row,
  .top-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .content {
    padding: 12px;
  }

  .form-grid,
  .form-grid.small,
  .quote-item,
  .parsed-summary,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  button,
  .download-link {
    width: 100%;
  }

  .app-modal {
    grid-template-columns: 1fr;
  }
}
