@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --bg: #f2f5f7;
  --surface: #ffffff;
  --ink: #111111;
  --muted: #52606f;
  --line: #d7dfe6;
  --primary: #18344f;
  --primary-strong: #0f263b;
  --success-bg: #e6f6ec;
  --success-ink: #18643c;
  --warn-bg: #fff4dd;
  --warn-ink: #8d5206;
  --danger: #b42318;
  --radius: 16px;
  --shadow: 0 12px 28px rgba(24, 52, 79, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', 'Segoe UI', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 0% -5%, rgba(24, 52, 79, 0.12), transparent 35%),
    radial-gradient(circle at 100% 0%, rgba(23, 127, 172, 0.1), transparent 30%),
    var(--bg);
}

h1,
h2,
p {
  margin: 0;
}

.app-shell {
  width: min(980px, calc(100% - 1rem));
  margin: 0 auto;
  padding: 0.8rem 0 1.4rem;
  display: grid;
  gap: 0.8rem;
}

.hero {
  border-radius: var(--radius);
  padding: 1rem;
  background: linear-gradient(140deg, #0f263b, #24496a 58%, #326890);
  color: #fff;
  box-shadow: var(--shadow);
}

.eyebrow {
  display: inline-flex;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  background: rgba(255, 255, 255, 0.17);
  margin-bottom: 0.45rem;
}

.hero h1 {
  font-size: clamp(1.65rem, 5vw, 2rem);
  margin-bottom: 0.2rem;
}

.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.hero .muted {
  color: rgba(255, 255, 255, 0.88);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem;
}

.card h2 {
  font-size: 1.02rem;
  margin-bottom: 0.72rem;
}

.grid {
  display: grid;
  gap: 0.65rem;
}

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

.hidden {
  display: none !important;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.9rem;
  font-weight: 500;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0.62rem 0.68rem;
  font: inherit;
  color: var(--ink);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(50, 104, 144, 0.2);
  border-color: #326890;
}

textarea {
  resize: vertical;
}

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

.row-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0.55rem 0.92rem;
}

.btn.primary {
  background: linear-gradient(140deg, var(--primary), var(--primary-strong));
  color: #fff;
}

.btn.secondary {
  border: 1px solid #204364;
  color: #204364;
  background: #eef6ff;
}

.btn.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: #334155;
}

.item-list {
  display: grid;
  gap: 0.62rem;
}

.item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem;
  background: #fcfdff;
}

.item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.item-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #30465a;
}

.icon-btn {
  border: 0;
  border-radius: 10px;
  background: #ffeff0;
  color: #b42318;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
}

.item-grid {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: 1fr;
}

.line-total {
  display: flex;
  justify-content: flex-end;
  font-size: 0.9rem;
  margin-top: 0.25rem;
  color: #204364;
}

.total-card {
  border-width: 2px;
}

.total-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 1.06rem;
}

.threshold {
  margin-top: 0.35rem;
  padding: 0.55rem 0.62rem;
  border-radius: 10px;
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.threshold.ok {
  background: var(--success-bg);
  color: var(--success-ink);
}

.checkbox-row {
  grid-template-columns: auto 1fr;
  align-items: flex-start;
  gap: 0.65rem;
}

.checkbox-row input {
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.1rem;
}

.split-fields {
  display: grid;
  gap: 0.55rem;
}

.signature-pad {
  width: 100%;
  height: 190px;
  border-radius: 12px;
  border: 2px dashed #b5c2ce;
  background: #fff;
  touch-action: none;
}

.error {
  margin-top: 0.55rem;
  font-size: 0.9rem;
  color: var(--danger);
  min-height: 1.2rem;
}

.result {
  margin-top: 0.6rem;
  display: none;
  border: 1px solid #b7ddc5;
  border-radius: 12px;
  background: #f1fbf5;
  padding: 0.68rem;
  color: #1e5f3a;
  font-size: 0.95rem;
}

.result a {
  color: #11472a;
  font-weight: 700;
  text-decoration: underline;
}

.recent-list {
  display: grid;
  gap: 0.5rem;
}

.recent-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0.58rem;
  display: grid;
  gap: 0.18rem;
}

.recent-item strong {
  font-size: 0.93rem;
}

.recent-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.recent-actions a {
  font-size: 0.86rem;
  text-decoration: underline;
  color: #204364;
}

.inline-btn {
  border: 0;
  background: transparent;
  color: #204364;
  text-decoration: underline;
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
  padding: 0;
}

@media (min-width: 780px) {
  .app-shell {
    width: min(980px, calc(100% - 2.4rem));
    padding-top: 1.2rem;
  }

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

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

  .item-grid .full {
    grid-column: 1 / -1;
  }
}
