:root {
  --bg: #f5f2ea;
  --card: #ffffff;
  --text: #1d1d1f;
  --accent: #2f6f5e;
  --muted: #6c6c6c;
  --border: #e3e0d6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top left, #f0e8d9, var(--bg));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 28px;
  background: #fff8ed;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
  color: var(--text);
}

.brand:hover {
  text-decoration: none;
  color: var(--text);
}

.nav a {
  margin-left: 12px;
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
}

.nav .user {
  margin-right: 12px;
  color: var(--muted);
}

.container {
  max-width: 980px;
  margin: 32px auto;
  padding: 0 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  min-width: 0;
  overflow-wrap: break-word;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

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

.link:hover {
  text-decoration: underline;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}

.badge.info {
  background: #e7f3ee;
  color: #1e6a54;
  border-color: #c8e1d6;
}

.badge.warn {
  background: #fff2e0;
  color: #7a4b00;
  border-color: #f0d2a5;
}

.form {
  display: grid;
  gap: 14px;
  max-width: 100%;
}

.form-inline {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.form-inline button {
  width: auto;
}

.form-inline input[type="text"] {
  flex: 1;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 1rem;
  width: 100%;
  min-width: 0;
}

select {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 1rem;
  width: 100%;
  background: white;
}

button {
  padding: 12px 18px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

button.secondary {
  background: #e6e1d6;
  color: #2a2a2a;
}

button:hover {
  opacity: 0.92;
}

.split {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.panel {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 16px;
  min-width: 0;
}

.card-nested {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fffdf7;
}

.exercise-block {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
  display: grid;
  gap: 10px;
}

.exercise-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.exercise-header h3 {
  margin: 0;
  white-space: nowrap;
}

.row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.row-title {
  font-weight: 700;
  color: var(--muted);
}

.row label {
  min-width: 0;
  font-size: 0.95rem;
}

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

.flash {
  margin-bottom: 14px;
}

.flash-item {
  background: #ffe8c7;
  border: 1px solid #f2d19c;
  color: #6b4b1f;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 8px;
}

.hint {
  color: var(--muted);
  margin-top: 10px;
}

.last-sets {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.recent-list li {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  gap: 6px;
  background: #fffdf7;
}

.recent-code {
  font-weight: 700;
  font-size: 1.1rem;
}

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

.recent-actions {
  display: flex;
  gap: 12px;
}

.calendar {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.calendar th,
.calendar td {
  border: 1px solid var(--border);
  text-align: center;
  padding: 8px;
}

.day-link {
  color: inherit;
  text-decoration: none;
  display: inline-block;
  width: 100%;
  height: 100%;
  padding: 6px 0;
}

.day-link:hover {
  text-decoration: underline;
}

.calendar .empty {
  background: #f6f3eb;
}

.calendar .marked {
  background: #d9efe4;
  font-weight: 700;
}

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

.history {
  display: grid;
  gap: 14px;
}

.history-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fffdf7;
}

.history-date {
  font-weight: 700;
  margin-bottom: 8px;
}

.history-sets {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.chart-card {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  background: #fffdf7;
}

.chart-note {
  color: var(--muted);
  margin: 6px 0 12px;
}

.search-results {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}

.search-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  display: grid;
  gap: 4px;
  background: #fffdf7;
}

.search-code {
  font-weight: 700;
  font-size: 0.98rem;
}

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

.search-actions {
  display: flex;
  gap: 8px;
  font-size: 0.9rem;
}

.mini-results {
  margin-top: 6px;
  grid-template-columns: 1fr;
}

.selected-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.selected-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #fffdf7;
}

.selected-actions {
  display: flex;
  gap: 8px;
}

.btn-inline {
  width: auto;
}

.exercise-hero {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fffdf7;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.exercise-switcher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.detail-nav-btn {
  min-width: 46px;
  padding: 8px 12px;
}

.exercise-hero-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #ffffff;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.exercise-hero-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.exercise-big-code {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
}

.exercise-subtitle {
  color: var(--muted);
  margin-top: 4px;
}

.exercise-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.exercise-meta-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fffdf7;
  padding: 10px 12px;
}

.exercise-meta-label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.exercise-meta-value {
  font-weight: 700;
  word-break: break-word;
}

.exercise-hero-panel.slide-left {
  animation: ex-slide-left 220ms ease;
}

.exercise-hero-panel.slide-right {
  animation: ex-slide-right 220ms ease;
}

@keyframes ex-slide-left {
  from {
    opacity: 0;
    transform: translateX(22px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes ex-slide-right {
  from {
    opacity: 0;
    transform: translateX(-22px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.exercise-row-clickable {
  cursor: pointer;
}

.exercise-row-clickable:hover {
  background: #faf7ef;
}

.exercise-row-clickable.active-row {
  background: #e7f3ee;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.stats-table th,
.stats-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: center;
}

.stats-table thead th {
  background: #f6f3eb;
}

.stats-code {
  text-align: left;
  font-weight: 700;
}

.stat-compare {
  transition: background-color 0.2s ease;
}

.stat-better {
  background-color: #e6f6ea;
}

.stat-worse {
  background-color: #fde9e9;
}

.stat-equal {
  background-color: transparent;
}

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

.tile {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fffdf7;
}

.tile-title {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.tile-value {
  font-weight: 700;
  font-size: 1.1rem;
}

.status-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

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

.ip-list {
  margin-top: 6px;
  color: var(--text);
}

.security-grid {
  display: grid;
  gap: 8px;
}

.timeline-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.web-radar {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(46, 111, 94, 0.16), rgba(255, 255, 255, 0)) ,
    linear-gradient(180deg, #fffdf8 0%, #fffaf0 100%);
}

.web-radar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.26) 50%, rgba(255, 255, 255, 0) 70%);
  transform: translateX(-120%);
  animation: web-radar-sheen 7s ease-in-out infinite;
}

@keyframes web-radar-sheen {
  0% { transform: translateX(-120%); }
  45% { transform: translateX(120%); }
  100% { transform: translateX(120%); }
}

.web-radar-head .hint {
  margin-top: 4px;
}

.web-health-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.web-health-pill,
.web-threat-pill {
  border: 1px solid #d7d6c9;
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.web-threat-pill {
  background: linear-gradient(120deg, #fff2ea 0%, #fff9f2 100%);
}

.web-threat-pill strong {
  font-size: 1.3rem;
  color: #7a2b12;
  letter-spacing: 0.02em;
}

.web-traffic-cards {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.web-traffic-card {
  border: 1px solid #ddd9ca;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  padding: 12px;
}

.web-traffic-title {
  color: #5a5c4f;
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.web-traffic-values {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 30px;
  align-items: center;
}

.web-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.82rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.web-chip.ok {
  color: #1f6a50;
  background: #e8f5ee;
  border-color: #cfe8dc;
}

.web-chip.bad {
  color: #8b2d24;
  background: #fcecec;
  border-color: #f0d0d0;
}

.web-chip.total {
  color: #473f2a;
  background: #f4eddb;
  border-color: #e7dcc3;
}

.web-lists-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.web-list-card {
  border: 1px solid #ddd9ca;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  padding: 12px;
}

.web-list-card h3 {
  margin: 0 0 10px 0;
  font-size: 0.95rem;
}

.web-path-list {
  gap: 8px;
}

.web-path-item {
  border: 1px solid #e4dfd1;
  border-radius: 10px;
  padding: 8px;
  background: #fffef9;
}

.web-path-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.web-rank {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  color: #2f6f5e;
  background: #e7f3ee;
}

.web-path {
  overflow-wrap: anywhere;
  font-size: 0.82rem;
  color: #36362f;
}

.web-path-count {
  font-weight: 700;
  color: #3b3b36;
  font-size: 0.82rem;
}

.web-path-bar {
  margin-top: 6px;
  height: 6px;
  border-radius: 999px;
  background: #ece8db;
  overflow: hidden;
}

.web-path-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #2f6f5e 0%, #89b6a8 100%);
  border-radius: 999px;
}

.badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.badge.ok {
  background: #d9efe4;
  color: #1c5a48;
}

.badge.bad {
  background: #f8d7da;
  color: #842029;
}

.badge.unknown {
  background: #ece7dc;
  color: #5a5a5a;
}

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

.session-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fffdf7;
}

.session-date {
  font-weight: 700;
  margin-bottom: 8px;
}

.session-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 6px;
}

.session-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0;
}

.session-exercises {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.pill {
  padding: 4px 8px;
  border-radius: 999px;
  background: #f0ebe0;
  font-size: 0.85rem;
}

.timeline {
  display: grid;
  gap: 16px;
  position: relative;
  padding-left: 18px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 12px;
  align-items: start;
}

.timeline-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 6px;
}

.timeline-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fffdf7;
}

.history-last {
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.history-actions {
  display: flex;
  gap: 12px;
  margin: 6px 0 10px;
  align-items: center;
}

.inline-form {
  margin: 0;
}

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

.link-button:hover {
  text-decoration: underline;
}

.delta {
  color: var(--accent);
  font-weight: 700;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.pager {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  align-items: center;
}

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

.db-controls {
  margin-top: 12px;
}

.action-icons {
  display: inline-grid;
  grid-template-columns: repeat(2, 34px);
  gap: 8px;
  justify-content: center;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fffdf7;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  padding: 0;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.icon-btn:hover {
  background: #f0ebe0;
}

.icon-btn.danger {
  color: #8a2c2c;
}

@media (max-width: 900px) {
  .web-health-row {
    grid-template-columns: 1fr;
  }

  .web-traffic-cards {
    grid-template-columns: 1fr;
  }

  .web-lists-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .form-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .form-inline button {
    width: 100%;
  }

  .form-actions {
    flex-direction: column;
  }

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

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
  }

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

  .nav a {
    margin-left: 0;
    padding: 8px 10px;
    background: #f0ebe0;
    border-radius: 8px;
  }

  .container {
    margin: 16px auto;
    padding: 0 12px;
  }

  .card {
    padding: 16px;
  }

  input,
  button {
    min-height: 44px;
    font-size: 1rem;
  }

  .search-results {
    grid-template-columns: 1fr;
  }

  .recent-actions,
  .search-actions {
    flex-wrap: wrap;
  }

  .calendar th,
  .calendar td {
    padding: 6px;
  }

  .stats-table {
    display: block;
    width: 100%;
    overflow-x: auto;
  }

  .stats-table th,
  .stats-table td,
  .stats-code {
    white-space: normal;
    word-break: break-word;
  }

  .stats-table td:last-child {
    text-align: left;
  }

  .action-icons {
    justify-content: flex-start;
  }

  .web-path-row {
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 6px;
  }

  .web-path-count {
    grid-column: 2;
    justify-self: end;
  }
}
