:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --ink: #202426;
  --muted: #687174;
  --line: #d7d2c7;
  --panel: #ffffff;
  --accent: #0d6b6f;
  --accent-strong: #095256;
  --warm: #a4542a;
  --danger: #a33b32;
  --focus: #f0ba43;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button,
.button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 0 14px;
  white-space: nowrap;
  text-decoration: none;
}

button:hover:not(:disabled),
.button:hover {
  border-color: var(--accent);
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

button.primary,
.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

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

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

input {
  min-height: 40px;
}

textarea {
  min-height: 320px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 42%, transparent);
  outline-offset: 1px;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0;
}

.auth-gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-gate[hidden],
.app-shell[hidden] {
  display: none;
}

.auth-panel {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 28px;
}

.auth-panel .button {
  display: inline-grid;
  place-items: center;
  margin-top: 18px;
}

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

h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 2.4rem);
  line-height: 1.1;
  letter-spacing: 0;
}

.muted {
  margin: 7px 0 0;
  color: var(--muted);
}

.summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.summary span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-weight: 700;
  padding: 7px 11px;
}

.logout-link {
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--accent-strong);
  font-weight: 800;
  padding: 0 11px;
  text-decoration: none;
}

.app-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.app-tab {
  min-width: 94px;
  border-bottom: 0;
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.app-tab.active {
  border-color: var(--line);
  background: #fff;
  color: var(--accent-strong);
}

.tab-panel[hidden] {
  display: none;
}

.placeholder-panel {
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 28px;
}

.placeholder-panel h2 {
  margin: 0 0 8px;
  font-size: 1.4rem;
  letter-spacing: 0;
}

.toolbar,
.credential-tools,
.actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.toolbar label,
.credential-tools label,
.actions label.compact {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.toolbar label {
  flex: 1 1 150px;
}

.credential-tools {
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.credential-tools label {
  flex: 1 1 260px;
}

select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
}

.toolbar label:nth-child(1),
.toolbar label:nth-child(2) {
  flex-basis: 220px;
}

.actions {
  justify-content: space-between;
}

.left-actions,
.right-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.compact {
  width: min(260px, 100%);
}

.segmented {
  display: flex;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.segmented label {
  display: grid;
  place-items: center;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.segmented span {
  display: grid;
  place-items: center;
  min-height: 38px;
  min-width: 62px;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 800;
}

.segmented input:checked + span {
  background: #e5f2ef;
  color: var(--accent-strong);
}

.event-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.invoice-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.invoice-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.invoice-actions {
  display: flex;
  justify-content: flex-end;
}

.progress-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.progress-panel > div {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

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

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.progress-track {
  height: 14px;
  margin-top: 9px;
  border: 1px solid #b9d4cf;
  border-radius: 999px;
  background: #edf3f1;
  overflow: hidden;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #3c8b63);
  transition: width 220ms ease;
}

.progress-track[data-active="true"] .progress-fill {
  background-image: repeating-linear-gradient(
    45deg,
    var(--accent) 0,
    var(--accent) 10px,
    #3c8b63 10px,
    #3c8b63 20px
  );
}

.progress-detail {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.progress-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.progress-panel strong {
  display: block;
  margin-top: 4px;
  font-size: 1.45rem;
  line-height: 1;
}

.table-head,
.event-row {
  display: grid;
  grid-template-columns: 44px minmax(210px, 1.35fr) minmax(150px, 0.65fr) minmax(180px, 1fr) minmax(90px, 0.35fr);
  gap: 12px;
  align-items: center;
}

.table-head {
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  background: #ede8dc;
  color: #596165;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.table-head span,
.event-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-head span:first-child,
.event-row input {
  justify-self: center;
}

.event-list {
  max-height: calc(100vh - 300px);
  min-height: 280px;
  overflow: auto;
}

.event-row {
  min-height: 54px;
  border-bottom: 1px solid #ebe7dd;
  padding: 0 14px 0 0;
  cursor: pointer;
}

.event-row:hover {
  background: #f8fbfa;
}

.event-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.event-name {
  font-weight: 750;
}

.empty-row {
  display: grid;
  min-height: 280px;
  place-items: center;
  color: var(--muted);
  font-weight: 750;
}

.status {
  min-height: 28px;
  margin-top: 12px;
  color: var(--muted);
  font-weight: 700;
}

.status[data-type="error"] {
  color: var(--danger);
}

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

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

  .summary,
  .left-actions,
  .right-actions {
    justify-content: flex-start;
  }

  .app-tabs {
    overflow-x: auto;
  }

  .toolbar > *,
  .left-actions > *,
  .right-actions > * {
    flex: 1 1 100%;
    width: 100%;
  }

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

  .table-head {
    display: none;
  }

  .event-list {
    max-height: none;
  }

  .event-row {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 4px 10px;
    padding: 12px 12px 12px 0;
  }

  .event-row input {
    grid-row: 1 / span 4;
  }

  .event-row span {
    white-space: normal;
  }
}
