:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --primary: #0f766e;
  --primary-strong: #0b5f59;
  --primary-soft: #e6f5f2;
  --success: #16a34a;
  --success-soft: #eaf8ef;
  --warning: #d97706;
  --warning-soft: #fff4e5;
  --danger: #dc2626;
  --danger-soft: #fff1f2;
  --info: #2563eb;
  --info-soft: #eef4ff;
  --text: #172033;
  --muted: #667085;
  --subtle: #98a2b3;
  --border: #e5eaf2;
  --shadow: 0 10px 30px rgba(31, 41, 55, 0.07);
  --shadow-soft: 0 4px 14px rgba(31, 41, 55, 0.05);
  --radius: 16px;
  --sidebar-width: 220px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  background: var(--bg);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.layout {
  min-height: 100vh;
}

.sidebar {
  display: none;
}

.main-layout {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.app-name {
  font-size: 15px;
  font-weight: 800;
}

.page-title {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.logout-link,
.quick-links a,
.day-card-head a,
.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid rgba(15, 118, 110, 0.12);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
}

.danger-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(220, 38, 38, 0.14);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 750;
  line-height: 1;
  cursor: pointer;
}

.danger-link:hover {
  background: #ffe4e6;
}

.page {
  width: min(100%, 1600px);
  margin: 0 auto;
  padding: 22px 18px 96px;
}

.page-header,
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 18px;
}

.page-header h1,
.section-head h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
  letter-spacing: 0;
}

.page-header p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.section-head span,
.page-date {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

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

.card,
.metric-card,
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.card {
  padding: 18px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 17px;
  line-height: 1.35;
}

.entry-date-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.5;
}

.entry-date-status.has-data {
  border-color: #bfdbfe;
  background: var(--info-soft);
  color: #1d4ed8;
}

.entry-date-status.is-empty {
  color: #475467;
}

.compact-head {
  margin-bottom: 12px;
}

.compact-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.history-row {
  display: grid;
  grid-template-columns: 1.1fr repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: center;
  padding: 11px 0;
  border-top: 1px solid var(--border);
}

.history-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.history-row span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.history-row b {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.history-edit-link,
.report-edit-link {
  white-space: nowrap;
}

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

.inline-delete-form {
  margin: 0;
}

.report-delete-link,
.day-clear-link {
  white-space: nowrap;
}

.history-save-warning {
  margin-bottom: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.metric-grid,
.stat-grid,
.report-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric-card,
.stat-card {
  position: relative;
  overflow: hidden;
  min-height: 128px;
  padding: 18px;
}

.metric-card::after,
.stat-card::after {
  content: "";
  position: absolute;
  right: -28px;
  top: -34px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: var(--primary-soft);
}

.metric-card span,
.stat-card span,
.kv-list span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong,
.stat-card strong {
  display: block;
  margin-top: 14px;
  color: var(--text);
  font-size: 26px;
  line-height: 1.1;
  font-weight: 850;
}

.metric-card small,
.stat-card small {
  display: block;
  margin-top: 14px;
  color: var(--subtle);
  font-size: 12px;
  line-height: 1.4;
}

.card-icon {
  position: absolute;
  right: 16px;
  top: 16px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 12px;
  font-weight: 900;
}

.kv-list {
  display: grid;
  gap: 0;
}

.kv-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.kv-list div:first-child {
  border-top: 0;
}

.kv-list b {
  text-align: right;
}

.indicator-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.indicator-item {
  padding: 14px;
  background: #fbfcff;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.indicator-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.indicator-item b {
  display: block;
  margin-top: 8px;
  font-size: 18px;
}

.chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.chart-card {
  min-height: 320px;
}

.chart-wrap {
  position: relative;
  min-height: 250px;
}

.chart-wrap canvas {
  width: 100% !important;
  height: 250px !important;
}

.empty-chart,
.empty-card,
.empty-cell,
.muted-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.empty-chart {
  display: grid;
  place-items: center;
  min-height: 220px;
  background: #fbfcff;
  border: 1px dashed var(--border);
  border-radius: 14px;
  text-align: center;
}

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

.alert-item,
.safe-alert {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 14px;
  line-height: 1.45;
}

.alert-item {
  color: #7c2d12;
  background: var(--warning-soft);
  border: 1px solid #fed7aa;
}

.safe-alert {
  color: #166534;
  background: var(--success-soft);
  border: 1px solid #bbf7d0;
}

.alert-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  font-weight: 900;
}

.alert-title {
  font-weight: 850;
}

.alert-desc {
  margin-top: 2px;
  font-size: 13px;
  opacity: 0.86;
}

.rank-list,
.analysis-list,
.report-days,
.list-stack,
.entry-form,
.entry-grid {
  display: grid;
  gap: 14px;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(110px, 1.1fr) repeat(4, minmax(90px, 0.9fr)) minmax(180px, 1.5fr);
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.rank-row:first-child {
  border-top: 0;
}

.rank-row span,
.rank-row small {
  color: var(--muted);
  font-size: 12px;
}

.rank-row b {
  display: block;
  margin-top: 4px;
}

.notice,
.error-box,
.success-box {
  width: 100%;
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
}

.notice {
  color: #854d0e;
  background: var(--warning-soft);
  border: 1px solid #fde68a;
}

.notice.notice-error {
  color: #991b1b;
  background: var(--danger-soft);
  border-color: #fecdd3;
}

.notice.notice-success {
  color: #166534;
  background: var(--success-soft);
  border-color: #bbf7d0;
}

.strong-notice {
  font-weight: 800;
}

.strong-notice a {
  margin-left: 8px;
  color: var(--primary);
}

.error-box {
  color: #991b1b;
  background: var(--danger-soft);
  border: 1px solid #fecdd3;
}

.success-box {
  color: #166534;
  background: var(--success-soft);
  border: 1px solid #bbf7d0;
}

.filter-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.filter-form label,
.field-grid label,
.date-field {
  display: grid;
  gap: 7px;
}

.filter-form span,
.field-grid span,
.date-field span,
.form-stack label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  font-size: 14px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.12);
  border-color: var(--primary);
}

.field-help {
  display: block;
  margin-top: 3px;
  color: var(--subtle);
  font-size: 12px;
  line-height: 1.35;
}

.field-help.is-auto-calculated {
  color: var(--primary);
  font-weight: 800;
}

.filter-form button,
.primary-submit,
.primary-link,
.form-stack button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--primary);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.primary-submit {
  width: 100%;
  min-height: 50px;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.18);
}

.secondary-btn {
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: #eef2f7;
  font-weight: 800;
}

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

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.wide-field {
  grid-column: 1 / -1;
}

.entry-card-head,
.analysis-head,
.day-card-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.entry-card-head h2,
.analysis-head h2,
.account-card h2 {
  margin: 0 0 4px;
  font-size: 17px;
}

.entry-card-head p,
.analysis-head p,
.account-card p,
.remark {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.tag-main,
.tag-good {
  color: #166534;
  background: var(--success-soft);
}

.tag-backup,
.tag-test {
  color: #6d28d9;
  background: #f3e8ff;
}

.tag-active,
.tag-info,
.tag-keep {
  color: #1d4ed8;
  background: var(--info-soft);
}

.tag-warning {
  color: #9a3412;
  background: var(--warning-soft);
}

.tag-danger {
  color: #991b1b;
  background: var(--danger-soft);
}

.judge-box {
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.45;
}

.judge-good { color: #166534; background: var(--success-soft); }
.judge-keep { color: #1d4ed8; background: var(--info-soft); }
.judge-watch { color: #9a3412; background: var(--warning-soft); }
.judge-risk { color: #991b1b; background: var(--danger-soft); }
.judge-test { color: #6d28d9; background: #f3e8ff; }

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric-strip div {
  min-height: 72px;
  padding: 12px;
  background: #fbfcff;
  border: 1px solid var(--border);
  border-radius: 14px;
}

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

.metric-strip b {
  display: block;
  margin-top: 8px;
  font-size: 16px;
  line-height: 1.2;
}

.analysis-card {
  display: grid;
  gap: 12px;
}

.slot-summary {
  display: grid;
  gap: 5px;
  padding: 12px;
  background: #fbfcff;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.slot-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.slot-summary b {
  color: var(--primary);
  font-size: 15px;
}

.slot-summary small {
  color: var(--subtle);
  font-size: 12px;
  line-height: 1.4;
}

.ocr-card {
  border-color: rgba(15, 118, 110, 0.18);
}

.ocr-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
}

.ocr-actions .secondary-btn {
  width: auto;
  margin-top: 0;
}

.ocr-file-count {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.ocr-capture-hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.ocr-capture-hint.is-warning {
  padding: 9px 10px;
  color: #854d0e;
  background: var(--warning-soft);
  border: 1px solid #fed7aa;
  border-radius: 10px;
}

.ocr-capture-preview {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  margin-top: 10px;
  padding: 8px;
  color: var(--muted);
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
}

.ocr-capture-preview[hidden] {
  display: none;
}

.ocr-capture-preview img {
  display: block;
  width: 84px;
  height: 52px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.ocr-capture-preview span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ocr-crop-panel {
  margin-top: 12px;
  padding: 14px;
  background: #fff;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
}

.ocr-crop-panel[hidden] {
  display: none;
}

.ocr-crop-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.ocr-crop-head strong,
.ocr-crop-head span {
  display: block;
  line-height: 1.45;
}

.ocr-crop-head strong {
  color: var(--text);
  font-size: 14px;
}

.ocr-crop-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.ocr-crop-canvas-wrap {
  max-width: 100%;
  overflow: auto;
  padding: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.ocr-crop-canvas-wrap canvas {
  display: block;
  max-width: 100%;
  height: auto;
  cursor: crosshair;
  background: #fff;
  border-radius: 8px;
  touch-action: none;
}

.ocr-crop-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.ocr-crop-actions .primary-link,
.ocr-crop-actions .secondary-btn {
  min-height: 38px;
  margin-top: 0;
}

.ocr-progress {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.ocr-progress-bar {
  width: 100%;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

.ocr-progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.25s ease;
}

.ocr-progress-text {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.ocr-status {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.ocr-status.success {
  color: var(--success);
}

.ocr-status.error {
  color: var(--danger);
}

.ocr-apply-state {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 12px;
  background: var(--primary-soft);
}

.ocr-apply-state strong,
.ocr-apply-state span {
  display: block;
  line-height: 1.45;
}

.ocr-apply-state strong {
  color: var(--primary-strong);
  font-size: 13px;
}

.ocr-apply-state span {
  margin-top: 2px;
  color: #28756f;
  font-size: 12px;
}

.ocr-save-btn {
  flex-shrink: 0;
  min-width: 108px;
}

.ocr-result {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  background: #fbfcff;
  border: 1px solid var(--border);
  border-radius: 14px;
}

.ocr-confirm-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.ocr-confirm-head b,
.ocr-confirm-card-head strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
}

.ocr-confirm-head span,
.ocr-confirm-card-head span,
.ocr-confidence {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.ocr-panel-note {
  padding: 10px 12px;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  background: var(--success-soft);
  color: #166534;
  font-size: 13px;
  line-height: 1.5;
}

.ocr-panel-note.danger {
  border-color: #fecdd3;
  background: var(--danger-soft);
  color: #991b1b;
}

.ocr-panel-note.conflict {
  border-color: #fed7aa;
  background: var(--warning-soft);
  color: #9a3412;
}

.ocr-batch-summary {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
}

.ocr-coverage-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.ocr-coverage-card {
  min-height: 58px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.ocr-coverage-card span,
.ocr-coverage-card b {
  display: block;
  line-height: 1.35;
}

.ocr-coverage-card span {
  color: var(--muted);
  font-size: 12px;
}

.ocr-coverage-card b {
  margin-top: 5px;
  color: #475467;
  font-size: 13px;
}

.ocr-coverage-card.is-success {
  border-color: #bbf7d0;
  background: var(--success-soft);
}

.ocr-coverage-card.is-success b {
  color: #166534;
}

.ocr-coverage-card.is-conflict {
  border-color: #fed7aa;
  background: var(--warning-soft);
}

.ocr-coverage-card.is-conflict b {
  color: #9a3412;
}

.ocr-coverage-card.is-missing {
  background: #f8fafc;
}

.ocr-failure-list {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #fecdd3;
  border-radius: 12px;
  background: var(--danger-soft);
}

.ocr-failure-list b,
.ocr-failure-list span,
.ocr-failure-list em {
  display: block;
  line-height: 1.4;
}

.ocr-failure-list b {
  color: #991b1b;
  font-size: 13px;
}

.ocr-failure-list span {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.ocr-failure-list em {
  color: #991b1b;
  font-size: 12px;
  font-style: normal;
}

.ocr-result ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.ocr-confirm-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.ocr-confirm-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.ocr-confirm-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.ocr-badge-row {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.ocr-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
  white-space: nowrap;
}

.ocr-badge-good {
  color: #166534;
  background: var(--success-soft);
}

.ocr-badge-warn {
  color: #9a3412;
  background: var(--warning-soft);
}

.ocr-badge-neutral {
  color: #475467;
  background: #eef2f7;
}

.ocr-badge-danger {
  color: #991b1b;
  background: var(--danger-soft);
}

.ocr-low-note {
  width: fit-content;
  padding: 7px 9px;
  border-radius: 10px;
  background: var(--warning-soft);
  color: #9a3412;
  font-size: 12px;
  font-weight: 850;
}

.ocr-field-list {
  display: grid;
  gap: 7px;
}

.ocr-field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfcff;
}

.ocr-field-row span,
.ocr-field-row small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.ocr-field-row b {
  display: block;
  margin: 2px 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.ocr-field-row em {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
  white-space: nowrap;
}

.ocr-field-row.is-fill em {
  color: #166534;
  background: var(--success-soft);
}

.ocr-field-row.is-overwrite em {
  color: #9a3412;
  background: var(--warning-soft);
}

.ocr-field-row.is-same em,
.ocr-field-row.is-keep em,
.ocr-field-row.is-empty em {
  color: #475467;
  background: #eef2f7;
}

.ocr-field-row.is-unmatched em {
  color: #991b1b;
  background: var(--danger-soft);
}

.ocr-apply-one {
  width: 100%;
  margin-top: 2px;
}

.ocr-select-one {
  width: 100%;
  margin-top: 2px;
}

.entry-card.is-ocr-applied {
  animation: ocrAppliedPulse 1.4s ease;
}

@keyframes ocrAppliedPulse {
  0% { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.35); border-color: rgba(15, 118, 110, 0.5); }
  100% { box-shadow: 0 0 0 14px rgba(15, 118, 110, 0); border-color: var(--border); }
}

.ocr-account-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.ocr-account-preview b,
.ocr-account-preview small {
  line-height: 1.45;
}

.ocr-account-preview small {
  color: var(--muted);
}

.ocr-account-preview:first-child {
  border-top: 0;
}

.analysis-head strong,
.account-card .amount {
  color: var(--primary);
  font-size: 20px;
  font-weight: 850;
  white-space: nowrap;
}

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

.account-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.remark {
  grid-column: 1 / -1;
}

.account-aliases,
.alias-editor {
  grid-column: 1 / -1;
}

.account-aliases {
  display: grid;
  gap: 8px;
}

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

.alias-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.alias-list span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: 100%;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fbfcff;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.alias-editor summary {
  width: fit-content;
  cursor: pointer;
  color: var(--primary);
  font-size: 13px;
  font-weight: 850;
}

.alias-form {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.alias-form label {
  display: grid;
  gap: 6px;
}

.alias-form label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.alias-form textarea {
  width: 100%;
  min-height: 142px;
  resize: vertical;
}

.alias-form button {
  justify-self: start;
}

.table-scroll {
  overflow-x: auto;
  margin: 0 -18px;
  padding: 0 18px 4px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 800;
  background: #f8fafc;
}

tr:hover td {
  background: #fbfcff;
}

.section-subtitle {
  margin: 2px 0 12px;
  font-size: 18px;
}

.day-card-head {
  align-items: center;
}

.day-card-head a {
  width: 92px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(100%, 760px);
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px rgba(31, 41, 55, 0.08);
  backdrop-filter: blur(14px);
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav a {
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 58px;
  padding: 6px 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.bottom-nav a.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.nav-icon {
  font-size: 17px;
  line-height: 1;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 20px 14px;
}

.login-wrap {
  width: min(100%, 430px);
}

.login-card {
  padding: 26px 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.login-title {
  font-size: 24px;
  font-weight: 900;
  line-height: 1.25;
}

.login-subtitle {
  margin: 8px 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

@media (min-width: 768px) {
  .layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  }

  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 20px 14px;
    background: #0f172a;
    color: #dbeafe;
  }

  .brand {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 4px 8px 22px;
  }

  .brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    color: #fff;
    background: var(--primary);
    border-radius: 12px;
    font-weight: 900;
  }

  .brand-title {
    color: #fff;
    font-size: 14px;
    font-weight: 850;
    line-height: 1.25;
  }

  .brand-subtitle {
    margin-top: 3px;
    color: #94a3b8;
    font-size: 12px;
  }

  .side-nav {
    display: grid;
    gap: 6px;
  }

  .side-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 0 12px;
    color: #cbd5e1;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 800;
  }

  .side-nav a:hover,
  .side-nav a.active {
    color: #fff;
    background: rgba(15, 118, 110, 0.92);
  }

  .bottom-nav {
    display: none;
  }

  .page {
    padding: 28px 32px 40px;
  }

  .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .stat-grid,
  .report-summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .indicator-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .chart-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-grid.two-col {
    grid-template-columns: minmax(0, 1.3fr) minmax(360px, 0.7fr);
    align-items: start;
  }

  .analysis-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .entry-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .list-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1180px) {
  .analysis-list,
  .entry-grid,
  .list-stack {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 767px) {
  .page {
    padding: 16px 12px 92px;
  }

  .topbar {
    min-height: 58px;
    padding: 10px 12px;
  }

  .page-header,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .entry-date-status {
    align-items: flex-start;
    flex-direction: column;
  }

  .entry-date-status .inline-delete-form,
  .day-clear-link {
    width: 100%;
  }

  .page-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .page-actions a {
    flex: 1;
  }

  .metric-card,
  .stat-card {
    min-height: 112px;
    padding: 15px;
  }

  .metric-card strong,
  .stat-card strong {
    font-size: 22px;
  }

  .filter-form {
    grid-template-columns: 1fr;
  }

  .field-grid,
  .metric-strip,
  .indicator-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rank-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 14px 0;
  }

  .account-card {
    grid-template-columns: 1fr;
  }

  .history-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
  }

  .history-row:first-child {
    padding-top: 12px;
  }

  .history-edit-link {
    width: 100%;
  }

  .report-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .report-actions .action-link,
  .report-actions .inline-delete-form,
  .report-actions .danger-link {
    width: 100%;
  }

  .analysis-head,
  .entry-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .chart-wrap,
  .chart-wrap canvas {
    min-height: 230px;
    height: 230px !important;
  }

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

  .ocr-actions .primary-link,
  .ocr-actions .secondary-btn {
    width: 100%;
  }

  .ocr-crop-actions {
    flex-direction: column;
  }

  .ocr-crop-actions .primary-link,
  .ocr-crop-actions .secondary-btn {
    width: 100%;
  }

  .ocr-apply-state {
    align-items: stretch;
    flex-direction: column;
  }

  .ocr-apply-state .primary-link {
    width: 100%;
  }

  .ocr-confirm-head,
  .ocr-confirm-card-head {
    flex-direction: column;
  }

  .ocr-confirm-grid {
    grid-template-columns: 1fr;
  }

  .ocr-coverage-grid {
    grid-template-columns: 1fr;
  }

  .ocr-badge-row {
    justify-content: flex-start;
  }

  .ocr-field-row {
    grid-template-columns: 1fr;
    align-items: flex-start;
  }

  .ocr-field-row em {
    width: fit-content;
  }

  .ocr-account-preview {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 680px;
  }
}
