:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-strong: #f0f4f6;
  --text: #172026;
  --muted: #65727c;
  --line: #d9e0e5;
  --accent: #116466;
  --accent-dark: #0b4e50;
  --accent-soft: #d9eeee;
  --warn: #a8551c;
  --warn-soft: #fff1df;
  --notice-border: #e7c48b;
  --notice-text: #6f3b10;
  --danger: #b42318;
  --input-bg: #ffffff;
  --badge-bg: #e8edf0;
  --badge-text: #2b3942;
  --progress-track: #e7ecef;
  --focus-ring: rgba(17, 100, 102, 0.14);
  --switch-knob: #ffffff;
  --stripe-color: rgba(255, 255, 255, 0.72);
  --tile-fallback-start: #e4eff0;
  --tile-fallback-end: #f3f0e7;
  --shadow: 0 12px 32px rgba(23, 32, 38, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101113;
  --surface: #17191b;
  --surface-strong: #222629;
  --text: #eef1ed;
  --muted: #9ba5a0;
  --line: #30363a;
  --accent: #2aa889;
  --accent-dark: #37c8a7;
  --accent-soft: #153a32;
  --warn: #f0b35e;
  --warn-soft: #2d2115;
  --notice-border: #7b5426;
  --notice-text: #f2cf93;
  --danger: #ff7a6b;
  --input-bg: #111315;
  --badge-bg: #272d30;
  --badge-text: #e8eeeb;
  --progress-track: #2b3033;
  --focus-ring: rgba(42, 168, 137, 0.24);
  --switch-knob: #f7faf8;
  --stripe-color: rgba(255, 255, 255, 0.68);
  --tile-fallback-start: #172326;
  --tile-fallback-end: #24231d;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: background-color 160ms ease, color 160ms ease;
}

button,
input,
a {
  font: inherit;
}

.shell {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: min(420px, 100%);
}

.auth-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-panel h1 {
  margin: 0 0 24px;
  font-size: 28px;
  line-height: 1.1;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.auth-form input[type="password"] {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 11px;
  color: var(--text);
  background: var(--input-bg);
}

.auth-form input[type="password"]:focus {
  border-color: var(--accent);
  outline: 2px solid var(--focus-ring);
}

.auth-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h1,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 32px;
  line-height: 1.1;
}

.panel h2 {
  font-size: 18px;
  line-height: 1.2;
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 14px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button.primary {
  background: var(--accent);
  color: #ffffff;
}

.button.primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.button.secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.button.secondary:hover:not(:disabled) {
  background: var(--surface-strong);
}

.theme-switch {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  padding: 0 11px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.theme-switch:hover {
  background: var(--surface-strong);
}

.theme-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.theme-switch-track {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-strong);
  box-shadow: inset 0 0 0 1px var(--line);
}

.theme-switch-track::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--switch-knob);
  box-shadow: 0 1px 3px rgba(23, 32, 38, 0.24);
  transition: transform 160ms ease;
}

.theme-switch input:checked + .theme-switch-track {
  background: var(--accent);
}

.theme-switch input:checked + .theme-switch-track::before {
  transform: translateX(18px);
}

.theme-switch input:focus-visible + .theme-switch-track {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.button.danger {
  background: transparent;
  color: var(--danger);
  min-width: 36px;
  padding: 0 10px;
}

.status-pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 11px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-pill.connected {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.status-pill.blocked {
  color: var(--warn);
  background: var(--warn-soft);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  margin-bottom: 20px;
}

.summary-strip > div {
  min-width: 0;
  background: var(--surface);
  padding: 14px 16px;
}

.summary-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-strip strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.notice {
  border: 1px solid var(--notice-border);
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--notice-text);
  padding: 12px 14px;
  margin-bottom: 18px;
}

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

.counter-card {
  min-height: 178px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  box-shadow: var(--shadow);
}

.counter-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.code-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  background: var(--badge-bg);
  color: var(--badge-text);
  min-height: 28px;
  padding: 0 9px;
  font-size: 13px;
  font-weight: 800;
}

.counter-card h3 {
  margin: 10px 0 0;
  font-size: 16px;
  line-height: 1.25;
}

.counter-number {
  margin: 18px 0 10px;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
}

.counter-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.progress-track {
  position: relative;
  width: 100%;
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--progress-track);
}

.progress-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  height: 100%;
  width: 0;
  border-radius: inherit;
}

.progress-week-plan {
  z-index: 1;
  opacity: 0.2;
  background: var(--progress-color, #1f9d55);
}

.progress-next24 {
  z-index: 2;
  opacity: 0.55;
  background:
    repeating-linear-gradient(
      0deg,
      var(--stripe-color) 0,
      var(--stripe-color) 1px,
      rgba(255, 255, 255, 0) 1px,
      rgba(255, 255, 255, 0) 3px
    ),
    var(--progress-color, #1f9d55);
}

.progress-completed {
  z-index: 3;
  background: var(--progress-color, #1f9d55);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.85fr) minmax(440px, 1.15fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-header,
.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
}

.panel-header {
  border-bottom: 1px solid var(--line);
}

.panel-footer {
  border-top: 1px solid var(--line);
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

.goals-table input {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  color: var(--text);
  background: var(--input-bg);
}

.goals-table input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--focus-ring);
}

.goals-table th:nth-child(1),
.goals-table td:nth-child(1) {
  width: 22%;
}

.goals-table th:nth-child(3),
.goals-table td:nth-child(3) {
  width: 18%;
}

.goals-table th:nth-child(4),
.goals-table td:nth-child(4) {
  width: 42px;
}

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

.inspiration-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.inspiration-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(23, 32, 38, 0.1), rgba(23, 32, 38, 0.18)),
    var(--image),
    linear-gradient(135deg, var(--tile-fallback-start), var(--tile-fallback-end));
  background-position: center;
  background-size: cover;
}


@media (max-width: 960px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .summary-strip,
  .counter-grid,
  .workspace-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100vw - 20px, 1200px);
    padding-top: 18px;
  }

  .topbar h1 {
    font-size: 26px;
  }

  .summary-strip,
  .counter-grid,
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .button,
  .theme-switch {
    width: 100%;
  }

  .panel-header,
  .panel-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-header .button,
  .panel-footer .button {
    width: 100%;
  }
}
