:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #667085;
  --line: #e4e7ec;
  --panel: #ffffff;
  --page: #f5f7fb;
  --nav: #101828;
  --nav-soft: #1d2939;
  --accent: #1268b3;
  --accent-2: #12a594;
  --accent-soft: #e8f3ff;
  --control-soft: #f7fafb;
  --table-head: #f3f7f8;
  --formula-bg: #e9f7ef;
  --panel-tint: rgba(255, 255, 255, 0.78);
  --page-glow-a: rgba(18, 104, 179, 0.14);
  --page-glow-b: rgba(18, 165, 148, 0.12);
  --nav-glow: rgba(18, 104, 179, 0.28);
  --warn: #b54708;
  --good: #067647;
  --bad: #b42318;
  --shadow: 0 16px 40px rgba(16, 24, 40, 0.09);
  --shadow-strong: 0 26px 70px rgba(16, 24, 40, 0.16);
}

body[data-theme="midnight"] {
  --ink: #e5eefb;
  --muted: #9fb2ca;
  --line: #26384f;
  --panel: #101b2b;
  --page: #07111f;
  --nav: #050b14;
  --nav-soft: #15263b;
  --accent: #5aa8ff;
  --accent-2: #4bd0c0;
  --accent-soft: #102b4a;
  --control-soft: #15263b;
  --table-head: #17273b;
  --formula-bg: #12382f;
  --panel-tint: rgba(16, 27, 43, 0.82);
  --page-glow-a: rgba(90, 168, 255, 0.18);
  --page-glow-b: rgba(75, 208, 192, 0.14);
  --nav-glow: rgba(90, 168, 255, 0.2);
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  --shadow-strong: 0 28px 80px rgba(0, 0, 0, 0.38);
}

body[data-theme="jade"] {
  --ink: #0b1f1a;
  --muted: #55736b;
  --line: #d6e9e1;
  --panel: #ffffff;
  --page: #f1fbf7;
  --nav: #08231c;
  --nav-soft: #134638;
  --accent: #087f5b;
  --accent-2: #0ea5a4;
  --accent-soft: #e5f7f0;
  --control-soft: #f0faf6;
  --table-head: #edf8f3;
  --formula-bg: #e4f7ef;
  --panel-tint: rgba(255, 255, 255, 0.8);
  --page-glow-a: rgba(8, 127, 91, 0.16);
  --page-glow-b: rgba(14, 165, 164, 0.12);
  --nav-glow: rgba(14, 165, 164, 0.24);
}

body[data-theme="gold"] {
  --ink: #23180a;
  --muted: #7a664b;
  --line: #eadfcf;
  --panel: #fffefa;
  --page: #fbf7ef;
  --nav: #201408;
  --nav-soft: #4b3219;
  --accent: #a05a00;
  --accent-2: #147d64;
  --accent-soft: #fff2da;
  --control-soft: #fff8ec;
  --table-head: #fff3df;
  --formula-bg: #f4f7e7;
  --panel-tint: rgba(255, 254, 250, 0.82);
  --page-glow-a: rgba(160, 90, 0, 0.14);
  --page-glow-b: rgba(20, 125, 100, 0.1);
  --nav-glow: rgba(160, 90, 0, 0.22);
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 0%, var(--page-glow-a), transparent 30%),
    radial-gradient(circle at 100% 10%, var(--page-glow-b), transparent 28%),
    linear-gradient(180deg, var(--page), var(--page));
  transition: background 0.25s ease, color 0.25s ease;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at top, #eef6ff 0, #f5f7fb 45%, #e9eef7 100%);
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(16, 24, 40, 0.16);
  padding: 24px;
  display: grid;
  gap: 14px;
}

.login-brand {
  color: var(--ink);
  margin-bottom: 8px;
}

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

.login-card input {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
}

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

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

.sidebar {
  background:
    radial-gradient(circle at 24px 18px, var(--nav-glow), transparent 42%),
    linear-gradient(180deg, var(--nav), #07111f);
  color: #f4fbfc;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: 16px 0 50px rgba(15, 23, 42, 0.18);
}

.login-user {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 32px;
}

.user-name,
.logout-link {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.user-name {
  color: var(--accent);
  font-weight: 700;
}

.logout-link {
  color: var(--muted);
}

.user-name:hover,
.logout-link:hover {
  text-decoration: underline;
}

#accountPanel[hidden] {
  display: none;
}

.account-add {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 130px auto;
}

.brand {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #f2b84b;
  color: #14282d;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.brand p {
  margin: 4px 0 0;
  color: #abc4ca;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-btn {
  width: 100%;
  border: 0;
  border-radius: 8px;
  color: #d8e8eb;
  background: transparent;
  padding: 11px 12px;
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, color 0.18s ease;
}

.nav-btn:hover, .nav-btn.active {
  background: linear-gradient(135deg, var(--nav-soft), rgba(255, 255, 255, 0.08));
  color: #fff;
  transform: translateX(2px);
}

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

.toolbar {
  background: var(--panel-tint);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  border-radius: 10px;
  padding: 14px;
  display: grid;
  grid-template-columns: auto repeat(4, minmax(130px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.quick-range {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: -6px 0 18px;
}

.quick-range button {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-tint);
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
  box-shadow: 0 5px 14px rgba(16, 24, 40, 0.04);
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.quick-range button:hover,
.quick-range button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.quick-range .login-user {
  margin-left: auto;
}

.quick-range .user-name,
.quick-range .logout-link {
  width: auto;
  height: 32px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.quick-range .user-name {
  color: var(--accent);
  font-weight: 700;
}

.quick-range .logout-link {
  color: var(--muted);
}

.quick-range .user-name:hover,
.quick-range .logout-link:hover {
  border-color: transparent;
  background: transparent;
  text-decoration: underline;
}

.period-picker {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-tint);
  color: var(--ink);
  padding: 0 8px 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.theme-picker {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-tint);
  color: var(--muted);
  padding: 0 8px 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  box-shadow: 0 5px 14px rgba(16, 24, 40, 0.04);
}

.theme-picker select {
  height: 24px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  outline: none;
  min-width: 84px;
}

.period-picker input,
.period-picker select {
  height: 24px;
  border: 0;
  background: transparent;
  color: var(--accent);
  outline: none;
  min-width: 82px;
}

.period-trigger {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-tint);
  color: var(--ink);
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.period-trigger strong {
  color: var(--accent);
}

.year-panel,
.period-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 12px;
  margin: -8px 0 18px;
}

.year-panel-head,
.period-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.year-grid,
.period-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

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

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

.year-grid button,
.period-grid button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfcfd;
  color: #344054;
  cursor: pointer;
}

.period-grid small {
  color: var(--muted);
  font-size: 11px;
}

.year-grid button:hover,
.year-grid button.active,
.period-grid button:hover,
.period-grid button.active {
  border-color: var(--accent);
  background: #eef6ff;
  color: var(--accent);
  font-weight: 700;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 12px;
  color: var(--muted);
}

.field input, .field select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--ink);
  min-width: 0;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.btn {
  height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0 12px;
  cursor: pointer;
  background: var(--panel);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

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

.btn.ghost {
  background: var(--control-soft);
}

.btn.danger {
  color: var(--bad);
  border-color: #f0b4ad;
}

.btn.danger:hover {
  background: #fff4f2;
}

.file-btn {
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.view-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin: 4px 0 16px;
}

.view-title h2 {
  margin: 0;
  font-size: 24px;
}

.view-title p {
  margin: 6px 0 0;
  color: var(--muted);
}

.view-title > strong {
  border-radius: 999px;
  padding: 8px 12px;
  background: #ecfdf3;
  color: var(--good);
  border: 1px solid #abefc6;
}

.view-title > strong.positive {
  background: #ecfdf3;
  color: var(--good);
  border-color: #abefc6;
}

.view-title > strong.warning {
  background: #fffaeb;
  color: var(--warn);
  border-color: #fedf89;
}

.view-title > strong.negative {
  background: #fef3f2;
  color: var(--bad);
  border-color: #fecdca;
}

.segmented-control {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.segmented-control button {
  height: 34px;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
  cursor: pointer;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.active {
  background: var(--accent);
  color: #fff;
}

.metric-card, .panel {
  background: var(--panel-tint);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.metric-card {
  padding: 16px;
  display: grid;
  gap: 8px;
  border-top: 3px solid var(--accent);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-strong);
}

.metric-card span, .metric-card small {
  color: var(--muted);
}

.metric-card strong {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.1;
}

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

.rank-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.panel {
  min-width: 0;
  padding: 14px;
}

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

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

.panel-head h2 {
  margin: 0;
  font-size: 17px;
}

.panel-head span {
  color: var(--muted);
  font-size: 12px;
}

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

.log-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  margin: 0 0 14px;
}

.chart-wrap {
  width: 100%;
  overflow: hidden;
}

canvas {
  width: 100%;
  max-height: 320px;
}

.bar-list, .rank-list, .tag-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  gap: 6px;
}

.bar-meta, .rank-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--control-soft);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.rank-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.rank-row:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.08);
  transform: translateY(-1px);
}

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

.insight-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fcfcfd;
  display: grid;
  gap: 6px;
}

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

.insight-item strong {
  font-size: 20px;
}

.boss-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.boss-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.boss-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.boss-card ul {
  margin: 0;
  padding-left: 18px;
  color: #344054;
  line-height: 1.8;
}

.rank-row b {
  color: var(--accent-2);
}

.rank-row em {
  color: var(--accent);
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
  margin-left: 6px;
}

.rank-row small {
  color: var(--muted);
}

.table-scroll {
  overflow: auto;
  max-height: calc(100vh - 190px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1420px;
  background: var(--panel);
}

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

.data-table th.select-col,
.data-table td.select-col {
  width: 42px;
  min-width: 42px;
  text-align: center;
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--table-head);
  z-index: 1;
  font-size: 12px;
}

.data-table input, .data-table select {
  width: 100%;
  min-width: 110px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 6px;
  background: transparent;
  color: var(--ink);
}

.data-table input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  height: 16px;
  padding: 0;
}

.data-table td.formula-cell {
  background: var(--formula-bg);
}

.data-table td.formula-cell input {
  color: var(--good);
  font-weight: 500;
}

.data-table input[readonly] {
  cursor: default;
}

.data-table.compact {
  min-width: 760px;
}

.data-table.compact th,
.data-table.compact td {
  padding: 10px;
}

.data-table input:focus, .data-table select:focus {
  outline: 2px solid rgba(31, 138, 112, 0.2);
  border-color: var(--accent);
  background: #fff;
}

.entry-filter-bar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.entry-time-filter {
  display: grid;
  gap: 5px;
}

.entry-time-filter > span {
  color: var(--muted);
  font-size: 12px;
}

.entry-range-buttons {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.entry-range-buttons button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.entry-range-buttons button.active,
.entry-range-buttons button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.entry-filter-bar label {
  display: grid;
  gap: 5px;
  min-width: 180px;
  color: var(--muted);
  font-size: 12px;
}

.entry-filter-bar input,
.entry-filter-bar select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text);
  background: #fff;
}

.entry-filter-bar .btn {
  min-height: 34px;
}

.entry-date-modal {
  width: min(560px, calc(100vw - 28px));
}

.entry-date-range-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 12px 0;
}

.entry-date-range-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.entry-date-range-panel input {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--panel);
}

.entry-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafb;
  color: var(--muted);
  font-size: 13px;
}

.entry-pager-actions {
  display: flex;
  gap: 8px;
}

.entry-pager .btn {
  min-height: 32px;
  padding: 6px 10px;
}

.boss-table-wrap {
  overflow: auto;
}

.boss-report-card {
  display: grid;
  gap: 8px;
}

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

.boss-report-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(420px, 1fr));
  gap: 24px;
}

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

.summary-report-table {
  overflow: auto;
}

.summary-insight {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafb;
  padding: 12px;
}

.summary-insight-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.summary-insight-head strong {
  font-size: 14px;
}

.summary-insight-head span {
  padding: 3px 8px;
  border-radius: 999px;
  background: #e8f3ef;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.summary-insight ul {
  margin: 0;
  padding-left: 18px;
  color: #40505a;
  line-height: 1.7;
  font-size: 13px;
}

.summary-insight li + li {
  margin-top: 4px;
}

.boss-report-table,
.store-summary-table {
  border-collapse: collapse;
  width: 100%;
  background: #fff;
  font-size: 14px;
}

.boss-report-table th,
.boss-report-table td,
.store-summary-table th,
.store-summary-table td {
  border: 1px solid #6aa84f;
  padding: 5px 7px;
  text-align: left;
  vertical-align: top;
}

.boss-report-table th,
.store-summary-table th {
  background: #fff8df;
  font-weight: 700;
}

.boss-report-table .label,
.store-summary-table .label {
  background: #fff8df;
  width: 55%;
}

.boss-report-table .value,
.store-summary-table .value {
  background: #fff;
  color: #001a66;
  font-variant-numeric: tabular-nums;
}

.boss-report-table .section td {
  background: #fff8df;
  font-weight: 700;
  padding-top: 10px;
}

.boss-report-table .top-text {
  line-height: 1.8;
}

.boss-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafb;
  padding: 12px;
}

.boss-summary-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.boss-summary-head strong {
  font-size: 14px;
}

.boss-summary-head span {
  padding: 3px 8px;
  border-radius: 999px;
  background: #e8f3ef;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.boss-summary ul {
  margin: 0;
  padding-left: 18px;
  color: #40505a;
  font-size: 13px;
  line-height: 1.7;
}

.boss-summary li + li {
  margin-top: 4px;
}

.tag-list {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

#accountList {
  grid-template-columns: 1fr;
}

.tag-list span {
  border: 1px solid var(--line);
  background: #f7fafb;
  border-radius: 8px;
  padding: 9px 10px;
}

.config-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, auto) auto;
  gap: 8px;
  margin-bottom: 12px;
}

.config-add input,
.config-add select {
  height: 38px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
}

.tag-item {
  border: 1px solid var(--line);
  background: #f7fafb;
  border-radius: 8px;
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  grid-template-areas:
    "name remove"
    "meta remove";
  gap: 8px;
  min-width: 0;
}

.department-item {
  grid-template-areas:
    "name remove"
    "meta remove"
    "stores stores";
  align-content: start;
}

.tag-item strong {
  grid-area: name;
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-item small {
  grid-area: meta;
  color: var(--muted);
  white-space: nowrap;
}

.department-name {
  cursor: pointer;
}

.department-name:hover {
  color: var(--brand);
}

.department-store-list {
  grid-area: stores;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
  min-height: 30px;
  max-height: 78px;
  overflow: hidden;
}

.department-item.show-stores .department-store-list {
  max-height: 260px;
  overflow: auto;
}

.department-store-list span,
.department-store-list .store-more {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 100%;
  padding: 5px 9px;
  border: 1px solid #dbe5eb;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  white-space: normal;
  word-break: break-all;
}

.department-store-list .extra-store {
  display: none;
}

.department-item.show-stores .department-store-list .extra-store {
  display: inline-flex;
}

.department-store-list .store-more {
  color: var(--muted);
  font-style: normal;
  background: #edf4f6;
}

.department-item.show-stores .department-store-list .store-more {
  display: none;
}

.department-store-list.empty {
  color: var(--muted);
  font-size: 13px;
  min-height: auto;
}

.account-group {
  display: grid;
  gap: 10px;
}

.account-group + .account-group {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
}

.account-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
}

.account-group-head strong {
  font-size: 14px;
  font-weight: 700;
}

.account-group-head span {
  color: var(--muted);
  font-size: 13px;
}

.account-group-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.permission-panel {
  margin: 12px 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafb;
  padding: 12px;
}

.permission-title {
  font-weight: 700;
  margin-bottom: 10px;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.permission-option {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}

.permission-option input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.account-card {
  cursor: pointer;
}

.account-card-no-remove {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "name"
    "meta";
}

.account-card:hover {
  border-color: rgba(18, 104, 179, 0.35);
  background: #eef6ff;
}

.tag-item select {
  grid-area: meta;
  height: 30px;
  width: 100%;
  max-width: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  min-width: 0;
}

.icon-btn {
  grid-area: remove;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--bad);
  cursor: pointer;
  line-height: 1;
}

.icon-btn:hover {
  border-color: #f0b4ad;
  background: #fff4f2;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(16, 41, 47, 0.42);
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop.modal-top {
  z-index: 40;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(10, 24, 30, 0.24);
  border: 1px solid var(--line);
  padding: 16px;
}

.account-edit-modal {
  width: min(560px, 100%);
}

.backup-modal {
  width: min(760px, 100%);
}

.backup-hero {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fbff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.backup-hero div {
  display: grid;
  gap: 5px;
}

.backup-hero span,
.backup-list-head span {
  color: var(--muted);
}

.backup-list {
  display: grid;
  gap: 10px;
  max-height: 420px;
  overflow: auto;
}

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

.backup-item strong {
  display: block;
  margin-bottom: 4px;
}

.backup-item small {
  color: var(--muted);
  line-height: 1.6;
}

.backup-actions {
  display: flex;
  gap: 8px;
}

.capture-preview-modal {
  width: min(920px, 100%);
  max-height: calc(100vh - 48px);
}

.capture-preview-note {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6fafc;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.capture-preview-image-wrap {
  max-height: min(68vh, 720px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  padding: 12px;
}

.capture-preview-image-wrap img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 8px 24px rgba(39, 54, 67, 0.12);
}

.app-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1200;
  padding: 10px 14px;
  border-radius: 8px;
  background: #153b35;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(17, 32, 41, 0.18);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.app-toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  display: grid;
  gap: 10px;
}

.modal-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.modal-body label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.modal-body input,
.modal-body select {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
}

.form-error {
  min-height: 20px;
  margin-top: 8px;
  color: var(--bad);
  font-size: 13px;
}

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

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

.logic-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.logic-grid span {
  color: var(--muted);
  line-height: 1.6;
}

.positive { color: var(--good); }
.negative { color: var(--bad); }
.warning { color: var(--warn); }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .nav-btn { text-align: center; }
  .toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar-actions { justify-content: flex-start; }
  .summary-grid, .content-grid, .logic-grid, .rank-board, .boss-card-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .main { padding: 12px; }
  .sidebar { padding: 16px 12px; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar { grid-template-columns: 1fr; }
  .log-filters { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr; }
  .view-title { align-items: flex-start; flex-direction: column; }
  .boss-report-grid { grid-template-columns: 1fr; }
  .summary-report-grid { grid-template-columns: 1fr; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .backup-hero,
  .backup-item { grid-template-columns: 1fr; }
  .backup-hero { align-items: stretch; }
  .backup-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .config-add { grid-template-columns: 1fr; }
  .year-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .period-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .btn { width: 100%; }
}
