:root {
  color-scheme: light;
  --bg: #f5f6f4;
  --panel: #ffffff;
  --text: #151515;
  --muted: #676b70;
  --line: #d9ded9;
  --green: #1f6f5b;
  --blue: #255f9d;
  --orange: #b65c20;
  --red: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.alarm-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 18px;
  color: #fff;
  background: var(--red);
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
}

.alarm-banner[hidden] {
  display: none;
}

.alarm-banner strong {
  display: block;
  font-size: 18px;
}

.alarm-banner button {
  background: #fff;
  color: var(--red);
  font-weight: 800;
}

main {
  width: min(1060px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

header,
.toolbar,
.grid,
.ticket {
  display: grid;
  gap: 12px;
}

header {
  grid-template-columns: 1fr auto auto auto;
  align-items: end;
  margin-bottom: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  margin: 20px 0 10px;
  font-size: 17px;
}

header p,
label,
time,
.muted {
  color: var(--muted);
}

.panel,
.status,
.ticket,
.record {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel,
.status {
  padding: 14px;
}

.toolbar {
  grid-template-columns: 1fr auto auto;
  align-items: center;
  margin-bottom: 10px;
}

.grid {
  grid-template-columns: 180px 1fr;
}

label {
  display: block;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  margin-top: 5px;
  border: 1px solid #cbd2cb;
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

input {
  height: 38px;
  padding: 0 10px;
}

textarea {
  min-height: 76px;
  padding: 9px 10px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

button,
a#openOfficial {
  min-height: 38px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--green);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#checkBtn {
  background: var(--blue);
}

#notifyBtn,
a#openOfficial {
  background: #555b60;
}

#testAlarmBtn {
  background: var(--orange);
}

button.danger {
  background: var(--red);
}

button.secondary {
  background: #555b60;
}

button:disabled {
  opacity: 0.58;
  cursor: wait;
}

.switch,
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.switch input,
.check input {
  width: auto;
  height: auto;
  margin: 0;
}

.actions {
  margin-top: 12px;
}

.actions.compact {
  margin-top: 8px;
}

.hint {
  align-self: end;
  min-height: 38px;
  padding: 8px 0;
  color: var(--muted);
  font-size: 13px;
}

.date-picker {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
}

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

.date-picker-head button {
  width: auto;
  min-height: 30px;
  padding: 0 10px;
  background: #70757a;
  font-size: 13px;
}

.mini-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.date-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}

.choice-grid {
  display: grid;
  grid-template-columns: minmax(180px, 0.32fr) 1fr;
  gap: 10px;
}

.monitor-panel {
  margin-bottom: 12px;
}

.monitor-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.monitor-tab {
  width: auto;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.monitor-tab.active {
  border-color: rgba(31,111,91,0.35);
  background: var(--green);
  color: #fff;
}

.chip-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

.chip-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-weight: 650;
  font-size: 13px;
}

.chip-option input {
  width: auto;
  height: auto;
  margin: 0;
}

.date-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  align-items: center;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 650;
}

.date-option.active {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(31,111,91,0.12);
}

.date-option input {
  width: auto;
  height: auto;
  margin: 0;
}

.date-option em {
  grid-column: 2;
  color: var(--muted);
  font-style: normal;
  font-weight: 400;
  font-size: 12px;
}

.empty.small {
  padding: 10px;
  font-size: 13px;
}

.selected-summary {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

.summary-row {
  display: grid;
  gap: 6px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.summary-row strong {
  font-size: 13px;
}

.summary-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.summary-detail span {
  padding: 3px 7px;
  border-radius: 6px;
  background: #eef2ee;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.status {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 0.45fr);
  gap: 12px;
  margin-top: 14px;
}

#lastStatus {
  font-weight: 700;
}

#lastError {
  color: var(--red);
  overflow-wrap: anywhere;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.ticket {
  grid-template-columns: 1fr auto;
  padding: 12px;
}

.ticket strong {
  font-size: 16px;
}

.count {
  color: var(--orange);
  font-weight: 800;
}

.record {
  margin-bottom: 10px;
  padding: 12px;
}

.record time {
  display: block;
  margin-bottom: 8px;
}

.log-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  width: min(520px, calc(100vw - 28px));
  max-height: min(420px, calc(100vh - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9faf9;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18);
  overflow: hidden;
  resize: both;
  min-width: 300px;
  min-height: 48px;
}

.log-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  color: #fff;
  background: #555b60;
  cursor: move;
  user-select: none;
  touch-action: none;
}

.log-panel-head div {
  display: flex;
  gap: 6px;
}

.log-panel-head button {
  width: auto;
  min-height: 28px;
  padding: 0 5px;
  background: #fff;
  color: #333;
  font-size: 13px;
}

.log-panel.collapsed {
  max-height: none;
}

.log-panel.collapsed .logs {
  display: none;
}

.logs {
  display: grid;
  gap: 6px;
  max-height: min(360px, calc(100vh - 96px));
  padding: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.log-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
}

.log-row time {
  color: var(--muted);
}

.log-row.success span {
  color: var(--green);
  font-weight: 700;
}

.log-row.error span {
  color: var(--red);
  font-weight: 700;
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255,255,255,0.5);
}

.public-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.12), transparent 30%),
    linear-gradient(180deg, #fbfdff 0%, #eef5ff 46%, #f8fafc 100%);
  color: #111827;
}

.public-shell {
  width: min(760px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 92px 0 44px;
}

.public-brand-wrap {
  position: fixed;
  top: 16px;
  left: 18px;
  z-index: 20;
}

.public-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 5px 10px 5px 6px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: #111827;
  text-decoration: none;
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.10);
  backdrop-filter: blur(14px);
  font-weight: 850;
  cursor: pointer;
  font: inherit;
}

.public-brand-icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
}

.public-brand-caret {
  color: #64748b;
  font-size: 16px;
  line-height: 1;
}

.public-monitor-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  display: grid;
  width: min(320px, calc(100vw - 36px));
  max-height: min(360px, calc(100vh - 80px));
  overflow: auto;
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(14px);
}

.public-monitor-menu[hidden] {
  display: none;
}

.public-monitor-menu .monitor-tab {
  justify-content: flex-start;
  width: 100%;
  min-height: 38px;
  border-radius: 7px;
  background: transparent;
  text-align: left;
}

.public-monitor-menu .monitor-tab.active {
  background: #111827;
  color: #fff;
}

.public-hero {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin: 0 auto 20px;
  text-align: center;
}

.public-hero p {
  color: #2563eb;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.public-hero h1 {
  max-width: 760px;
  color: #0f172a;
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", "Comic Sans MS", system-ui, sans-serif;
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.12;
}

.public-date-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: min(600px, 100%);
  max-width: 100%;
}

.public-date-tab {
  width: auto;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(148, 163, 184, 0.38);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: #334155;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
  font-size: 13px;
  font-weight: 850;
}

.public-date-tab.active {
  border-color: #2563eb;
  background: #2563eb;
  color: #fff;
}

.public-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 14px;
}

.public-actions button,
.public-actions a {
  width: auto;
}

.public-actions a,
.public-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid rgba(21,21,21,0.10);
  border-radius: 8px;
  background: rgba(255,255,255,0.78);
  color: var(--text);
  box-shadow: 0 10px 22px rgba(15,23,42,0.08);
  font-size: 13px;
  font-weight: 800;
}

.public-pill.sound {
  color: var(--green);
}

.public-pill.sound.active {
  border-color: rgba(31,111,91,0.35);
  background: var(--green);
  color: #fff;
}

.public-pill.quiet {
  color: var(--muted);
}

.public-actions a {
  color: #fff;
  background: #2563eb;
}

.public-status {
  display: grid;
  justify-items: center;
  gap: 8px;
  max-width: 100%;
  margin: 0 auto 20px;
  padding: 22px;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 18px 48px rgba(37, 99, 235, 0.12);
  text-align: center;
}

.public-status h2 {
  margin: 4px 0 0;
  color: #0f172a;
  font-size: 22px;
  line-height: 1.35;
}

.public-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 3px 11px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 13px;
  font-weight: 800;
}

.public-badge.hot {
  background: #ffedd5;
  color: #c2410c;
}

.public-badge.idle {
  background: #dcfce7;
  color: #15803d;
}

.public-block {
  margin-top: 22px;
}

.public-block h2 {
  color: #0f172a;
  font-size: 18px;
  font-weight: 900;
}

.public-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.public-summary-card {
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.public-summary-card strong {
  display: block;
  margin-bottom: 8px;
}

.public-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.public-chips span {
  padding: 4px 8px;
  border-radius: 7px;
  background: #eef2ff;
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 750;
}

.public-section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
}

.public-page .ticket {
  border-color: rgba(148, 163, 184, 0.32);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.public-page .ticket.clickable {
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.public-page .ticket.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(37, 99, 235, 0.13);
}

.public-page .count {
  color: #ea580c;
}

.public-page .record {
  border-color: rgba(148, 163, 184, 0.32);
  background: rgba(255, 255, 255, 0.82);
}

.public-page .empty {
  background: rgba(255, 255, 255, 0.62);
}

@media (max-width: 760px) {
  header,
  .toolbar,
  .grid,
  .choice-grid,
  .status,
  .public-status {
    grid-template-columns: 1fr;
  }

  .log-row {
    grid-template-columns: 1fr;
  }

  .log-panel {
    right: 8px;
    bottom: 8px;
    width: calc(100vw - 16px);
  }

  .log-panel-head button {
    width: auto;
  }

  button,
  a#openOfficial,
  .public-actions button,
  .public-actions a {
    width: 100%;
  }
}
