:root {
  --ink: #121417;
  --muted: #68707c;
  --line: #d9dee6;
  --paper: #ffffff;
  --mist: #f5f6f8;
  --rail: #171b20;
  --rail-soft: #242a31;
  --teal: #087f72;
  --red: #c92a3a;
  --amber: #d99a18;
  --green: #2f8f54;
  --blue: #2c5f9e;
  --shadow: 0 18px 48px rgba(18, 20, 23, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--mist);
  font-family: Verdana, Geneva, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(320px, 1.25fr) minmax(320px, 0.75fr);
  min-height: 100vh;
}

.login-visual {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background: var(--rail);
}

.login-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.86) contrast(1.05);
}

.login-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(18, 20, 23, 0.82), rgba(18, 20, 23, 0.18));
}

.visual-copy {
  position: absolute;
  left: 48px;
  right: 48px;
  bottom: 48px;
  z-index: 1;
  color: #fff;
  max-width: 680px;
}

.visual-copy h1,
.login-panel h2,
.sidebar h1,
.topbar h2 {
  margin: 0;
  font-family: Verdana, Geneva, sans-serif;
  line-height: 1.04;
}

.visual-copy h1 {
  font-size: 48px;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100vh;
  padding: 48px;
  background: var(--paper);
  border-left: 1px solid var(--line);
}

.login-panel h2 {
  margin-top: 8px;
  font-size: 36px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  line-height: 1.6;
}

.form-stack {
  display: grid;
  gap: 18px;
  margin-top: 30px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--ink);
  font-weight: 800;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
  background: #fff;
}

input:focus {
  outline: 3px solid rgba(8, 127, 114, 0.18);
  border-color: var(--teal);
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 11px 16px;
  color: #fff;
  background: var(--teal);
  font-weight: 900;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.94);
}

button.loading {
  opacity: 0.72;
}

.secondary-button {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.secondary-link-button {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 16px;
  color: var(--ink);
  background: #fff;
  font-weight: 900;
  text-decoration: none;
}

.secondary-link-button:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--red);
}

.dashboard-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(18, 20, 23, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, #f8f9fb 0, #eef1f4 100%);
  background-size: 48px 48px, auto;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  height: 100vh;
  padding: 26px;
  background: var(--rail);
  color: #fff;
  border-right: 1px solid #2c333c;
}

.brand-block {
  display: grid;
  gap: 12px;
}

.sidebar .eyebrow {
  color: #9fc5bb;
}

.sidebar h1 {
  font-size: 32px;
}

.status-pill {
  justify-self: start;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 7px 10px;
  color: #dfe8e5;
  background: var(--rail-soft);
  font-size: 12px;
  font-weight: 900;
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.sidebar a {
  display: block;
  border-radius: 8px;
  padding: 12px 10px;
  color: #c9d1d9;
  text-decoration: none;
  font-weight: 800;
}

.sidebar a.active,
.sidebar a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.dashboard-content {
  display: grid;
  gap: 18px;
  align-content: start;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.topbar h2 {
  font-size: 34px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timestamp {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.metric-tile {
  display: grid;
  gap: 9px;
  min-height: 118px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.metric-tile span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-tile strong {
  font-size: 38px;
  line-height: 1;
}

.metric-tile small {
  color: var(--muted);
  font-weight: 800;
}

.metric-tile.urgent {
  border-left-color: var(--red);
}

.mail-console,
.section-panel,
.activity-band,
.agent-chat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.mail-console {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.section-panel,
.activity-band,
.agent-chat {
  padding: 18px;
}

.agent-chat {
  display: grid;
  gap: 14px;
  border-top: 4px solid var(--blue);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
}

.section-heading h3 {
  margin: 0;
  font-size: 21px;
}

.section-heading span {
  color: var(--muted);
  font-weight: 900;
}

.mail-toolbar {
  display: flex;
  align-items: end;
  gap: 12px;
  padding-top: 4px;
}

.search-field {
  width: min(520px, 100%);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.search-field input {
  color: var(--ink);
  font-size: 14px;
  text-transform: none;
}

.email-workbench {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(0, 1.58fr);
  gap: 16px;
  min-height: 430px;
}

.email-list {
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}

.email-list-item {
  display: grid;
  gap: 8px;
  width: 100%;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  color: var(--ink);
  background: #fbfcfd;
  text-align: left;
  cursor: pointer;
}

.email-list-item.active,
.email-list-item:hover {
  border-color: var(--teal);
  background: #edf7f4;
  filter: none;
}

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

.email-list-item strong {
  overflow-wrap: anywhere;
}

.email-list-item span:not(.tag) {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.email-detail {
  display: grid;
  grid-template-rows: auto auto auto minmax(260px, 1fr);
  gap: 16px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 252, 253, 0.98)),
    #fbfcfd;
}

.email-detail-header {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.email-title-line {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.email-detail-header strong {
  overflow-wrap: anywhere;
  font-size: 23px;
  line-height: 1.25;
}

.email-detail-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
}

.email-detail-meta div,
.email-intelligence div {
  display: grid;
  gap: 5px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.email-detail-meta span,
.email-intelligence span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.email-detail-meta strong,
.email-intelligence strong {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.35;
}

.email-intelligence {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 0.4fr);
  gap: 10px;
}

.email-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.email-actions button {
  min-width: 118px;
}

.email-actions span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.email-summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  border-left: 4px solid var(--teal);
  padding: 2px 0 2px 14px;
  font-weight: 700;
}

.email-points {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0 0 0 20px;
  color: var(--ink);
  font-weight: 700;
}

.email-points:empty {
  display: none;
}

.email-points li {
  line-height: 1.45;
}

.email-body {
  min-height: 220px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  color: var(--ink);
  background: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.72;
}

.email-body p {
  max-width: 78ch;
  margin: 0 0 16px;
  overflow-wrap: anywhere;
}

.email-body p:last-child {
  margin-bottom: 0;
}

.email-html-content {
  max-width: 880px;
  overflow-wrap: anywhere;
  word-break: normal;
}

.email-html-content :where(p, div, section, article, blockquote) {
  max-width: 78ch;
  line-height: 1.68;
}

.email-html-content :where(table) {
  width: max-content;
  max-width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  font-size: 14px;
}

.email-html-content :where(th, td) {
  border: 1px solid var(--line);
  padding: 8px 10px;
  vertical-align: top;
}

.email-html-content :where(img) {
  max-width: 100%;
  height: auto;
}

.email-html-content :where(a) {
  color: var(--teal-dark);
  font-weight: 700;
}

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

.pending-list,
.task-list,
.runtime-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.pending-item,
.task-item,
.runtime-item,
.empty-state {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.runtime-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.pending-item strong,
.task-item strong,
.runtime-item strong {
  overflow-wrap: anywhere;
}

.pending-item span:not(.tag),
.task-item span:not(.tag),
.runtime-item span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.empty-state {
  color: var(--muted);
  line-height: 1.5;
}

.agent-panel {
  border-top: 4px solid var(--teal);
}

.agent-status {
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--ink);
  background: #e6ebf0;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.agent-status.live {
  color: #fff;
  background: var(--green);
}

.agent-status.standby,
.agent-status.checking {
  color: var(--ink);
  background: #f3cf75;
}

.agent-status.error {
  color: #fff;
  background: var(--red);
}

.agent-summary {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.agent-summary strong {
  font-size: 18px;
}

.agent-summary span,
.agent-note {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
}

.agent-details {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.agent-details div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.agent-details span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.agent-details strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.agent-note {
  margin: 12px 0 0;
}

.chat-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 220px;
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.chat-message {
  display: grid;
  gap: 5px;
  max-width: min(760px, 88%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.chat-message.admin {
  justify-self: end;
  border-color: rgba(8, 127, 114, 0.26);
  background: #edf7f4;
}

.chat-message.zeroclaw {
  justify-self: start;
}

.chat-message.pending {
  border-color: rgba(217, 154, 24, 0.42);
  background: #fff8e6;
}

.chat-message.error {
  border-color: rgba(185, 45, 45, 0.32);
  background: #fff1f1;
}

.chat-message span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.chat-message p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

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

.chat-input textarea {
  width: 100%;
  resize: vertical;
  min-height: 82px;
  max-height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  line-height: 1.45;
  text-transform: none;
}

.chat-input textarea:focus {
  outline: 3px solid rgba(8, 127, 114, 0.18);
  border-color: var(--teal);
}

.tag {
  justify-self: start;
  border-radius: 999px;
  padding: 4px 9px;
  color: #fff;
  background: var(--blue);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.tag.alta {
  background: var(--red);
}

.tag.media {
  color: var(--ink);
  background: #f3cf75;
}

.tag.bassa {
  background: var(--green);
}

.activity-list {
  display: grid;
  gap: 4px;
  margin: 12px 0 0;
  padding-left: 24px;
}

.activity-list li {
  padding: 6px 0;
  color: var(--muted);
  font-weight: 750;
}

@media (max-width: 1100px) {
  .operations-grid,
  .email-workbench {
    grid-template-columns: 1fr;
  }

  .email-detail-meta {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

@media (max-width: 900px) {
  .login-shell,
  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 340px;
  }

  .visual-copy {
    left: 24px;
    right: 24px;
    bottom: 24px;
  }

  .visual-copy h1 {
    font-size: 34px;
  }

  .login-panel {
    min-height: auto;
    padding: 32px 22px;
    border-left: 0;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

@media (max-width: 620px) {
  .dashboard-content {
    padding: 18px;
  }

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

  .topbar,
  .topbar-actions,
  .section-heading,
  .email-title-line,
  .email-intelligence,
  .email-actions {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .email-detail-meta {
    grid-template-columns: 1fr;
  }
}
