:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --border: #d9dfdc;
  --border-strong: #b8c3be;
  --text: #202824;
  --muted: #64706a;
  --teal: #117c72;
  --teal-dark: #0d5d56;
  --amber: #bf7a00;
  --rose: #b43f53;
  --blue: #2f6f9f;
  --shadow: 0 18px 55px rgba(35, 48, 44, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(17, 124, 114, 0.08), transparent 280px),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

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

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

.login-panel {
  width: min(430px, 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: white;
  font-weight: 800;
}

.login-panel h1,
.view-title h1 {
  margin: 16px 0 4px;
  font-size: 26px;
  line-height: 1.08;
  letter-spacing: 0;
}

.login-panel p,
.muted {
  color: var(--muted);
}

.login-panel p {
  margin: 0 0 24px;
}

.field-stack {
  display: grid;
  gap: 14px;
}

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

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--text);
  padding: 9px 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(17, 124, 114, 0.14);
}

.primary-button,
.secondary-button,
.ghost-button,
.tab-button {
  min-height: 40px;
  border-radius: 6px;
  padding: 9px 13px;
  font-weight: 750;
}

.primary-button {
  background: var(--teal);
  color: white;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.secondary-button {
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
}

.ghost-button {
  background: transparent;
  color: var(--muted);
}

.error-box,
.warning-box,
.empty-state {
  border-radius: 8px;
  padding: 12px 14px;
}

.error-box {
  border: 1px solid rgba(180, 63, 83, 0.28);
  background: rgba(180, 63, 83, 0.08);
  color: #83293a;
}

.warning-box {
  border: 1px solid rgba(191, 122, 0, 0.28);
  background: rgba(191, 122, 0, 0.08);
  color: #7d4f00;
}

.empty-state {
  border: 1px dashed var(--border-strong);
  background: rgba(255, 255, 255, 0.65);
  color: var(--muted);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 82px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.88);
  padding: 14px 22px;
  backdrop-filter: blur(18px);
}

.view-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.view-title h1 {
  margin: 0;
}

.view-title p {
  margin: 3px 0 0;
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  min-height: calc(100vh - 82px);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.64);
  padding: 18px;
}

.sidebar-section {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.sync-panel {
  display: grid;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
}

.sync-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.checkbox-row input {
  width: 16px;
  min-height: 16px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 11px;
}

.stat strong {
  display: block;
  font-size: 21px;
  line-height: 1;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.project-list {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: calc(100vh - 465px);
  min-height: 220px;
  overflow: auto;
  padding-right: 2px;
}

.project-button {
  display: grid;
  width: 100%;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 10px;
  text-align: left;
}

.project-button:hover,
.project-button.is-selected {
  border-color: var(--border);
  background: white;
}

.project-button.is-selected {
  box-shadow: 0 6px 20px rgba(17, 124, 114, 0.12);
}

.project-name {
  overflow: hidden;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.content {
  min-width: 0;
  padding: 22px;
}

.detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  margin-bottom: 18px;
}

.detail-header h2 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 28px;
  line-height: 1.12;
  letter-spacing: 0;
}

.context-line {
  margin-top: 6px;
  color: var(--muted);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  padding-bottom: 10px;
}

.tab-button {
  border: 1px solid var(--border);
  background: white;
  color: var(--muted);
}

.tab-button.is-active {
  border-color: var(--teal);
  background: rgba(17, 124, 114, 0.1);
  color: var(--teal-dark);
}

.data-grid {
  overflow: auto;
  max-height: calc(100vh - 245px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

td {
  min-width: 150px;
  max-width: 360px;
  overflow-wrap: anywhere;
}

.item-list {
  display: grid;
  gap: 10px;
}

.item-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  padding: 14px;
}

.item-card h3 {
  margin: 0 0 7px;
  overflow-wrap: anywhere;
  font-size: 16px;
}

.item-card p {
  margin: 0;
  color: var(--muted);
}

.item-card a {
  color: var(--blue);
  font-weight: 750;
  text-decoration: none;
}

.event-log {
  display: grid;
  max-height: 170px;
  gap: 6px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}

.event-log div[data-level="warning"] {
  color: var(--amber);
}

.event-log div[data-level="error"] {
  color: var(--rose);
}

.metadata-code {
  max-height: calc(100vh - 245px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  margin: 0;
  padding: 14px;
  color: #26302c;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 940px) {
  .topbar,
  .workspace,
  .detail-header {
    grid-template-columns: 1fr;
  }

  .workspace {
    min-height: 0;
  }

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .project-list {
    max-height: 280px;
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .topbar,
  .content,
  .sidebar {
    padding: 14px;
  }

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

  .detail-header h2 {
    font-size: 23px;
  }
}
