:root {
  color-scheme: light;
  --red: #e4002b;
  --red-dark: #b90024;
  --ink: #17191d;
  --muted: #69707d;
  --line: #dfe3ea;
  --soft: #f5f6f8;
  --green: #15803d;
  --green-soft: #dcfce7;
  --amber-soft: #fef3c7;
  --shadow: 0 1px 2px rgba(23, 25, 29, 0.04), 0 10px 28px rgba(23, 25, 29, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: transparent;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  max-width: 100%;
  min-width: 0;
  font: inherit;
}

button {
  cursor: pointer;
}

.alecrin-app {
  display: grid;
  gap: 18px;
  max-width: 100%;
  min-width: 0;
  padding: 1px;
  overflow-x: hidden;
}

.alecrin-header,
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.alecrin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 96px;
  padding: 20px;
  border-top: 4px solid var(--red);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--red);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 6px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 0.98;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
}

.alecrin-header p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 750;
}

.sync-chip {
  flex: 0 0 auto;
  min-width: 148px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
}

.sync-chip[data-state="synced"] {
  background: var(--green-soft);
  border-color: #86efac;
  color: #166534;
}

.sync-chip[data-state="loading"] {
  background: var(--amber-soft);
  border-color: #fbbf24;
  color: #92400e;
}

.sync-chip[data-state="error"] {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.alecrin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
  min-width: 0;
}

.side-column {
  display: grid;
  align-content: start;
  gap: 18px;
  min-width: 0;
}

.panel {
  min-width: 0;
  padding: 20px;
}

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

.stack {
  display: grid;
  gap: 14px;
}

.form-grid {
  display: grid;
  gap: 12px;
  min-width: 0;
}

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

.form-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 13px;
  font-weight: 800;
}

input,
select {
  height: 48px;
  min-height: 48px;
}

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

input[type="date"] {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  line-height: 48px;
  text-align: center;
}

input:focus,
textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(228, 0, 43, 0.12);
  outline: none;
}

.previous-card,
.ink-card,
.replace-card {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.previous-card span,
.previous-card small {
  color: var(--muted);
  font-weight: 850;
}

.previous-card strong {
  font-size: 1.1rem;
}

.ink-card {
  background: #f8fafc;
}

.replace-card,
.manual-card,
.settings-group {
  background: #fff7ed;
  border-color: #fed7aa;
}

.manual-card,
.settings-group {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
}

.manual-card p:not(.eyebrow) {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.settings-group {
  background: #f8fafc;
  border-color: var(--line);
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.replacement-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid #fed7aa;
}

.replacement-grid label {
  font-size: 0.78rem;
}

.check-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff;
}

.check-grid input {
  width: 18px;
  height: 18px;
  min-height: 18px;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  min-height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 18px;
  font-weight: 900;
}

button.primary,
button.danger {
  border-color: var(--red);
  background: var(--red);
  color: #fff;
}

button.secondary {
  justify-self: end;
}

.result-panel {
  border-top: 4px solid var(--ink);
}

.result-total {
  display: grid;
  gap: 4px;
  margin: 16px 0;
  padding: 18px;
  border-radius: 8px;
  background: #17191d;
  color: #fff;
}

.result-total span {
  color: #b9bec7;
  font-weight: 850;
}

.result-total strong {
  font-size: clamp(2.3rem, 7vw, 4rem);
  line-height: 1;
  color: #fff;
}

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

.metric-grid div {
  display: grid;
  gap: 4px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.metric-grid span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-grid strong {
  font-size: 1.45rem;
}

.result-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-weight: 750;
}

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

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 8px;
  background: #fff;
}

.history-item strong {
  display: block;
  font-size: 1.05rem;
}

.history-item small,
.history-item p {
  color: var(--muted);
  font-weight: 750;
}

.history-item p {
  margin: 8px 0 0;
}

.history-metrics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 9px;
}

.history-metrics span {
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.history-actions {
  display: flex;
  gap: 8px;
}

.empty {
  padding: 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

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

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(420px, 100%);
  padding: 22px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

.modal-card p:not(.eyebrow) {
  color: var(--muted);
  font-weight: 750;
}

@media (max-width: 900px) {
  .alecrin-grid,
  .form-grid.two,
  .form-grid.four,
  .replacement-grid,
  .check-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .alecrin-header,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .sync-chip,
  button,
  button.secondary {
    width: 100%;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .history-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}
