:root {
  --bg: #edf1f5;
  --sidebar: #3f4f60;
  --sidebar-soft: #516476;
  --sidebar-border: #31404f;
  --sidebar-text: #d8e2ec;
  --sidebar-muted: #9cb0c4;
  --sidebar-active: #63efc2;
  --sidebar-active-ink: #173533;
  --topbar: #5d7184;
  --panel: #ffffff;
  --line: #d5dde6;
  --text: #22313f;
  --muted: #6f8091;
  --title: #163250;
  --accent: #2c8dc9;
  --accent-soft: #e7f4fc;
  --good: #188354;
  --bad: #d14c4c;
  --warn: #d98f1c;
  --shadow: 0 12px 30px rgba(24, 43, 61, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", "Noto Sans TC", sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

.login-shell {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(99, 239, 194, 0.18), transparent 34%),
    linear-gradient(160deg, #eef3f7 0%, #dde5ee 100%);
}

.login-layout {
  width: min(960px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: stretch;
}

.login-hero,
.login-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-hero {
  padding: 40px;
  display: grid;
  align-content: center;
  gap: 14px;
}

.login-hero h1,
.login-card h2 {
  margin: 0;
  color: var(--title);
}

.login-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.login-card {
  padding: 32px 28px;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.login-submit {
  width: 100%;
}

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

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

.admin-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
  width: 100%;
  overflow-x: clip;
}

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
}

.brand {
  height: 78px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(160deg, #6af0c5 0%, #43d8b7 100%);
  color: #153434;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 700;
}

.brand-copy strong {
  display: block;
  font-size: 1.05rem;
}

.brand-copy span {
  display: block;
  margin-top: 2px;
  font-size: 0.82rem;
  color: var(--sidebar-muted);
}

.nav-scroll {
  padding: 12px 0 20px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-group {
  padding: 0 10px 16px;
}

.nav-label {
  margin: 12px 12px 8px;
  color: var(--sidebar-muted);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 0 14px;
  color: var(--sidebar-text);
  border-left: 4px solid transparent;
  transition: background 140ms ease, color 140ms ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-item.is-active {
  background: var(--sidebar-active);
  border-left-color: #2fb993;
  color: var(--sidebar-active-ink);
  font-weight: 700;
}

.nav-icon {
  width: 18px;
  text-align: center;
}

.main {
  display: grid;
  grid-template-rows: 50px 1fr;
  min-width: 0;
}

.topbar {
  background: var(--topbar);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 18px;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.92rem;
}

.menu-toggle {
  font-size: 1.25rem;
  line-height: 1;
}

.content {
  padding: 14px;
  display: grid;
  gap: 16px;
  min-width: 0;
  align-content: start;
}

.page-head,
.panel,
.dashboard-card,
.mini-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.page-head {
  padding: 12px 16px 14px;
  margin-bottom: 0;
}

.breadcrumbs {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 18px;
}

.page-head h1 {
  margin: 6px 0 0;
  color: var(--title);
  font-size: 1.6rem;
  line-height: 36px;
}

.page-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.panel-head {
  padding: 12px 14px 0;
}

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

.panel-head h2 {
  margin: 0;
  color: var(--title);
  font-size: 1.05rem;
}

.panel-head p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.panel-body {
  padding: 14px;
}

.panel-foot {
  border-top: 1px solid var(--line);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.pager-size select {
  min-width: 108px;
}

.pager-nav {
  display: inline-flex;
  align-items: center;
}

.pager-nav .btn {
  min-width: 58px;
  border-radius: 0;
}

.pager-nav .btn:first-child {
  border-top-left-radius: 3px;
  border-bottom-left-radius: 3px;
}

.pager-nav .btn:last-child {
  border-top-right-radius: 3px;
  border-bottom-right-radius: 3px;
}

.pager-nav .btn:disabled {
  background: #f3f6f9;
  color: #9aa8b6;
  cursor: not-allowed;
}

.pager-indicator {
  min-width: 64px;
  min-height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
  border-top: 1px solid #bdd1e5;
  border-bottom: 1px solid #bdd1e5;
  color: var(--title);
  background: #edf4fa;
}

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

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

.field.span-2 {
  grid-column: span 2;
}

.field.span-4 {
  grid-column: 1 / -1;
}

.field label {
  font-weight: 700;
  color: var(--title);
  font-size: 0.9rem;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid #bcc9d6;
  border-radius: 3px;
  background: #fff;
  color: var(--text);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.btn {
  min-height: 36px;
  border: 1px solid #bdd1e5;
  border-radius: 3px;
  padding: 0 12px;
  background: #f6fbff;
  color: #23405a;
  cursor: pointer;
}

.btn-soft {
  background: #fff;
}

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

.status {
  min-height: 20px;
  color: var(--muted);
  font-size: 0.86rem;
}

.status.is-error {
  color: var(--bad);
}

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: #eef2f7;
}

.stat-card {
  padding: 10px 12px;
  border-right: 1px solid var(--line);
  text-align: center;
}

.stat-card:last-child {
  border-right: 0;
}

.stat-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
  color: var(--title);
  white-space: nowrap;
}

.btn-compact {
  min-height: 32px;
  padding: 0 10px;
}

.split-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 18px;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}

.table-wrap.is-wide table {
  min-width: 1180px;
}

.col-datetime {
  width: 210px;
  min-width: 210px;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.col-user {
  width: 150px;
  min-width: 150px;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.col-amount {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.col-round {
  width: 260px;
  min-width: 260px;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid #e2e8ef;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  vertical-align: top;
}

th {
  background: #f4f7fb;
  color: var(--title);
  font-size: 0.9rem;
}

.sort-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sort-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.sort-btn {
  width: 14px;
  height: 14px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: transparent;
  cursor: pointer;
  position: relative;
}

.sort-btn::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform: translate(-50%, -50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}

.sort-btn[data-sort-dir="asc"]::before {
  border-bottom: 6px solid #b7c0cb;
}

.sort-btn[data-sort-dir="desc"]::before {
  border-top: 6px solid #b7c0cb;
}

.sort-btn:hover::before {
  border-bottom-color: var(--accent);
  border-top-color: var(--accent);
}

.sort-btn.is-active {
  background: #e7f0f9;
}

.sort-btn.is-active[data-sort-dir="asc"]::before {
  border-bottom-color: var(--title);
}

.sort-btn.is-active[data-sort-dir="desc"]::before {
  border-top-color: var(--title);
}

tbody tr:nth-child(even) {
  background: #fafbfd;
}

.mono {
  font-family: "IBM Plex Mono", Consolas, monospace;
}

.text-good {
  color: var(--good);
}

.text-bad {
  color: var(--bad);
}

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

.dashboard-card,
.mini-panel {
  padding: 18px;
  display: grid;
  gap: 10px;
}

.dashboard-card h3,
.mini-panel h3 {
  margin: 0;
  color: var(--title);
}

.dashboard-card p,
.mini-panel p {
  margin: 0;
  color: var(--muted);
}

.tag {
  display: inline-flex;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  background: var(--accent-soft);
  color: var(--accent);
}

.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.list-plain {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

body.modal-open {
  overflow: hidden;
}

.modal-shell {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-shell[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 33, 48, 0.48);
}

.modal-card {
  position: relative;
  width: min(980px, 100%);
  max-height: min(88vh, 900px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 24px 64px rgba(12, 24, 36, 0.28);
  overflow: hidden;
}

.modal-head,
.modal-foot {
  padding: 14px 16px;
  background: #f7fafc;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  margin: 0;
  color: var(--title);
  font-size: 1.1rem;
}

.modal-body {
  padding: 16px;
  overflow: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
}

.modal-close {
  width: 36px;
  height: 36px;
  border: 1px solid #bdd1e5;
  border-radius: 3px;
  background: #fff;
  color: var(--title);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

@media (max-width: 1280px) {
  .filter-grid,
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .split-grid,
  .mini-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .login-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .content {
    padding: 12px;
  }

  .topbar {
    padding: 0 12px;
  }

  .topbar-right {
    gap: 8px;
    font-size: 0.84rem;
  }
}

@media (max-width: 720px) {
  .filter-grid,
  .dashboard-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .field.span-2,
  .field.span-4 {
    grid-column: auto;
  }

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

  .modal-shell {
    padding: 12px;
  }

  .modal-card {
    max-height: 92vh;
  }

  .modal-foot {
    flex-wrap: wrap;
  }
}
