:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #172033;
  --muted: #667085;
  --line: #d8dde7;
  --primary: #1769e0;
  --primary-dark: #0f4eaa;
  --danger: #c03535;
  --warning: #a15c00;
  --ok: #16794c;
  --shadow: 0 8px 24px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

#app {
  min-height: 100vh;
  padding-bottom: 72px;
}

#view {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 16px 96px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

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

.auth-mode #view {
  width: 100%;
  max-width: 420px;
  padding: 0;
}

.auth-mode .tabbar {
  display: none;
}

.login-panel {
  display: grid;
  gap: 22px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.login-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 4px;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

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

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.metric,
.panel,
.matter-card,
.clarification-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 12px;
}

.metric strong {
  display: block;
  font-size: 24px;
}

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

.panel {
  padding: 14px;
  margin-bottom: 14px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

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

.matter-card,
.clarification-card {
  padding: 12px;
}

.matter-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.matter-title strong {
  line-height: 1.35;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #edf2ff;
  color: #174ea6;
  font-size: 12px;
  white-space: nowrap;
}

.badge.waiting {
  background: #fff4df;
  color: var(--warning);
}

.badge.blocked {
  background: #ffe8e8;
  color: var(--danger);
}

.badge.completed {
  background: #e8f6ef;
  color: var(--ok);
}

.meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 7px;
  line-height: 1.45;
}

.risk {
  color: var(--danger);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  min-height: 38px;
  padding: 8px 12px;
}

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

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

.btn.danger {
  border-color: #f1b3b3;
  color: var(--danger);
}

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: 720px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.tab {
  border: 0;
  background: transparent;
  min-height: 58px;
  color: var(--muted);
}

.tab.active {
  color: var(--primary);
  font-weight: 700;
}

.input-area {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--text);
}

.parse-preview {
  white-space: pre-wrap;
  overflow: auto;
  max-height: 360px;
  padding: 12px;
  background: #101828;
  color: #f2f4f7;
  border-radius: 8px;
  font-size: 12px;
}

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 12px;
}

.filter-row .btn {
  white-space: nowrap;
}

.search {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  margin-bottom: 10px;
}

.empty {
  padding: 18px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
}

.detail-grid {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 4px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

@media (min-width: 680px) {
  #view {
    padding-top: 28px;
  }
}
