:root {
  --bg: #f5f2ea;
  --panel: #fffdf8;
  --panel-border: #dacfb9;
  --accent: #1f5c4f;
  --accent-soft: #dcefe6;
  --danger-soft: #f9d8d3;
  --warn-soft: #fff0b8;
  --text: #2c241d;
  --muted: #6f6255;
  --line: #d9cfbe;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(223, 188, 112, 0.22), transparent 32%),
    linear-gradient(180deg, #f8f5ef 0%, var(--bg) 100%);
  color: var(--text);
  font: 14px/1.5 "Yu Gothic UI", "Hiragino Sans", sans-serif;
}

a {
  color: var(--accent);
}

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

.shell {
  width: 96vw;
  max-width: 96vw;
  margin: 0 auto;
  padding: 24px 0 48px;
}

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

.auth-card,
.panel {
  background: rgba(255, 253, 248, 0.96);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(74, 54, 31, 0.08);
}

.auth-card {
  width: min(440px, 100%);
  padding: 28px;
}

.auth-card h1,
.page-header h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.2;
}

.auth-card p,
.page-header p {
  margin: 0;
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.form-grid label {
  display: grid;
  gap: 6px;
  font-weight: 600;
}

.text-input,
.select-input,
.text-area {
  width: 100%;
  border: 1px solid #c9bda8;
  border-radius: 10px;
  background: #fffefb;
  padding: 10px 12px;
  color: var(--text);
}

.text-area {
  min-height: 92px;
  resize: vertical;
}

.primary-button,
.ghost-button {
  border-radius: 999px;
  padding: 10px 16px;
  border: 1px solid transparent;
  cursor: pointer;
}

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

.ghost-button {
  background: transparent;
  color: var(--accent);
  border-color: var(--panel-border);
}

.error-box,
.success-box {
  margin-top: 16px;
  border-radius: 12px;
  padding: 12px 14px;
}

.error-box {
  background: #fff1ee;
  color: #7b3025;
}

.success-box {
  background: #eef8f3;
  color: #1b5a41;
}

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

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.toolbar form {
  margin: 0;
}

.compact-stats {
  margin-bottom: 12px;
  padding: 12px 14px;
}

.stats-list {
  display: grid;
  gap: 6px;
  font-size: 12px;
}

.stat-row {
  display: grid;
  grid-template-columns: 140px 1fr 48px;
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 9px;
  border-radius: 999px;
  background: #efe6d4;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #9bc89b 0%, #2d8b57 100%);
}

.panel {
  padding: 14px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  background: rgba(255, 255, 255, 0.7);
}

th,
td {
  border-bottom: 1px solid #e6ddcf;
  border-right: 1px solid #eee6d8;
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th:last-child,
td:last-child {
  border-right: none;
}

thead th {
  position: sticky;
  top: 0;
  background: #f9f4ea;
  z-index: 2;
  white-space: nowrap;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.filter-menu {
  position: relative;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fffefb;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.filter-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 220px;
  padding: 12px;
  background: #fffdf8;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 30px rgba(74, 54, 31, 0.12);
  z-index: 5;
}

.filter-options {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
}

.filter-options label {
  display: flex;
  gap: 8px;
  align-items: center;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-width: 62px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  background: #f1eadb;
}

.status-chip.accept,
.decision-cell.accept {
  background: var(--accent-soft);
}

.status-chip.reject,
.decision-cell.reject {
  background: var(--danger-soft);
}

.status-chip.inconsistent,
.term-heading-cell.inconsistent {
  background: var(--warn-soft);
}

.muted {
  color: var(--muted);
}

.save-status {
  display: inline-block;
  min-width: 56px;
  font-size: 12px;
  color: var(--muted);
}

.comment-cell {
  white-space: pre-wrap;
  min-width: 180px;
}

.inline-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: #18493d;
  background: #e6f3ec;
  white-space: nowrap;
}

.link-button {
  margin-left: 8px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}

.danger-text {
  color: #9a2d21;
}

.link-button:disabled {
  cursor: default;
  opacity: 0.6;
  text-decoration: none;
}

.decision-cell {
  text-align: center;
  white-space: nowrap;
  width: 1%;
  min-width: 64px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(44, 36, 29, 0.38);
  z-index: 20;
}

.modal-card {
  width: min(640px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 20px;
  background: rgba(255, 253, 248, 0.98);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: 0 18px 40px rgba(74, 54, 31, 0.18);
}

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

.modal-header h2 {
  margin: 0;
  font-size: 22px;
}

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

.summary-table {
  min-width: 1680px;
}

.summary-table .term-heading-cell {
  min-width: 180px;
}

.summary-table .comment-cell {
  min-width: 120px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .shell {
    width: 96vw;
    max-width: 96vw;
    padding-top: 16px;
  }

  .page-header {
    flex-direction: column;
  }

  .stat-row {
    grid-template-columns: 110px 1fr 42px;
  }

  .panel {
    padding: 10px;
  }
}
