:root {
  color-scheme: dark;
  --bg: #0c0f14;
  --surface: #131821;
  --surface-2: #181f2b;
  --line: #293241;
  --text: #f2f5f8;
  --muted: #98a3b3;
  --gold: #d7b46a;
  --cyan: #35c6d3;
  --red: #ff6b6b;
  --green: #58d68d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", "Noto Sans CJK JP", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
}

[hidden] {
  display: none !important;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(12, 15, 20, 0.74), rgba(12, 15, 20, 0.96)),
    radial-gradient(circle at 20% 10%, rgba(53, 198, 211, 0.2), transparent 34%),
    radial-gradient(circle at 82% 22%, rgba(215, 180, 106, 0.18), transparent 32%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  background: rgba(19, 24, 33, 0.96);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.login-panel h1 {
  margin-bottom: 22px;
  font-size: 34px;
}

.login-panel label {
  display: block;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-panel input:not([type="checkbox"]) {
  width: 100%;
  margin-top: 7px;
}

.remember-row {
  display: flex !important;
  align-items: center;
  gap: 9px;
  font-weight: 500 !important;
}

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

.login-error {
  margin: 0 0 12px;
  color: var(--red);
  font-size: 13px;
}

.primary-action {
  width: 100%;
  border-color: rgba(215, 180, 106, 0.75);
  background: var(--gold);
  color: #16130d;
  font-weight: 800;
}

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 20px;
}

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

.topbar {
  padding: 8px 0 14px;
}

.top-actions,
.actions {
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
  letter-spacing: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 5vw, 44px);
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

.status,
select,
input,
button,
textarea {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  font: inherit;
}

.status {
  padding: 9px 12px;
  color: var(--muted);
  white-space: nowrap;
}

select,
input,
button {
  min-height: 40px;
  padding: 0 12px;
}

button {
  cursor: pointer;
}

textarea {
  width: 100%;
  padding: 10px 12px;
  resize: vertical;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 0 16px;
}

.tab {
  flex: 0 0 auto;
  color: var(--muted);
}

.tab.is-active {
  border-color: var(--gold);
  color: var(--text);
}

.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 360px)) minmax(340px, 1fr);
  gap: 10px;
  align-items: end;
  margin-bottom: 16px;
}

.filters div {
  min-width: 0;
}

.filters span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.date-group {
  display: grid;
  grid-template-columns: 72px 1fr 1fr 1fr;
  gap: 8px;
  align-items: end;
}

.date-group span {
  margin-bottom: 10px;
}

.date-group select {
  width: 100%;
}

.quick-range {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.filter-dropdown {
  position: relative;
  min-width: 190px;
}

.filter-dropdown summary {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  cursor: pointer;
  list-style: none;
}

.filter-dropdown summary::-webkit-details-marker {
  display: none;
}

.filter-dropdown summary b {
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
}

.filter-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  right: 0;
  width: min(320px, 84vw);
  max-height: 360px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  background: #101620;
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}

.filter-menu label,
.filter-menu button {
  width: 100%;
}

.filter-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}

.filter-menu label:hover {
  background: rgba(215, 180, 106, 0.08);
}

.filter-menu input {
  width: 16px;
  min-height: 16px;
}

.filter-menu .filter-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

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

.metrics article,
.panel,
.employee-card,
.admin-grid article,
.detail-card,
.compare-item,
.calendar-day,
.graph-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
}

.metrics article {
  padding: 16px;
}

.metrics span,
.employee-card span,
.detail-card span,
.compare-item span,
.calendar-day span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(22px, 5vw, 34px);
  line-height: 1.1;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.panel {
  margin-top: 16px;
  padding: 16px;
}

.panel-head {
  margin-bottom: 14px;
}

.customer-controls {
  margin: 12px 0 16px;
}

.customer-controls .filters {
  margin-bottom: 12px;
}

.customer-controls .metrics {
  margin-bottom: 14px;
}

.chart-panel canvas,
.detail-panel canvas,
#compareChart,
.graph-card canvas {
  display: block;
  width: 100%;
  height: min(320px, 52vw);
  border-radius: 6px;
  background: #0f141c;
}

.graph-card.is-pie canvas {
  width: min(100%, 520px);
  height: min(520px, calc(100vw - 48px));
  min-height: 340px;
  margin: 0 auto;
}

.graph-panel {
  margin: 14px 0 16px;
}

.graph-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.graph-card {
  padding: 14px;
}

.graph-card h3 {
  margin-bottom: 12px;
}

.legend {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

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

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 8px;
  text-align: right;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

td {
  font-size: 14px;
}

tr[data-customer-key] {
  cursor: pointer;
}

tr[data-customer-key]:hover {
  background: rgba(215, 180, 106, 0.08);
}

.employee-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.employee-card {
  padding: 14px;
  text-align: left;
  transition: border-color 160ms ease, transform 160ms ease;
}

.employee-card:hover,
.employee-card.is-selected {
  border-color: var(--gold);
  transform: translateY(-1px);
}

.employee-card strong,
.detail-card strong {
  display: block;
  margin: 5px 0 8px;
  font-size: 18px;
}

.bar {
  height: 5px;
  overflow: hidden;
  background: #0b1018;
  border-radius: 999px;
}

.bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--cyan));
}

.detail-grid,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.detail-card,
.admin-grid article {
  padding: 14px;
}

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

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

.note-grid input {
  width: 100%;
  margin-top: 6px;
}

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

.compare-layout {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.compare-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.compare-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.compare-summary article {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 14px;
}

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

.compare-summary strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.compare-graphs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.compare-list {
  display: grid;
  gap: 8px;
  max-height: 430px;
  overflow: auto;
}

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

.compare-item input {
  width: 18px;
  min-height: 18px;
}

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

.calendar-day {
  min-height: 96px;
  padding: 10px;
}

.calendar-day strong {
  display: block;
  margin-bottom: 6px;
}

.calendar-day.is-muted {
  opacity: 0.35;
}

.calendar-day b {
  display: block;
  color: var(--cyan);
  font-size: 13px;
}

pre {
  overflow: auto;
  margin: 0;
  color: var(--text);
  white-space: pre-wrap;
}

@media (max-width: 820px) {
  .shell {
    padding: 16px 12px 24px;
  }

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

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

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

  .date-group {
    grid-template-columns: 56px 1fr 1fr 1fr;
  }

  .quick-range {
    justify-content: stretch;
  }

  .quick-range button {
    flex: 1;
  }

  .status,
  select,
  input,
  button,
  .filter-dropdown,
  .actions,
  .top-actions {
    width: 100%;
  }

  .filter-menu {
    left: 0;
    right: auto;
    width: 100%;
  }

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

  .compare-toolbar .filter-dropdown {
    width: 100%;
  }

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

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

@media (max-width: 440px) {
  .metrics {
    grid-template-columns: 1fr;
  }
}
