/* ViewMaster-inspired admin shell (from lmmcp) + extract page styles */

:root {
  --palette-cyan: #65c9d4;
  --palette-blue: #348adc;
  --palette-navy: #072741;
  --palette-white: #fbfcfc;
  --palette-border: #dadfe4;
  --palette-gray: #bcc4c9;

  --bg: var(--palette-white);
  --surface: #ffffff;
  --accent-primary: var(--palette-blue);
  --border: var(--palette-border);
  --border-light: var(--palette-border);
  --text: var(--palette-navy);
  --text-muted: #4a6270;
  --highlight: rgba(52, 138, 220, 0.1);
  --tag-bg: #eef1f3;
  --row-hover: #f6f8f9;
  --sidebar-width: 220px;
  --destructive-text: #c62828;
  --success-text: #1b5e20;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

.app-shell {
  display: flex;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

.app-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-content {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0;
  -webkit-overflow-scrolling: touch;
}

.sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border-light);
  overflow: hidden;
  z-index: 40;
}

.sidebar-header {
  display: flex;
  align-items: center;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border-light);
  min-height: 56px;
}

.sidebar-logo-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.sidebar-logo-text span {
  color: var(--accent-primary);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.sidebar-link:hover {
  background: var(--row-hover);
  color: var(--text);
  text-decoration: none;
}

.sidebar-link.active {
  background: var(--highlight);
  color: var(--accent-primary);
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.app-page-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.app-page-subtitle {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.task-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
}

.app-page-body {
  padding: 24px 32px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
}

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

.btn-primary {
  background: var(--accent-primary);
  color: white;
  border-color: var(--accent-primary);
}

.btn-primary:hover {
  background: #2a74c4;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-danger {
  color: var(--destructive-text);
  border-color: #f5c2c2;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.data-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

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

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

.data-table thead th {
  background: #f4f7f9;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.data-table tbody tr:hover {
  background: var(--row-hover);
}

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

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--tag-bg);
  color: var(--text-muted);
}

.tag-pill--success {
  background: #e8f5e9;
  color: var(--success-text);
}

.tag-pill--error {
  background: #ffebee;
  color: var(--destructive-text);
}

.tag-pill--partial {
  background: color-mix(in srgb, #b45309 14%, transparent);
  color: #b45309;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(160deg, #e8f4f8 0%, #fbfcfc 45%, #eef3f8 100%);
}

.login-card {
  width: min(100%, 24rem);
  padding: 2rem;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(15, 40, 70, 0.08);
}

.login-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  color: var(--palette-navy);
}

.login-hint {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.login-field {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.login-error {
  color: var(--destructive-text);
  font-size: 13px;
  margin-bottom: 12px;
  min-height: 1.2em;
}

.login-brand {
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
}

.login-brand span {
  color: var(--accent-primary);
}

/* Extract / forms */
label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="file"],
select,
textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 400;
}

.upload {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.tenant-bar,
.api-key-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-top: 12px;
}

.status {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--highlight);
  color: var(--text);
  font-size: 13px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 15px;
  margin-bottom: 10px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 960px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
}

.fact-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.fact-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 8px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-weight: 400;
  color: var(--text);
}

.fact-item input {
  margin-top: 3px;
}

.fact-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

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

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

.model-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.model-option {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 400;
  color: var(--text);
}

.hidden {
  display: none !important;
}

.hop {
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 8px;
}

.fact-card {
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: pointer;
}

.fact-card:hover,
.fact-card.active {
  border-color: var(--accent-primary);
  background: var(--highlight);
}

.outline {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 39, 65, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  width: min(100%, 480px);
  border: 1px solid var(--border);
}

.modal h3 {
  margin-bottom: 8px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  justify-content: flex-end;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.form-row > label {
  flex: 1;
  min-width: 160px;
}

.auth-me-error {
  color: var(--destructive-text);
}
