:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2b7de9;
  --border: #e5e7eb;
  --error: #d92d20;
  --success: #12b76a;
  --shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Roboto", "Noto Sans", "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-y: scroll;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}

.brand {
  font-size: 20px;
  font-weight: 600;
}

.layout {
  display: flex;
  min-height: calc(100vh - 64px);
  overflow-x: hidden;
}

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  padding: 24px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.nav-item {
  display: block;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(43, 125, 233, 0.12);
  color: var(--primary);
}

.content {
  flex: 1;
  padding: 32px;
  min-width: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-top: 12px;
}

.stat-number {
  font-size: 42px;
  font-weight: 700;
}

.stat-label {
  color: var(--muted);
}

.form-grid label {
  display: block;
  margin-bottom: 14px;
  font-weight: 500;
}

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-top: 6px;
  font-size: 14px;
  background: #fff;
}

.actions {
  margin-top: 10px;
}

.btn {
  border: none;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.small {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
  background: #eef2ff;
  color: #1f2937;
}

.btn.ghost {
  background: #f3f4f6;
  color: #374151;
}

.error {
  background: rgba(217, 45, 32, 0.1);
  color: var(--error);
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.notice {
  background: rgba(18, 183, 106, 0.1);
  color: var(--success);
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.muted {
  color: var(--muted);
}

.link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.message-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.report-controls {
  margin: 18px 0;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.chart-wrap {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.chart-legend {
  display: grid;
  gap: 8px;
}

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

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e5e7eb;
}

.tag-list {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.tag-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.tag-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.code-block {
  background: #0b1220;
  color: #e5e7eb;
  padding: 12px;
  border-radius: 10px;
  overflow: auto;
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.report-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 14px;
}

.report-table th,
.report-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.report-table th {
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 1;
}

.report-table tfoot td {
  font-weight: 600;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.message-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.inline {
  margin-left: auto;
}

.link-button {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
  padding: 0;
}

.message-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: #f3f4f6;
}

.message-title {
  font-weight: 600;
}

.message-meta {
  color: var(--muted);
  font-size: 13px;
}

.auth-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.auth-card {
  max-width: 360px;
  margin: 64px auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin-top: 0;
}

.auth-footer {
  margin-top: 12px;
  text-align: center;
}

.success {
  background: #eafaf2;
  border: 1px solid #b7f0d1;
  color: #11643a;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  background: #fff;
  cursor: pointer;
}

.tab.active {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #1f2937;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.inline-form {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-right: 6px;
}

.input-mini {
  max-width: 140px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.search-input {
  min-width: 220px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    display: flex;
    gap: 8px;
    overflow-x: auto;
  }

  .content {
    padding: 20px;
  }
}
