:root {
  color-scheme: light;
  --bg-primary: #f4f3ee;
  --bg-secondary: #eeede6;
  --bg-tertiary: #e6e2d8;
  --bg-inverse: #191817;
  --surface: #f9f8f3;
  --surface-soft: #eeede6;
  --text-primary: #191817;
  --text-secondary: #5a554e;
  --text-muted: #8a847a;
  --accent: #c96442;
  --accent-hover: #b55738;
  --border: #d8d3c8;
  --border-strong: #c9c1b2;
  --success: #6b7a3d;
  --warning: #c98a42;
  --danger: #a53e2a;
  --shadow-modal: 0 8px 24px rgba(25, 24, 23, 0.08);
  --measure: 68ch;
}

* {
  box-sizing: border-box;
}

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

html {
  background: var(--bg-primary);
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 14% 8%, rgba(201, 100, 66, 0.08), transparent 28rem),
    linear-gradient(180deg, rgba(238, 237, 230, 0.72), transparent 22rem),
    var(--bg-primary);
  color: var(--text-primary);
  font-family: "Source Sans 3", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  color: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin: 0;
}

h1,
.login-card-heading,
.sidebar-logo {
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  letter-spacing: 0;
  font-weight: 500;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1.04;
}

h2 {
  font-size: 24px;
  font-weight: 500;
  line-height: 1.2;
}

.eyebrow,
.group-kicker,
.sidebar-caption {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
}

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

.login-stage {
  display: grid;
  width: min(420px, 100%);
}

.group-card:hover,
.activity:hover,
.history-shell:hover {
  outline: 1px solid var(--border);
}

.login-card {
  position: relative;
  display: grid;
  gap: 16px;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-primary) 72%, white);
}

.login-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 32px;
  right: 32px;
  height: 3px;
  background: var(--accent);
}

.login-card-heading {
  margin-bottom: 8px;
  font-size: 32px;
  line-height: 1.12;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 28px 20px;
  border-right: 1px solid var(--border);
  background: var(--bg-secondary);
}

.sidebar-logo {
  font-size: 30px;
  line-height: 1.04;
}

.sidebar-caption {
  margin-top: 8px;
}

.sidebar-nav {
  display: grid;
  gap: 8px;
  margin-top: 40px;
}

.sidebar-link {
  min-height: 42px;
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
}

.sidebar-link:hover,
.sidebar-link.active {
  background: var(--bg-primary);
  color: var(--text-primary);
}

.sidebar-user {
  display: grid;
  gap: 2px;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.sidebar-user span {
  font-weight: 500;
}

.sidebar-user small {
  color: var(--text-muted);
}

.main {
  min-width: 0;
  padding: 36px 40px 48px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.summary-strip {
  display: flex;
  gap: 12px;
}

.summary-strip div {
  min-width: 108px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-primary) 70%, white);
}

.summary-strip span {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
}

.summary-strip strong {
  display: block;
  margin-top: 2px;
  font-size: 24px;
  font-weight: 500;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  margin-top: 32px;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 18px;
}

.group-card,
.activity,
.history-shell {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg-primary) 76%, white);
  box-shadow: var(--shadow-modal);
}

.group-card {
  padding: 20px;
}

.group-card.busy {
  background:
    linear-gradient(180deg, rgba(201, 138, 66, 0.12), transparent 46%),
    color-mix(in srgb, var(--bg-primary) 76%, white);
}

.group-head,
.title-row,
.alias-row,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.title-row {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 8px;
}

.meta {
  margin-top: 12px;
  color: var(--text-secondary);
  font-size: 15px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 500;
}

.status-pill.idle {
  color: var(--success);
  background: rgba(107, 122, 61, 0.09);
}

.status-pill.busy {
  color: #8a5a14;
  background: rgba(201, 138, 66, 0.13);
}

.alias-row {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin: 18px 0;
}

code {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-primary);
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.lease-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 0 0 18px;
}

dt {
  color: var(--text-muted);
  font-size: 13px;
}

dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-weight: 500;
}

.notes {
  margin: -4px 0 18px;
  color: var(--text-secondary);
  font-size: 15px;
}

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

.occupy-form {
  display: grid;
  gap: 12px;
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--surface);
  color: var(--text-primary);
}

input {
  min-height: 42px;
}

textarea {
  min-height: 280px;
  resize: vertical;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}

input:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 18px;
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}

.primary {
  width: 100%;
  color: var(--bg-primary);
  background: var(--accent);
}

.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.danger {
  width: 100%;
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
  background: color-mix(in srgb, var(--danger) 7%, var(--bg-primary));
}

.danger:hover {
  background: color-mix(in srgb, var(--danger) 11%, var(--bg-primary));
}

.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 18px;
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.secondary-action:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
}

.icon-button {
  width: 36px;
  min-height: 36px;
  border-color: var(--border);
  padding: 0;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 24px;
  line-height: 1;
}

.text-button {
  min-height: auto;
  justify-content: flex-start;
  border: 0;
  padding: 8px 0 0;
  color: var(--text-primary);
  background: transparent;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 4px;
}

.activity {
  display: grid;
  gap: 18px;
  align-self: start;
  padding: 22px;
}

.api-card {
  display: grid;
  gap: 16px;
}

.api-card {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.api-key-readonly {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.api-key-readonly span {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.api-key-readonly code {
  display: block;
  overflow-wrap: anywhere;
}

.api-example {
  display: grid;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 14px;
}

.api-example p {
  margin-top: 4px;
}

.api-example code {
  display: block;
  overflow-wrap: anywhere;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(25, 24, 23, 0.38);
}

.agent-prompt-modal {
  display: grid;
  width: min(760px, 100%);
  max-height: min(86vh, 760px);
  gap: 16px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-modal);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-actions {
  align-items: center;
}

.modal-actions .primary {
  width: auto;
}

.copy-status {
  min-height: 1.4em;
  color: var(--success);
  font-size: 14px;
}

.event-list {
  display: grid;
  gap: 14px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.event-list li {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.event-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

time {
  display: block;
  color: var(--text-muted);
  font-size: 13px;
}

.event-list strong,
.event-list span {
  display: inline-block;
  margin-top: 4px;
}

.event-list span {
  color: var(--text-muted);
}

.event-list p {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.history-shell {
  margin-top: 32px;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

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

th {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tr:nth-child(even) td {
  background: rgba(238, 237, 230, 0.44);
}

.empty {
  color: var(--text-muted);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 18px;
    height: auto;
    padding: 18px 20px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-nav {
    display: flex;
    margin: 0;
  }

  .sidebar-user {
    margin: 0 0 0 auto;
    padding: 0;
    border: 0;
  }

  .main {
    padding: 28px 20px 40px;
  }

  .login-stage {
    width: min(420px, 100%);
  }
}

@media (max-width: 720px) {
  body {
    font-size: 16px;
  }

  .login-shell {
    padding: 24px 18px;
  }

  .login-card {
    padding: 24px 20px;
  }

  .sidebar {
    align-items: flex-start;
    flex-direction: column;
  }

  .sidebar-user {
    margin-left: 0;
  }

  .page-head {
    flex-direction: column;
  }

  .summary-strip {
    width: 100%;
  }

  .summary-strip div {
    flex: 1;
  }

  .group-grid {
    grid-template-columns: 1fr;
  }

  .lease-details {
    grid-template-columns: 1fr;
  }

  .agent-fields {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    display: grid;
    align-items: stretch;
  }

  .modal-actions .primary,
  .secondary-action {
    width: 100%;
  }
}
