:root {
  --bg: #eef3f2;
  --surface: #ffffff;
  --surface-soft: #f7faf9;
  --line: #d9e3e0;
  --line-strong: #b9cbc6;
  --ink: #0b1d24;
  --muted: #647783;
  --accent: #0b8f7c;
  --accent-strong: #067263;
  --accent-soft: #e6f5f2;
  --blue: #2f67b2;
  --blue-soft: #eaf1fb;
  --warn: #b26b00;
  --warn-soft: #fff4df;
  --loss: #c2413a;
  --loss-soft: #fff0ee;
  --shadow: 0 14px 34px rgba(20, 38, 45, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

body.auth-locked .app-shell {
  filter: blur(3px);
  pointer-events: none;
  user-select: none;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 16px;
  overflow: auto;
  background: #071a20;
  color: #e7f4f1;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #d8fff4, #17b49b);
  color: #063037;
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 17px;
}

.brand span {
  margin-top: 3px;
  color: #9db3b9;
  font-size: 12px;
}

.side-section {
  display: grid;
  gap: 10px;
  padding: 14px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.side-section:first-of-type {
  border-top: 0;
}

.side-muted {
  color: #bed0d4;
}

.side-label {
  color: #9eb8be;
  font-size: 12px;
  font-weight: 800;
}

.user-switch {
  display: grid;
  gap: 8px;
}

.user-option,
.nav-button,
.chip-button,
.ghost-button,
.primary-button,
.secondary-button,
.icon-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
}

.user-option,
.nav-button,
.ghost-button {
  width: 100%;
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.12);
  color: #f2fbf8;
  text-align: left;
  padding: 0 12px;
}

.user-option {
  display: grid;
  gap: 2px;
  padding: 9px 11px;
}

.user-option strong,
.user-option span {
  display: block;
}

.user-option span {
  color: #9bb3b9;
  font-size: 12px;
}

.user-option.is-active,
.nav-button.is-active,
.nav-button:hover,
.user-option:hover {
  background: #e6f5f2;
  border-color: #e6f5f2;
  color: #063b36;
}

.user-option.is-active span,
.user-option:hover span {
  color: #3f6868;
}

.date-input,
.modal input,
.modal select,
.modal textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 10px;
}

.sidebar .date-input {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.quick-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.chip-button {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.14);
  color: #f1fbf8;
}

.time-line {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: baseline;
}

.time-line strong {
  color: #ffffff;
  font-size: 20px;
}

.time-line span {
  color: #98afb5;
  font-size: 12px;
}

.auth-state {
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: #cfe0dc;
  background: rgba(255, 255, 255, 0.045);
  font-size: 12px;
  font-weight: 800;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 20, 25, 0.76);
  backdrop-filter: blur(12px);
}

.login-overlay[hidden] {
  display: none;
}

.login-card {
  width: min(390px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
  padding: 24px;
  display: grid;
  gap: 13px;
}

.login-mark {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #d8fff4, #17b49b);
  color: #063037;
  font-weight: 900;
}

.login-card h1 {
  margin: 0;
  font-size: 24px;
}

.login-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.login-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 10px;
}

.remember-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.remember-row input {
  width: 16px;
  height: 16px;
}

.login-error {
  min-height: 20px;
  color: var(--loss);
  font-size: 13px;
  font-weight: 800;
}

.main {
  min-width: 0;
  padding: 18px;
}

.topbar {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

h1 {
  margin: 4px 0 0;
  font-size: 28px;
  line-height: 1.1;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.secondary-button {
  padding: 0 14px;
}

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

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

.secondary-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.secondary-button:hover {
  border-color: var(--line-strong);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.summary-card,
.view-panel,
.modal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.summary-card {
  min-height: 104px;
  padding: 14px;
  display: grid;
  align-content: space-between;
}

.summary-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.summary-card label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.summary-card strong {
  font-size: 30px;
  line-height: 1;
}

.summary-input {
  width: 100%;
  max-width: 120px;
  min-height: 34px;
  border: 0;
  border-bottom: 2px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  outline: none;
}

.summary-input:focus {
  border-bottom-color: var(--accent);
}

.summary-card small {
  color: var(--muted);
  font-weight: 700;
}

.summary-card.good strong {
  color: var(--accent);
}

.summary-card.warn strong {
  color: var(--warn);
}

.summary-card.loss strong {
  color: var(--loss);
}

.view-panel {
  padding: 14px;
  margin-bottom: 14px;
}

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

.section-head span,
.reminder-panel span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.section-head strong {
  display: block;
  margin-top: 3px;
  font-size: 20px;
}

.section-head small,
#uploadStatus,
#adminStatus {
  color: var(--muted);
  font-weight: 800;
}

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

.calendar-upload-panel {
  display: grid;
  gap: 10px;
}

.calendar-upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 12px;
  align-items: start;
}

.calendar-block,
.selected-day-upload {
  min-width: 0;
}

.selected-day-upload {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
  display: grid;
  grid-template-rows: auto auto;
  gap: 10px;
}

.selected-day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.selected-day-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.selected-day-head strong {
  font-size: 16px;
}

.calendar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-weekdays {
  margin-bottom: 6px;
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.calendar-day {
  min-width: 0;
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  padding: 8px;
  display: grid;
  align-content: space-between;
  gap: 4px;
  text-align: left;
}

.calendar-day.blank {
  border-color: transparent;
  background: transparent;
}

.calendar-day strong {
  font-size: 18px;
  line-height: 1;
}

.calendar-day span,
.calendar-day small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-day span {
  color: var(--loss);
  font-size: 12px;
  font-weight: 900;
}

.calendar-day small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.calendar-day.has-upload span,
.calendar-day.has-data span {
  color: var(--accent);
}

.calendar-day.is-today {
  border-color: rgba(47, 103, 178, 0.55);
}

.calendar-day.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.upload-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
  align-items: start;
}

.submission-main,
.submission-side {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.submission-side {
  align-self: start;
  position: sticky;
  top: 18px;
}

.upload-drop {
  min-height: 260px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #ffffff;
  overflow: hidden;
}

.upload-drop.has-files {
  display: block;
  min-height: 0;
  padding: 10px;
}

.upload-drop.is-dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.empty-upload {
  display: grid;
  gap: 8px;
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.empty-upload strong {
  color: var(--ink);
  font-size: 22px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.preview-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.preview-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: #081418;
  cursor: zoom-in;
}

.preview-card footer {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
}

.preview-card span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--loss);
  font-weight: 900;
}

.note-panel,
.daily-trade-panel,
.daily-note-panel,
.reminder-panel,
.table-panel,
.rules-editor,
.rules-side,
.approval-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.note-panel,
.daily-trade-panel,
.daily-note-panel,
.rules-editor,
.rules-side,
.approval-panel {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.note-panel label,
.daily-trade-panel label,
.daily-note-panel label,
.rules-editor label,
.modal label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.note-panel textarea,
.daily-note-panel textarea,
.rules-editor textarea,
.modal textarea {
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  padding: 10px;
}

.note-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.daily-trade-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.trade-field,
.trade-result {
  min-height: 94px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  display: grid;
  align-content: space-between;
}

.trade-field span,
.trade-result span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.trade-field input {
  width: 100%;
  max-width: 120px;
  min-height: 36px;
  border: 0;
  border-bottom: 2px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-size: 30px;
  font-weight: 900;
  outline: none;
}

.trade-field input:focus {
  border-bottom-color: var(--accent);
}

.trade-result strong {
  font-size: 30px;
  line-height: 1;
}

.trade-result small {
  color: var(--muted);
  font-weight: 800;
}

.trade-result.good strong {
  color: var(--accent);
}

.trade-result.loss strong {
  color: var(--loss);
}

.daily-note-panel textarea {
  min-height: 132px;
}

.recent-notes-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.recent-notes-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.recent-note-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  padding: 10px;
  display: grid;
  gap: 4px;
  text-align: left;
}

.recent-note-item:hover,
.recent-note-item.is-active {
  border-color: rgba(11, 143, 124, 0.35);
  background: var(--accent-soft);
}

.recent-note-item strong,
.recent-note-item span {
  display: block;
}

.recent-note-item span,
.recent-note-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.recent-note-empty {
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.section-head.compact {
  margin-bottom: 0;
}

.section-head.compact strong {
  font-size: 17px;
}

.rules-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
  align-items: start;
}

.rules-editor textarea {
  min-height: 260px;
}

.rule-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  align-items: center;
}

.rule-edit-box {
  display: grid;
  gap: 9px;
}

.rule-edit-box[hidden] {
  display: none;
}

.rule-summary-actions {
  display: flex;
  justify-content: flex-end;
}

.rule-edit-box > span,
.request-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.rules-side span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.rules-side pre {
  min-height: 360px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b171c;
  color: #d8eee8;
  padding: 12px;
  white-space: pre-wrap;
}

.rules-editor pre {
  max-height: 210px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b171c;
  color: #d8eee8;
  padding: 12px;
  white-space: pre-wrap;
}

.request-note {
  min-height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  background: var(--surface-soft);
  padding: 8px 10px;
}

.request-note.pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.request-note.done {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 12px;
  align-items: start;
}

.table-panel {
  overflow: auto;
}

.status-table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

.status-table th,
.status-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.status-table th {
  background: #f3f7f6;
  color: #486069;
  font-size: 12px;
}

.status-table td {
  font-size: 13px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 8px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 900;
}

.status-badge.done {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-badge.missing {
  background: var(--loss-soft);
  color: var(--loss);
}

.status-badge.pending {
  background: var(--warn-soft);
  color: var(--warn);
}

.reminder-panel {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.approval-panel {
  margin-top: 12px;
}

.approval-list {
  display: grid;
  gap: 10px;
}

.approval-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.approval-item header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.approval-item strong,
.approval-item span {
  display: block;
}

.approval-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.approval-item pre {
  max-height: 220px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px;
  white-space: pre-wrap;
}

.approval-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.reminder-panel pre {
  min-height: 260px;
  max-height: 420px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b171c;
  color: #d8eee8;
  padding: 12px;
  white-space: pre-wrap;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.history-item strong,
.history-item span,
.history-item small {
  display: block;
}

.history-item span,
.history-item small {
  color: var(--muted);
  font-weight: 800;
}

.modal {
  border: 0;
  background: transparent;
  padding: 0;
}

.modal::backdrop {
  background: rgba(6, 18, 22, 0.45);
}

.modal-card {
  width: min(440px, calc(100vw - 28px));
  padding: 14px;
  display: grid;
  gap: 12px;
}

.modal-card header,
.modal-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-card header strong {
  font-size: 18px;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  background: #ffffff;
  border-color: var(--line);
}

.image-dialog {
  width: min(1120px, calc(100vw - 36px));
  max-width: none;
  border: 0;
  background: transparent;
  padding: 0;
}

.image-dialog::backdrop {
  background: rgba(6, 18, 22, 0.78);
}

.image-dialog img {
  display: block;
  width: 100%;
  max-height: calc(100vh - 80px);
  object-fit: contain;
  border-radius: 8px;
  background: #071114;
}

.image-close {
  position: fixed;
  top: 16px;
  right: 18px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 24px;
  font-weight: 900;
}

@media (max-width: 1360px) {
  .calendar-upload-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  .daily-trade-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .calendar-upload-grid {
    grid-template-columns: 1fr;
  }

  .upload-layout,
  .admin-grid,
  .rules-layout {
    grid-template-columns: 1fr;
  }

  .submission-side {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .main {
    padding: 12px;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions,
  .note-actions,
  .approval-actions {
    width: 100%;
    justify-content: stretch;
  }

  .top-actions button,
  .note-actions button,
  .approval-actions button {
    flex: 1;
  }

  .rule-actions {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .daily-trade-grid {
    grid-template-columns: 1fr;
  }

  .calendar-panel {
    padding: 10px;
  }

  .calendar-weekdays,
  .calendar-grid {
    gap: 4px;
  }

  .calendar-day {
    min-height: 62px;
    padding: 6px;
  }

  .selected-day-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .calendar-day strong {
    font-size: 15px;
  }

  .calendar-day span,
  .calendar-day small {
    font-size: 10px;
  }

  .upload-drop {
    min-height: 320px;
  }

  .history-item {
    grid-template-columns: 1fr;
  }
}
