:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1f2430;
  --text-muted: #666c78;
  --accent: #2f5fac;
  --accent-soft: #e8eefb;
  --ok-bg: #e3f3e6;
  --ok-text: #1f6b35;
  --warn-bg: #fdecec;
  --warn-text: #9c2a2a;
  --unknown-bg: #fdf3da;
  --unknown-text: #7a5a00;
  --unreg-bg: #eef0f3;
  --unreg-text: #7b818c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 24, 33, 0.06), 0 2px 8px rgba(20, 24, 33, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* Header */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 20px;
}
.topbar-title h1 {
  font-size: 24px;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 13.5px;
}

/* Summary tiles */
.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.tile-label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 6px;
}
.tile-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  margin: 0;
}
.tile-value.has-attention { color: var(--warn-text); }
.tile-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin: 4px 0 0;
}

.status-note {
  background: var(--accent-soft);
  border: 1px solid #cfdcf4;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: #324a73;
  margin: 0 0 18px;
}

.local-note {
  background: var(--accent-soft);
  border: 1px solid #cfdcf4;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12.5px;
  color: #324a73;
  margin: 0 0 14px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  appearance: none;
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab-btn.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-panel[hidden] { display: none; }

/* Toolbar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.search-input {
  flex: 1 1 220px;
  min-width: 160px;
}
.search-input, .filter-select {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}
.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.view-btn {
  appearance: none;
  background: var(--surface);
  border: none;
  padding: 9px 14px;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--text-muted);
}
.view-btn + .view-btn { border-left: 1px solid var(--border); }
.view-btn.is-active {
  background: var(--accent);
  color: #fff;
}

.result-count {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 10px;
}

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.bot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bot-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.bot-id {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.bot-name {
  font-size: 16px;
  font-weight: 700;
  margin: 2px 0 0;
}
.bot-channel {
  font-size: 12.5px;
  color: var(--text-muted);
}
.bot-role {
  font-size: 13.5px;
  color: var(--text);
  margin: 4px 0 0;
}
.bot-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.bot-next {
  font-size: 12.5px;
  color: #a85d00;
  background: #fff7ea;
  border: 1px solid #f3dcb3;
  border-radius: 8px;
  padding: 7px 9px;
}
.bot-link {
  align-self: flex-start;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.bot-link:hover { text-decoration: underline; }

.bot-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
}
.edited-tag {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 8px;
  align-self: flex-start;
}
.btn-edit {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.btn-edit:hover { background: var(--accent-soft); }

/* Status badge */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-running { background: var(--ok-bg); color: var(--ok-text); }
.badge-check, .badge-stopped { background: var(--warn-bg); color: var(--warn-text); }
.badge-unknown { background: var(--unknown-bg); color: var(--unknown-text); }
.badge-unregistered { background: var(--unreg-bg); color: var(--unreg-text); font-style: italic; }

/* List / table view */
.list-view {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  background: #fafbfc;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
td a { color: var(--accent); text-decoration: none; font-weight: 600; }
td a:hover { text-decoration: underline; }

/* Worklog */
.storage-banner {
  background: var(--accent-soft);
  border: 1px solid #cfdcf4;
  color: #324a73;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13.5px;
  margin-bottom: 16px;
}
.worklog-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.form-row:last-child { margin-bottom: 0; }
.form-row label {
  display: flex;
  flex-direction: column;
  font-size: 12.5px;
  color: var(--text-muted);
  gap: 5px;
  flex: 1 1 160px;
}
.form-row label.grow { flex: 2 1 240px; }
.form-row input, .form-row select {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
}
.form-row input:disabled { background: #f2f3f5; color: var(--text-muted); }
.form-actions { justify-content: flex-end; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: #f2f3f5; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #274d8f; }
.btn-file { display: inline-flex; align-items: center; }
.btn-danger-text {
  color: var(--warn-text);
  background: none;
  border: none;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
}
.btn-danger-text:hover { text-decoration: underline; }

.worklog-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-muted);
}
.worklog-buttons { display: flex; gap: 8px; }
.empty-note {
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  padding: 24px 0;
}

/* Guide */
.guide-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.guide-card h2 {
  font-size: 15px;
  margin: 18px 0 8px;
}
.guide-card h2:first-child { margin-top: 0; }
.guide-card ul { margin: 0; padding-left: 20px; }
.guide-card li { margin-bottom: 7px; font-size: 13.5px; }
.guide-card p { font-size: 13.5px; color: var(--text); }

.footer {
  margin-top: 36px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* Edit modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 33, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
  padding: 20px 22px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 {
  font-size: 16px;
  margin: 0 0 6px;
}
.modal-id {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.modal-note {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 14px;
}
#botEditForm label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
#botEditForm input, #botEditForm select {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2430;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

/* Responsive */
@media (max-width: 760px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
  .topbar { flex-direction: column; align-items: flex-start; gap: 6px; }
  .card-grid { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; }
  .form-row label, .form-row label.grow { flex: 1 1 auto; }
}

@media (max-width: 480px) {
  .summary { grid-template-columns: 1fr 1fr; }
  .tile-value { font-size: 22px; }
}
[hidden] { display: none !important; }
