:root {
  --bg: #f5f6f2;
  --surface: #ffffff;
  --surface-soft: #f8f8f4;
  --ink: #20231f;
  --muted: #666d63;
  --line: #d9ddd2;
  --teal: #0f766e;
  --teal-dark: #0b5f59;
  --amber: #b86e00;
  --red: #b42318;
  --green: #24734b;
  --violet: #5b4b8a;
  --shadow: 0 18px 45px rgba(33, 36, 31, 0.11);
  color-scheme: light;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
}

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

button {
  cursor: pointer;
}

.shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: inline-grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: #173f3a;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 2.1vw, 2.2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.button,
.text-button,
.icon-button,
.filter {
  border: 0;
  border-radius: 8px;
}

.button {
  min-height: 42px;
  padding: 0 16px;
  font-weight: 750;
  white-space: nowrap;
}

.button-primary {
  background: var(--teal);
  color: #fff;
}

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

.button-muted {
  background: #e8ebe2;
  color: var(--ink);
}

.button-muted:hover {
  background: #dfe4d8;
}

.text-button {
  background: transparent;
  color: var(--teal);
  font-size: 0.9rem;
  font-weight: 760;
  padding: 8px 4px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  color: var(--ink);
  font-size: 2rem;
  line-height: 1;
}

.metric-total {
  border-top: 4px solid var(--violet);
}

.metric-danger {
  border-top: 4px solid var(--red);
}

.metric-warning {
  border-top: 4px solid var(--amber);
}

.metric-money {
  border-top: 4px solid var(--teal);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  align-items: start;
}

.main-panel,
.side-panel,
.dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.main-panel {
  overflow: hidden;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 220px;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

label span,
.search-wrap span,
.select-wrap span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 760;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd1c4;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 42px;
  padding: 10px 11px;
  outline: none;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
.button:focus-visible,
.filter:focus-visible,
.text-button:focus-visible,
.icon-button:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.22);
  outline-offset: 2px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.filter {
  min-height: 36px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  font-weight: 760;
}

.filter:hover,
.filter.is-active {
  background: #20312e;
  color: #fff;
}

.table-shell {
  min-height: 370px;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
}

.records-table th {
  background: #eef1ea;
  color: #4d554d;
  font-size: 0.78rem;
  letter-spacing: 0;
  text-align: left;
  text-transform: uppercase;
}

.records-table th,
.records-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.records-table td {
  font-size: 0.95rem;
}

.records-table tr:hover td {
  background: #fbfcf8;
}

.client-name {
  display: block;
  margin-bottom: 4px;
  font-weight: 820;
}

.subtext {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.domain {
  font-weight: 760;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 820;
  white-space: nowrap;
}

.status-expired,
.status-critical {
  background: #fde7e3;
  color: var(--red);
}

.status-today,
.status-soon {
  background: #fff0d4;
  color: #865000;
}

.status-watch {
  background: #e8e4f5;
  color: var(--violet);
}

.status-active {
  background: #dff1e7;
  color: var(--green);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 0 9px;
  font-size: 0.86rem;
  font-weight: 760;
}

.mini-button:hover {
  background: #eff3ec;
}

.mini-button.danger {
  color: var(--red);
}

.side-panel {
  padding: 14px;
}

.side-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

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

.due-item {
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.due-item.is-danger {
  border-left-color: var(--red);
}

.due-item.is-warning {
  border-left-color: var(--amber);
}

.due-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.due-title {
  margin-bottom: 2px;
  font-weight: 820;
}

.due-date {
  color: var(--muted);
  font-size: 0.86rem;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 330px;
  padding: 36px 22px;
  text-align: center;
}

.empty-state h3 {
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.empty-state p {
  max-width: 420px;
  margin: 0 auto 18px;
  color: var(--muted);
  line-height: 1.5;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 28, 23, 0.48);
}

.dialog {
  position: relative;
  width: min(860px, 100%);
  max-height: min(92vh, 860px);
  overflow: auto;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-actions {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
  background: var(--surface-soft);
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  background: #eff3ec;
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}

.wide {
  grid-column: 1 / -1;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(360px, calc(100% - 36px));
  border-radius: 8px;
  background: #20312e;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

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

  .side-panel {
    order: -1;
  }
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 20px, 720px);
    padding-top: 14px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions .button {
    flex: 1 1 142px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .toolbar,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .records-table,
  .records-table thead,
  .records-table tbody,
  .records-table tr,
  .records-table th,
  .records-table td {
    display: block;
  }

  .records-table thead {
    display: none;
  }

  .records-table tr {
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
  }

  .records-table td {
    border: 0;
    padding: 6px 0;
  }

  .records-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
  }
}

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

  .brand-mark {
    width: 42px;
    height: 42px;
  }

  .dialog-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
}
