:root {
  --ink: #171816;
  --muted: #686b65;
  --line: #dedfd9;
  --soft-line: #ecece8;
  --paper: #ffffff;
  --canvas: #f2f3ef;
  --accent: #e8492f;
  --accent-dark: #c93822;
  --success: #1c7b4e;
  --error: #c53224;
  --focus: #246bce;
  --radius: 6px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.site-header {
  width: 100%;
  height: 82px;
  margin: 0 auto;
  padding: 0 max(20px, calc((100% - 980px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 0;
  color: white;
  background: var(--ink);
}

.brand { display: inline-flex; align-items: center; gap: 11px; font-size: 16px; font-weight: 700; }
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  color: white;
  background: var(--accent);
  border-radius: 4px;
  font-size: 17px;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--paper);
}
.icon-button:hover { border-color: #a9aaa5; background: #fafaf8; }
.icon-button svg { width: 18px; height: 18px; }
.site-header .icon-button { border-color: #4a4c47; color: white; background: #292a27; }
.site-header .icon-button:hover { border-color: #73756f; background: #363733; }

.submit-shell { width: min(100% - 40px, 720px); margin: 0 auto; padding: 64px 0 72px; }
.intro { margin-bottom: 48px; max-width: 620px; padding: 3px 0 3px 22px; border-left: 5px solid var(--accent); }
.eyebrow { margin: 0 0 12px; color: var(--accent); font-size: 11px; font-weight: 800; line-height: 1; letter-spacing: 0; }
.intro h1, .login-heading h1, .dashboard-header h1 { margin: 0; font-size: 38px; line-height: 1.25; letter-spacing: 0; }
.intro > p:last-child, .login-heading > p:last-child { margin: 16px 0 0; color: var(--muted); font-size: 15px; line-height: 1.8; }

.tip-form { display: grid; gap: 30px; padding: 34px; border-top: 4px solid var(--ink); background: var(--paper); }
.field { display: grid; gap: 9px; min-width: 0; }
.field label, fieldset legend { font-size: 14px; font-weight: 700; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; }
.field-label-row > span { color: #92948e; font-size: 12px; }
.field-label-row b { font-weight: 500; }

input, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #cfd0ca;
  border-radius: var(--radius);
  outline: none;
  color: var(--ink);
  background: var(--paper);
  transition: border-color 150ms, box-shadow 150ms;
}
input { height: 50px; padding: 0 14px; }
textarea { min-height: 220px; padding: 14px; line-height: 1.75; resize: vertical; }
input::placeholder, textarea::placeholder { color: #a0a29c; }
input:focus, textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(36, 107, 206, 0.11); }
input.invalid, textarea.invalid { border-color: var(--error); }
.field-error { min-height: 17px; margin: -3px 0 0; color: var(--error); font-size: 12px; }

fieldset { margin: 4px 0 0; padding: 27px 0 0; border: 0; border-top: 1px solid var(--line); }
fieldset legend { float: left; width: 100%; margin-bottom: 20px; }
fieldset::after { content: ""; display: block; clear: both; }
.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; clear: both; }
.primary-button, .secondary-button {
  height: 50px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: var(--radius);
  font-weight: 700;
}
.primary-button { border: 0; color: white; background: var(--ink); }
.primary-button:hover { background: #30312e; }
.primary-button:disabled { cursor: not-allowed; opacity: 0.55; }
.primary-button svg, .secondary-button svg { width: 18px; height: 18px; }
.secondary-button { padding: 0 18px; border: 1px solid var(--line); color: var(--ink); background: var(--paper); }
.secondary-button:hover { border-color: #aaaca5; background: #fafaf8; }
.form-status { min-height: 20px; margin: -16px 0 0; color: var(--error); text-align: center; font-size: 13px; }

.success-panel { padding: 54px 42px; border: 1px solid var(--line); border-top: 4px solid var(--success); border-radius: var(--radius); background: var(--paper); text-align: center; }
.success-icon { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 24px; border-radius: 50%; color: white; background: var(--success); }
.success-icon svg { width: 26px; height: 26px; }
.success-panel h2 { margin: 0; font-size: 30px; letter-spacing: 0; }
.success-panel > p:not(.eyebrow) { max-width: 430px; margin: 14px auto 26px; color: var(--muted); line-height: 1.75; }
.reference-row { max-width: 390px; margin: 0 auto 28px; padding: 15px 17px; display: flex; justify-content: space-between; border: 1px solid var(--soft-line); background: var(--canvas); font-size: 13px; }
.reference-row span { color: var(--muted); }
.success-panel .secondary-button { min-width: 130px; }

.site-footer { width: min(100% - 40px, 980px); margin: 0 auto; padding: 24px 0 30px; display: flex; justify-content: space-between; border-top: 1px solid var(--line); color: #8b8d87; font-size: 11px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 20; padding: 11px 16px; border-radius: 4px; color: white; background: var(--ink); font-size: 13px; opacity: 0; pointer-events: none; transform: translate(-50%, 10px); transition: 180ms; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Admin */
.login-view { position: relative; min-height: 100vh; display: grid; place-items: center; overflow: hidden; padding: 32px 20px; background: #e7e9e3; }
.login-view::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 32%; background: var(--ink); }
.login-panel { width: min(100%, 420px); padding: 36px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.login-panel { position: relative; z-index: 1; box-shadow: 0 14px 46px rgba(23, 24, 22, 0.12); }
.login-heading { margin: 52px 0 30px; }
.login-heading h1 { font-size: 30px; }
.login-panel form { display: grid; gap: 20px; }
.login-panel .primary-button { margin-top: 4px; }

.dashboard { min-height: 100vh; display: grid; grid-template-columns: 226px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 18px; color: #f6f6f3; background: var(--ink); }
.brand-inverse { padding: 0 8px; }
.sidebar nav { margin-top: 54px; }
.nav-item { height: 44px; display: flex; align-items: center; gap: 11px; padding: 0 12px; border-radius: 5px; color: #bbbdb7; font-size: 14px; }
.nav-item.active { color: white; background: #2d2e2b; }
.nav-item svg, .sidebar-logout svg { width: 18px; height: 18px; }
.sidebar-logout { height: 44px; margin-top: auto; display: flex; align-items: center; gap: 11px; padding: 0 12px; border: 0; color: #bbbdb7; background: transparent; }
.sidebar-logout:hover { color: white; }
.dashboard-main { min-width: 0; padding: 46px clamp(28px, 5vw, 74px) 70px; }
.dashboard-header { display: flex; align-items: center; justify-content: space-between; }
.dashboard-header h1 { font-size: 32px; }
.download-button { flex: 0 0 auto; }
.stat-row { margin-top: 40px; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.stat-block { min-width: 0; padding: 22px 24px; display: grid; gap: 10px; border-right: 1px solid var(--line); }
.stat-block:last-child { border-right: 0; }
.stat-block span { color: var(--muted); font-size: 12px; }
.stat-block strong { font-size: 26px; line-height: 1; }

.data-section { margin-top: 28px; }
.data-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 22px; margin-bottom: 14px; }
.data-toolbar h2 { margin: 0; font-size: 17px; }
.filters { display: flex; align-items: center; gap: 8px; }
.search-box { position: relative; }
.search-box svg { position: absolute; top: 50%; left: 12px; width: 17px; height: 17px; color: #777a74; transform: translateY(-50%); }
.search-box input { width: 250px; height: 40px; padding-left: 38px; font-size: 13px; }
.date-filter { height: 40px; display: flex; align-items: center; border: 1px solid #cfd0ca; border-radius: var(--radius); background: var(--paper); }
.date-filter span { padding-left: 10px; color: var(--muted); font-size: 12px; }
.date-filter input { width: 130px; height: 38px; padding: 0 8px; border: 0; font-size: 12px; }
.filters .icon-button { flex: 0 0 40px; }

.table-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { height: 45px; padding: 0 16px; color: #777a74; background: #f1f1ee; text-align: left; font-size: 11px; font-weight: 700; }
td { height: 64px; padding: 10px 16px; border-top: 1px solid var(--soft-line); font-size: 13px; vertical-align: middle; }
th:nth-child(1) { width: 162px; }
th:nth-child(2) { width: auto; }
th:nth-child(3) { width: 100px; }
th:nth-child(4) { width: 140px; }
th:nth-child(5) { width: 60px; }
.cell-time { color: var(--muted); white-space: nowrap; }
.cell-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.row-action { border: 0; color: var(--muted); background: transparent; }
.row-action:hover { color: var(--accent); }
.row-action svg { width: 18px; height: 18px; }
.empty-state { padding: 70px 20px; text-align: center; }
.empty-state svg { width: 30px; height: 30px; color: #a7a9a3; }
.empty-state h3 { margin: 15px 0 6px; font-size: 15px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }
.load-status { margin: 12px 0 0; color: var(--error); font-size: 12px; }

.detail-dialog { width: min(92vw, 720px); max-height: 88vh; padding: 0; border: 0; border-radius: 7px; color: var(--ink); background: var(--paper); box-shadow: 0 20px 70px rgba(0,0,0,.22); }
.detail-dialog::backdrop { background: rgba(18, 19, 17, 0.55); }
.dialog-head { padding: 26px 28px 22px; display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--soft-line); }
.dialog-head h2 { margin: 0; font-size: 21px; line-height: 1.45; letter-spacing: 0; }
.detail-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 22px 28px; border-bottom: 1px solid var(--soft-line); }
.detail-meta > div { display: grid; gap: 5px; }
.detail-meta span, .detail-content > span { color: var(--muted); font-size: 11px; }
.detail-meta strong { font-size: 13px; }
.detail-content { padding: 24px 28px; }
.detail-content p { max-height: 280px; overflow-y: auto; margin: 9px 0 0; color: #383a36; font-size: 14px; line-height: 1.85; white-space: pre-wrap; overflow-wrap: anywhere; }
.dialog-actions { padding: 0 28px 26px; display: flex; justify-content: flex-end; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@media (max-width: 900px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar { position: static; width: 100%; height: 66px; flex-direction: row; align-items: center; padding: 0 20px; }
  .sidebar nav { margin: 0 0 0 auto; }
  .nav-item { display: none; }
  .sidebar-logout { width: 40px; height: 40px; margin: 0 0 0 16px; padding: 0; justify-content: center; }
  .sidebar-logout span { display: none; }
  .dashboard-main { padding-top: 34px; }
  .data-toolbar { align-items: flex-start; flex-direction: column; }
  .filters { width: 100%; flex-wrap: wrap; }
  .search-box { flex: 1 1 260px; }
  .search-box input { width: 100%; }
  .date-filter { flex: 1 1 150px; }
  .date-filter input { width: 100%; }
  .table-wrap { overflow-x: auto; }
  table { min-width: 760px; }
}

@media (max-width: 600px) {
  .site-header { height: 68px; padding: 0 16px; }
  .submit-shell { width: min(100% - 32px, 720px); padding: 40px 0 52px; }
  .intro { margin-bottom: 36px; }
  .intro h1 { font-size: 30px; }
  .intro > p:last-child { font-size: 14px; }
  .tip-form { gap: 25px; margin: 0 -4px; padding: 26px 20px; }
  .two-column { grid-template-columns: 1fr; }
  textarea { min-height: 200px; }
  .success-panel { padding: 42px 20px; }
  .reference-row { flex-direction: column; gap: 7px; }
  .site-footer { width: min(100% - 32px, 980px); }
  .login-view::before { width: 100%; height: 28%; }
  .login-panel { padding: 28px 22px; }
  .login-heading { margin-top: 42px; }
  .dashboard-main { padding: 28px 16px 50px; }
  .dashboard-header h1 { font-size: 26px; }
  .download-button { width: 42px; padding: 0; }
  .download-button span { display: none; }
  .stat-row { margin-top: 28px; }
  .stat-block { padding: 18px 14px; }
  .stat-block strong { font-size: 22px; }
  .detail-meta { grid-template-columns: 1fr; }
  .dialog-head, .detail-meta, .detail-content { padding-left: 20px; padding-right: 20px; }
  .dialog-actions { padding-right: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
