:root {
  --bg: #e8efe6;
  --bg-deep: #d4e0d1;
  --paper: #f7faf6;
  --ink: #1a2a22;
  --muted: #5a6e63;
  --line: #b8c9bc;
  --selection: #333333;
  --selection-width: 2px;
  --accent: #1f6b4a;
  --accent-soft: #d5ebe0;
  --danger: #9b2c2c;
  --header: #2a3d34;
  --header-ink: #eef6f1;
  --cell-bg: #ffffff;
  --cell-font-size: 0.92rem;
  --header-font-size: 0.9rem;
  --shadow: 0 12px 40px rgba(26, 42, 34, 0.12);
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "Manrope", system-ui, sans-serif;
  --done-bg: #c9d0cb;
  --done-ink: #5a6560;
  --check: #1f6b4a;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #cfe3d6 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #f0e6d4 0%, transparent 50%),
    var(--bg);
}

.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-panel {
  width: min(380px, 100%);
  background: var(--paper);
  padding: 28px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}
.login-brand {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
}
.field { display: grid; gap: 6px; font-size: 0.9rem; color: var(--muted); }
.field input {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}
.form-error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 0.9rem; }

.btn {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-ghost { background: transparent; }
.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
}
.btn-icon svg { display: block; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px 12px 16px;
  background: rgba(247, 250, 246, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
#project-filter {
  font: inherit;
  min-width: 220px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
  outline: none;
  box-shadow: none;
}
#project-filter:focus,
#project-filter:focus-visible,
#project-filter:active {
  outline: none;
  box-shadow: none;
  border-color: var(--line);
}
.topbar-spacer { flex: 1; min-width: 8px; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

#app-shell {
  width: 100%;
  min-width: 0;
}
.grid-wrap {
  overflow-x: hidden;
  overflow-y: auto;
  max-height: calc(100vh - 64px);
  width: 100%;
  box-sizing: border-box;
  padding: 0;
}

.sheet {
  table-layout: fixed;
  border-collapse: collapse;
  background: var(--cell-bg);
  box-shadow: none;
  border-radius: 0;
  width: 100%;
  max-width: 100%;
}
.col-project { width: 16%; }
.col-request { width: 33%; }
.col-result { width: 33%; }
.col-status { width: 10%; }
.col-done { width: 8%; }
.sheet th, .sheet td {
  border: 1px solid var(--line);
  vertical-align: top;
  padding: 0;
}

.col-head {
  position: relative;
  background: var(--header);
  color: var(--header-ink);
  font-weight: 600;
  font-size: var(--header-font-size);
  height: 36px;
}
.col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
}
.col-head-inner {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  min-height: 36px;
}
.col-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sheet td {
  background: var(--cell-bg);
  color: var(--ink);
  font-size: var(--cell-font-size);
  line-height: 1.4;
  padding: 6px 10px;
  vertical-align: top;
  overflow: hidden;
}
.cell-text {
  display: block;
  box-sizing: border-box;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.cell-project {
  font-weight: 700;
  overflow-wrap: anywhere;
  background: var(--cell-bg);
  color: var(--ink);
}
.cell-status {
  overflow-wrap: anywhere;
}
.cell-done {
  text-align: center;
}
.done-check {
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  vertical-align: top;
  accent-color: var(--check);
  cursor: pointer;
}

.row-done td:not(.cell-project) {
  background: var(--done-bg);
  color: var(--done-ink);
}
.row-done .cell-text {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 1.4em;
  transition: max-height 0.22s ease;
}
.row-done.is-open .cell-text {
  white-space: pre-wrap;
  overflow: visible;
  text-overflow: unset;
  max-height: 40em;
}
.row-done {
  cursor: pointer;
}

.empty-hint {
  margin: 24px 8px;
  color: var(--muted);
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(10, 18, 14, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
}
.settings-panel {
  width: min(440px, 100%);
  max-height: min(90vh, 720px);
  overflow: auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}
.settings-head h2 {
  margin: 0;
  font-size: 1.15rem;
}
.settings-head .btn-ghost {
  font-size: 1.5rem;
  line-height: 1;
  padding: 0 6px;
  border: none;
}
.settings-body {
  padding: 0 16px 12px;
  display: grid;
  gap: 18px;
}
.settings-section h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}
.settings-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.9rem;
}
.settings-row input[type="color"] {
  width: 42px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
.settings-row input[type="range"] {
  width: 120px;
}
.settings-row output {
  min-width: 2.5em;
  text-align: right;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}
.settings-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px 16px;
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  #project-filter { flex: 1; min-width: 0; }
  .cell { min-height: 56px; }
  .settings-row { grid-template-columns: 1fr auto; }
  .settings-row output { grid-column: 2; }
}
