:root {
  --bg: #f6f8ff;
  --panel: #ffffff;
  --text: #1f2a37;
  --muted: #60708b;
  --line: #dde6f5;
  --primary: #2c6cf2;
  --ok: #18a058;
  --warn: #ffb020;
  --bad: #f54f4f;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(24, 55, 117, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background: linear-gradient(150deg, #f7f9ff 0%, #edf3ff 45%, #f5f8ff 100%);
}

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

h1,
h2,
h3 {
  margin: 0 0 10px;
}

.top-bar {
  margin-bottom: 16px;
}

.top-bar p {
  margin: 0;
  color: var(--muted);
}

.is-hidden {
  display: none !important;
}

.app-user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
}

.app-user-bar span {
  color: var(--muted);
  font-size: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.form-section form {
  display: grid;
  gap: 12px;
}

.auth-section {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  align-items: start;
  min-height: 320px;
}

.auth-status,
.auth-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: #fcfdff;
}

.auth-status p {
  margin: 0;
  color: var(--muted);
}

.auth-card button,
.auth-status button {
  justify-self: start;
}

.grid {
  display: grid;
  gap: 12px;
}

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

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  color: #28354a;
}

input,
select,
button,
textarea {
  border: 1px solid #ccd6ed;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  color: #1f2a37;
}

input:focus,
select:focus {
  outline: 2px solid #2b65f2;
  outline-offset: 1px;
}

.actions {
  display: flex;
  gap: 10px;
}

button {
  cursor: pointer;
  border: none;
}

.primary {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.ghost {
  background: #eef3ff;
  color: #2449a4;
}

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

.stat-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fcfdff;
}

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

.stat-card .value {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 700;
}

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

.control-group {
  display: grid;
  gap: 10px;
  align-content: start;
}

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

.align-bottom {
  align-self: end;
  min-height: 41px;
}

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

.chart-block {
  display: grid;
  gap: 12px;
  justify-items: stretch;
}

canvas {
  width: 100%;
  border: 1px dashed #cfdbf3;
  border-radius: 12px;
  background: #fbfdff;
}

#pieChart {
  justify-self: center;
  max-width: 420px;
  aspect-ratio: 1 / 1;
  height: auto;
}

#lineChart {
  max-width: none;
  min-height: 380px;
}

.legend {
  max-width: 720px;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.list-box {
  margin-top: 0;
  padding-left: 20px;
  min-height: 54px;
}

.list-box li {
  margin-bottom: 4px;
}

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

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

th,
td {
  text-align: left;
  border-bottom: 1px solid #dce6fb;
  padding: 10px;
  font-size: 14px;
}

th {
  background: #f4f7ff;
  position: sticky;
  top: 0;
  white-space: nowrap;
}

tr:hover td {
  background: #fbfcff;
}

.btn-small {
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-edit {
  background: #1f6df5;
  color: #fff;
}

.btn-delete {
  background: #ff5c7a;
  color: #fff;
}

.footer {
  text-align: center;
  color: #7185a3;
  font-size: 13px;
  margin: 10px 0 30px;
}

@media (max-width: 920px) {
  .grid-2,
  .auth-section,
  .stats-section,
  .chart-section,
  .chart-controls {
    grid-template-columns: 1fr;
  }

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