/* Base CSS - clean operational density, no JS dependencies */

:root {
  --font-stack: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "JetBrains Mono", "SFMono-Regular", monospace;
  --theme-primary: #475569;
  --theme-primary-dark: #334155;
  --theme-primary-light: #e2e8f0;
  --text-primary: #18212f;
  --text-secondary: #5b677a;
  --border-color: #dbe2ea;
  --bg-primary: #f4f7fb;
  --bg-secondary: #ffffff;
  --surface-shadow: 0 8px 28px rgba(14, 20, 33, 0.07);
  --radius-md: 12px;
}

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

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

body {
  font-family: var(--font-stack);
  line-height: 1.45;
  color: var(--text-primary);
  background:
    radial-gradient(circle at 5% -10%, #dbe9ff 0%, transparent 36%),
    radial-gradient(circle at 95% -20%, #ffe8d4 0%, transparent 30%),
    var(--bg-primary);
}

.header-content,
main,
.footer-content {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

header {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(4px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  min-height: 68px;
}

h1,
h2,
h3 {
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 0.85rem;
  color: var(--text-primary);
}

h1 {
  font-size: 1.2rem;
}

h2 {
  font-size: 1.35rem;
  margin-top: 1rem;
}

h3 {
  font-size: 1rem;
}

a {
  color: #9a4f07;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.logo-link {
  color: inherit;
  font-weight: 700;
  letter-spacing: 0.02em;
}

nav {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

nav a {
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 0.92rem;
}

nav a:hover {
  text-decoration: none;
  border-color: var(--border-color);
  color: var(--text-primary);
}

main {
  padding: 1.15rem 0 1.8rem;
}

.page-shell {
  display: grid;
  gap: 0.9rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.page-subtitle {
  margin-top: -0.4rem;
  font-size: 0.9rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.kpi-card {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.kpi-value {
  font-size: 1.2rem;
  font-weight: 700;
}

.quick-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.75rem;
  border: 1px dashed color-mix(in srgb, var(--theme-primary) 35%, #fff);
  border-radius: var(--radius-md);
  background: #fff;
}

.search-panel,
.relationship-panel,
.operational-table,
.interaction-feed {
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.search-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.5rem 0;
  flex-wrap: wrap;
  align-items: center;
}

.stack-sm {
  display: grid;
  gap: 0.5rem;
}

.muted {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.mode-nav {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.mode-nav a.mode-nav-active {
  background: var(--theme-primary);
  color: #fff;
  border-color: var(--theme-primary);
}

section {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  box-shadow: var(--surface-shadow);
}

p,
li,
td,
th,
label,
small {
  color: var(--text-secondary);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  border-bottom: 1px solid var(--border-color);
  padding: 0.55rem 0.45rem;
  vertical-align: top;
}

thead th {
  color: var(--text-primary);
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

ul {
  padding-left: 1.05rem;
}

li + li {
  margin-top: 0.35rem;
}

input,
button,
select,
textarea {
  font-family: inherit;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: #fff;
}

input,
select,
textarea {
  padding: 0.52rem 0.6rem;
}

textarea {
  resize: vertical;
}

button {
  cursor: pointer;
  font-weight: 600;
}

form {
  gap: 0.5rem;
}

.entity-card {
  margin: 0 0 1rem;
}

.context-bar {
  border-bottom: 3px solid var(--theme-primary);
  box-shadow: 0 2px 0 color-mix(in srgb, var(--theme-primary) 18%, transparent);
}

.workflow-chip {
  background: var(--theme-primary);
  color: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  transition: background 140ms ease, transform 120ms ease;
}

.workflow-chip:hover {
  background: var(--theme-primary-dark);
  transform: translateY(-1px);
}

.entity-card {
  border-left: 4px solid var(--theme-primary);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--theme-primary-light) 55%, transparent), transparent 120px),
    #ffffff;
}

.relationship-panel,
.interaction-feed,
.quick-actions,
.timeline-item,
.kpi-card,
.operational-table,
.search-panel,
.attachment-panel,
.notes-panel,
.task-pill {
  border-left: 3px solid color-mix(in srgb, var(--theme-primary) 30%, transparent);
}

.context-bar {
  color: var(--theme-primary);
  font-weight: 600;
}

.density-high table th,
.density-high table td {
  padding: 0.35rem 0.3rem;
  font-size: 0.88rem;
}

.density-medium table th,
.density-medium table td {
  padding: 0.5rem 0.4rem;
}

.density-low table th,
.density-low table td {
  padding: 0.65rem 0.55rem;
  font-size: 0.98rem;
}

.htmx-indicator {
  opacity: 0;
  pointer-events: none;
  transition: opacity 80ms linear;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

#htmx-global-indicator {
  position: fixed;
  right: 0.85rem;
  bottom: 0.85rem;
  z-index: 50;
  background: var(--theme-primary);
  color: #fff;
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  box-shadow: var(--surface-shadow);
}

.is-htmx-loading {
  opacity: 0.75;
}

footer {
  margin-top: 1rem;
  border-top: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.85);
}

.footer-content {
  padding: 0.95rem 0;
}

.footer-content p {
  font-size: 0.85rem;
}

@media (max-width: 800px) {
  .header-content,
  main,
  .footer-content {
    width: calc(100% - 1rem);
  }

  .header-content {
    min-height: 60px;
    align-items: flex-start;
    padding: 0.5rem 0;
    flex-direction: column;
  }

  nav {
    width: 100%;
  }

  nav a {
    font-size: 0.88rem;
  }

  h2 {
    font-size: 1.2rem;
  }
}
