:root {
  --bg: #eceff3;
  --surface: #ffffff;
  --border: #d4dae2;
  --border-strong: #b9c2cc;
  --text: #1f2733;
  --muted: #64707e;
  --accent: #d97706;
  --accent-dark: #b45309;
  --accent-soft: #fdf1e2;
  --steel: #33404f;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}

.en {
  color: var(--muted);
  font-size: 0.85em;
  font-weight: 500;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--steel);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}
.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-family: var(--mono);
  border-radius: 4px;
  font-size: 15px;
}
.brand h1 { margin: 0; font-size: 18px; line-height: 1.2; }
.brand p { margin: 0; font-size: 12px; }
.topbar .en { color: #c8d0da; }

.actions { display: flex; gap: 10px; }

.btn {
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.btn-ghost:hover { border-color: #fff; }

/* Layout */
.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.intro {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: 0 4px 4px 0;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.card-title {
  margin: 0;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border);
}
.card-title .no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: var(--steel);
  color: #fff;
  border-radius: 4px;
  font-size: 14px;
  font-family: var(--mono);
}
.card-title .en { font-size: 13px; }

/* Fields */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 600; font-size: 14px; }
.field-label.small { font-size: 13px; font-weight: 500; }
.field-label .en { font-weight: 500; }

.input {
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}
.input:disabled {
  background: #f2f4f6;
  color: var(--muted);
}

.hint { margin: 0; color: var(--muted); font-size: 12.5px; }
.note { margin: 0; color: var(--accent-dark); font-size: 12.5px; }

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

.input-prefix { display: flex; align-items: stretch; }
.input-prefix .prefix {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  background: #f2f4f6;
  border: 1px solid var(--border-strong);
  border-right: none;
  border-radius: 4px 0 0 4px;
  font-family: var(--mono);
  color: var(--muted);
}
.input-prefix .input { border-radius: 0 4px 4px 0; }

.time-range { display: grid; grid-template-columns: 160px 160px; gap: 14px; }

/* Fieldset sub-box */
.sub-box {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sub-box legend {
  padding: 0 8px;
  font-weight: 700;
  font-size: 14px;
  color: var(--steel);
}

/* Radio & checkbox */
.radio-group { display: flex; flex-wrap: wrap; gap: 16px; }
.radio-group.inline { gap: 16px; }
.radio, .check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 14px;
}
.radio input, .check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  margin: 0;
  flex: 0 0 auto;
}
.check-inline { margin-bottom: 2px; }

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px 18px;
}

/* Yes/No list */
.yn-list { display: flex; flex-direction: column; gap: 6px; }
.yn-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 12px;
  background: #f7f9fb;
  border: 1px solid var(--border);
  border-radius: 4px;
  flex-wrap: wrap;
}
.yn-name { font-weight: 600; font-size: 14px; }

/* Shared companies */
.shared-companies { margin-top: 4px; }
.shared-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 12px;
  padding: 8px;
  border: 1px dashed var(--border-strong);
  border-radius: 4px;
}

/* Table */
.table-wrap { overflow-x: auto; }
.rep-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 820px;
}
.rep-table th, .rep-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
}
.rep-table thead th {
  background: var(--steel);
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
}
.rep-table thead th .en { color: #c8d0da; }
.rep-table .role {
  background: #f2f4f6;
  font-weight: 600;
  white-space: nowrap;
  min-width: 150px;
}
.rep-table .role .en { display: block; font-weight: 500; }
.rep-table td input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.rep-table .input { padding: 7px 9px; font-size: 13.5px; }

/* Package cards */
.package-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.package {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.package:hover { border-color: var(--accent); }
.package input { position: absolute; top: 14px; right: 14px; width: 17px; height: 17px; accent-color: var(--accent); }
.package-name { font-weight: 700; font-size: 15px; }
.package-price { font-family: var(--mono); font-weight: 700; color: var(--accent-dark); font-size: 18px; }
.package-price .en { font-size: 12px; font-weight: 500; }
.package-note { color: var(--muted); font-size: 12.5px; }
.package:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Signature */
.signature-input { font-family: "Segoe Script", "Brush Script MT", "Comic Sans MS", cursive; font-size: 17px; }

/* Footer */
.footer {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}
.footer p { margin: 2px 0; }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--steel);
  color: #fff;
  padding: 11px 20px;
  border-radius: 6px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #b42318; }

/* Required & conditional */
.req { color: #c0392b; font-weight: 700; margin-left: 2px; }
.hidden { display: none !important; }
.input.invalid { border-color: #c0392b; box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12); }
.group-invalid { outline: 2px solid #c0392b; outline-offset: 3px; border-radius: 4px; }

/* Save bar */
.save-bar {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.save-hint { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }
.btn-lg { padding: 14px 40px; font-size: 16px; }

/* Responsive */
@media (max-width: 720px) {
  .grid-2, .grid-3, .package-grid { grid-template-columns: 1fr; }
  .time-range { grid-template-columns: 1fr 1fr; }
  .shared-row { grid-template-columns: 1fr; }
  .topbar-inner { flex-direction: column; align-items: flex-start; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; }
}
