:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --border: #e5e7eb;
  --border-strong: #cbd5e1;
  --ink: #0f172a;
  --ink-secondary: #475569;
  --ink-muted: #64748b;
  --accent: #0f766e;
  --accent-hover: #0d5e58;
  --accent-soft: #f0fdfa;
  --accent-border: #99f6e4;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --amber-bg: #fffbeb;
  --amber-text: #b45309;
  --amber-border: #fde68a;
  --slate-bg: #f1f5f9;
  --slate-text: #475569;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px -6px rgba(15, 23, 42, 0.08);
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ink-muted);
}

.nav-tabs {
  display: inline-flex;
  background: var(--slate-bg);
  padding: 4px;
  border-radius: 11px;
  gap: 4px;
}

.nav-tab {
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.16s ease;
}

.nav-tab:hover {
  color: var(--ink);
}

.nav-tab.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* Main */
.main-content {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 24px 64px;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* Submit View */
.submit-layout {
  max-width: 980px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.status-strip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.status-strip-left,
.status-strip-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-week-text {
  font-weight: 600;
  color: var(--ink);
}

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

.meta-stat strong {
  color: var(--ink);
  font-weight: 700;
}

.meta-divider {
  color: var(--border-strong);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-open {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

.badge-archived {
  background: var(--slate-bg);
  color: var(--slate-text);
  border: 1px solid var(--border);
}

.badge-all {
  background: var(--amber-bg);
  color: var(--amber-text);
  border: 1px solid var(--amber-border);
}

/* Form Card */
.form-card {
  padding: 24px 28px 26px;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.card-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.card-desc {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.week-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.field-label-inline {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-secondary);
}

.report-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.required {
  color: var(--danger);
}

.char-count {
  font-size: 12px;
  color: var(--ink-muted);
}

.text-input,
.textarea-input,
.select-input,
.search-input {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input,
.select-input {
  height: 40px;
  padding: 0 12px;
}

.textarea-input {
  padding: 12px 14px;
  resize: vertical;
  min-height: 190px;
  line-height: 1.65;
}

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

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-top: 8px;
}

.draft-hint {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--ink-muted);
}

.draft-hint .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-subtle);
  border-color: #94a3b8;
}

.btn-outline {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent-border);
}

.btn-outline:hover:not(:disabled) {
  background: var(--accent-soft);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--slate-bg);
  color: var(--ink);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--ink-muted);
  height: 30px;
  padding: 0 9px;
  font-size: 12.5px;
}

.btn-danger-ghost:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-full {
  width: 100%;
  height: 42px;
}

/* Receipt Card */
.receipt-card {
  padding: 20px 24px;
  border-color: var(--accent-border);
  background: linear-gradient(180deg, #f0fdfa 0%, #ffffff 55%);
}

.receipt-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.receipt-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.receipt-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.receipt-meta {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--ink-muted);
}

.receipt-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.receipt-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.receipt-col-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.receipt-text {
  font-size: 13.5px;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Password Gate */
.gate-wrap {
  min-height: 62vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
}

.gate-card {
  width: 100%;
  max-width: 420px;
  padding: 32px 28px;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.gate-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.gate-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.gate-desc {
  margin: 8px 0 22px;
  font-size: 13px;
  color: var(--ink-muted);
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.password-input-wrap {
  position: relative;
}

.password-input-wrap .text-input {
  padding-right: 54px;
}

.pwd-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
}

.pwd-toggle:hover {
  color: var(--ink);
}

.inline-error {
  margin: 0;
  font-size: 12.5px;
  color: var(--danger);
}

/* Admin Dashboard */
.dashboard-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.archive-sidebar {
  padding: 16px;
  position: sticky;
  top: 84px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.sidebar-title {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
}

.count-pill {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  background: var(--slate-bg);
  padding: 2px 8px;
  border-radius: 999px;
}

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

.archive-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.14s ease;
}

.archive-item:hover {
  background: var(--surface-subtle);
  border-color: var(--border);
}

.archive-item.active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.archive-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.archive-week-key {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
}

.archive-item.active .archive-week-key {
  color: var(--accent);
}

.archive-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
}

.archive-item-bottom {
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-muted);
}

.archive-status-dot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
}

.archive-status-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
}

.archive-status-dot.open::before {
  background: #10b981;
}

/* Dashboard Main */
.dashboard-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.toolbar-card {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.toolbar-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.dashboard-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.dashboard-sub {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--ink-muted);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.toolbar-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 380px;
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  pointer-events: none;
}

.search-input {
  height: 36px;
  padding: 0 12px 0 34px;
}

.toolbar-right-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-switch {
  display: inline-flex;
  background: var(--slate-bg);
  padding: 3px;
  border-radius: 8px;
}

.view-switch-btn {
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.view-switch-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Report Cards */
.reports-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.report-item-card {
  padding: 18px 20px;
}

.report-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.report-author {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #e2e8f0;
  color: #1e293b;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.author-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.author-meta {
  font-size: 12px;
  color: var(--ink-muted);
}

.report-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.report-block {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.report-block-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.report-block-label.plan {
  color: #2563eb;
}

.report-block-content {
  font-size: 13.5px;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
}

/* Table View */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
}

.reports-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 13.5px;
}

.reports-table th {
  background: var(--surface-subtle);
  color: var(--ink-secondary);
  font-weight: 700;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.reports-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.reports-table tr:last-child td {
  border-bottom: none;
}

.cell-pre {
  white-space: pre-wrap;
  word-break: break-word;
  min-width: 220px;
  line-height: 1.6;
}

/* Empty State */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-muted);
}

.empty-state-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-secondary);
}

/* Toast */
.toast-host {
  position: fixed;
  top: 76px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: #0f172a;
  color: #ffffff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
  max-width: 340px;
  animation: toastIn 0.2s ease;
}

.toast.success {
  background: #065f46;
}

.toast.error {
  background: #991b1b;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 960px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
  .archive-sidebar {
    position: static;
  }
  .archive-list {
    max-height: 220px;
  }
}

@media (max-width: 720px) {
  .topbar-inner {
    padding: 10px 14px;
    flex-direction: column;
    align-items: stretch;
  }
  .nav-tabs {
    width: 100%;
    justify-content: stretch;
  }
  .nav-tab {
    flex: 1;
    justify-content: center;
  }
  .main-content {
    padding: 16px 14px 48px;
  }
  .form-card {
    padding: 18px 16px;
  }
  .form-grid-two,
  .receipt-body,
  .report-columns {
    grid-template-columns: 1fr;
  }
  .card-header {
    flex-direction: column;
  }
}
