:root {
  color-scheme: light;
  --bg: #f5f6f4;
  --panel: #ffffff;
  --ink: #202421;
  --muted: #6b716d;
  --line: #dfe3de;
  --soft: #eef1ed;
  --accent: #2f6f5e;
  --accent-strong: #225245;
  --accent-soft: #dfeee9;
  --warn: #8b5e25;
  --shadow: 0 20px 60px rgba(32, 36, 33, 0.08);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(245, 246, 244, 0.9)),
    var(--bg);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.client-app {
  position: relative;
  width: min(100%, 440px);
  min-height: 520px;
}

.client-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 520px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.client-panel.view-active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.brand-row {
  position: absolute;
  top: 24px;
  left: 28px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
}

.client-copy,
.client-panel > .eyebrow,
.client-panel > h1,
.client-panel > p,
.code-form {
  width: 100%;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  line-height: 1.7;
}

.entry-form,
.code-form {
  display: grid;
  gap: 14px;
  margin-top: 26px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 0 14px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.primary-button,
.secondary-button,
.danger-button,
.session-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 18px;
  font-weight: 750;
  text-decoration: none;
}

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

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button,
.danger-button,
.session-actions button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary-button:hover,
.session-actions button:hover,
.session-actions button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.danger-button {
  border-color: #e4c9c3;
  background: #fff7f5;
  color: #9a3f2d;
}

.danger-button:hover:not(:disabled) {
  border-color: #c76b58;
  background: #fff0ec;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.link-button {
  width: max-content;
  margin-top: 18px;
}

.compact {
  min-height: 38px;
  padding: 0 14px;
}

.loader-ring {
  width: 58px;
  height: 58px;
  margin-bottom: 26px;
  border: 4px solid var(--soft);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 900ms linear infinite;
}

.status-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 26px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--accent-strong);
  font-size: 24px;
  font-weight: 800;
}

.status-icon.success {
  background: var(--accent);
  color: #fff;
}

.status-icon.error {
  background: #fff2ee;
  color: #9a3f2d;
}

.admin-shell {
  min-height: 100vh;
}

.admin-app {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 240px 1fr;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 86px 18px 24px;
}

.admin-sidebar .brand-row {
  position: absolute;
}

.admin-nav {
  display: grid;
  gap: 6px;
}

.admin-nav a {
  border-radius: 7px;
  color: var(--muted);
  padding: 12px 14px;
  text-decoration: none;
}

.admin-nav a.active,
.admin-nav a:hover {
  background: var(--soft);
  color: var(--ink);
}

.admin-main {
  width: min(1180px, 100%);
  padding: 34px;
}

.admin-header,
.session-meta,
.session-times,
.admin-toolbar,
.header-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-header {
  margin-bottom: 22px;
}

.admin-header h1 {
  font-size: 34px;
}

.admin-toolbar {
  align-items: end;
  justify-content: start;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.admin-toolbar label {
  width: min(360px, 100%);
}

.session-list {
  display: grid;
  gap: 12px;
}

.session-card,
.table-card,
.settings-panel,
.quick-create,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 30px rgba(32, 36, 33, 0.05);
}

.session-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.quick-create,
.settings-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
  padding: 16px;
}

.quick-create {
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 260px) auto;
  align-items: end;
}

.settings-panel {
  max-width: 680px;
}

.settings-panel p {
  margin: 0;
}

.settings-panel strong {
  min-height: 22px;
  color: var(--accent-strong);
  font-size: 13px;
}

.empty-state {
  color: var(--muted);
  padding: 28px;
}

.session-meta p,
.session-times {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.session-times {
  justify-content: start;
  flex-wrap: wrap;
}

.page-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent-strong);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 750;
}

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

.input-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.input-summary div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fafbf9;
  padding: 10px 12px;
}

.input-summary dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.input-summary dd {
  overflow: hidden;
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edit-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr)) repeat(3, auto);
  gap: 10px;
  align-items: end;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.edit-row.slim {
  grid-template-columns: minmax(150px, 1fr) minmax(160px, 1fr) repeat(3, auto);
  border-top: 0;
  padding-top: 0;
}

.edit-row input {
  min-height: 38px;
}

.event-log {
  display: grid;
  gap: 4px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.event-log:empty {
  display: none;
}

.event-log p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.session-actions button {
  min-height: 38px;
  padding: 0 14px;
}

.table-list {
  display: grid;
  gap: 12px;
}

.table-card {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(420px, 2fr);
  gap: 16px;
  align-items: center;
  padding: 16px;
}

.table-card.is-muted {
  opacity: 0.65;
}

.table-card p {
  margin: 5px 0 0;
  font-size: 13px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 760px) {
  .front-shell {
    padding: 12px;
  }

  .client-app,
  .client-panel {
    min-height: 560px;
  }

  .client-panel {
    padding: 28px 22px;
  }

  .admin-app {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: relative;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 78px 16px 16px;
  }

  .admin-main {
    padding: 22px 16px;
  }

  .admin-header,
  .session-meta,
  .admin-toolbar,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-toolbar label {
    width: 100%;
  }

  .input-summary {
    grid-template-columns: 1fr;
  }

  .quick-create,
  .edit-row,
  .edit-row.slim,
  .table-card {
    grid-template-columns: 1fr;
  }
}
