:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #5d6b85;
  --line: #d9e0ec;
  --accent: #1f5eff;
  --accent-dark: #194bc9;
  --soft: #eef4ff;
  --danger: #a83b3b;
  --shadow: 0 12px 36px rgba(23, 32, 51, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar, .page {
  width: min(1600px, calc(100vw - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 28px 0 18px;
}

h1, h2 { margin: 0; }
h1 { font-size: 2rem; letter-spacing: -0.03em; }
h2 { font-size: 1.15rem; }
.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
}

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

.page {
  display: grid;
  gap: 18px;
  padding-bottom: 28px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.intro {
  padding: 20px;
  display: grid;
  gap: 18px;
}

.meta-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.meta-grid > div {
  background: var(--soft);
  border: 1px solid #d9e5ff;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.table-card { overflow: hidden; }
.table-wrap {
  overflow: auto;
  max-height: 72vh;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 2200px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f9fbff;
  font-size: 0.82rem;
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  vertical-align: top;
}

tbody td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  vertical-align: top;
  padding: 0;
  background: #fff;
}

tbody tr:nth-child(even) td { background: #fcfdff; }

th:first-child, td:first-child { border-left: 1px solid var(--line); }

td textarea {
  width: 100%;
  min-height: 108px;
  resize: vertical;
  padding: 12px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  line-height: 1.45;
}

td textarea:focus {
  background: #f7faff;
}

.actions-col, .row-actions {
  width: 86px;
  min-width: 86px;
  text-align: center;
}

.row-actions {
  padding: 10px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: white;
  cursor: pointer;
  font-size: 1rem;
}

.icon-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.table-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 16px;
  background: #fbfcff;
}

.add-row-btn, .btn {
  border: 0;
  cursor: pointer;
  border-radius: 12px;
  font: inherit;
}

.add-row-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--soft);
  color: var(--accent-dark);
  border: 1px dashed #b9cbff;
}

.plus {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: white;
  border: 1px solid #c9d7ff;
  font-weight: 700;
}

.btn {
  padding: 12px 16px;
}
.btn.primary {
  background: var(--accent);
  color: white;
}
.btn.primary:hover { background: var(--accent-dark); }
.btn.secondary {
  background: white;
  color: var(--accent-dark);
  border: 1px solid #c9d7ff;
}
.btn.ghost {
  background: white;
  color: var(--muted);
  border: 1px solid var(--line);
}

@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
  }
  .table-footer {
    flex-direction: column;
    align-items: stretch;
  }
}

@media print {
  body {
    background: white;
  }
  .topbar, .page {
    width: auto;
    margin: 0;
  }
  .card {
    border: 0;
    box-shadow: none;
    border-radius: 0;
  }
  .table-wrap {
    overflow: visible;
    max-height: none;
  }
  table {
    min-width: 0;
    font-size: 10px;
  }
  thead th {
    position: static;
    background: white;
  }
  td textarea {
    min-height: auto;
    padding: 8px;
    resize: none;
    overflow: visible;
  }
  .no-print {
    display: none !important;
  }
}
