:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --border: #d0d5dd;
  --text: #1a1d23;
  --muted: #667085;
  --accent: #0b6e4f;
  --accent-hover: #095c42;
  --danger: #c0392b;
  --warn: #b7791f;
  --ok: #0b6e4f;
  --sheet-header: #e8eef2;
  --focus: #0b6e4f;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
  font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

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

.hidden { display: none !important; }

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(11, 110, 79, 0.12), transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(11, 110, 79, 0.08), transparent 45%),
    var(--bg);
}

.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.login-card p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-card label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--muted);
}

.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 16px;
}

.login-card input:focus {
  outline: 2px solid color-mix(in srgb, var(--focus) 35%, white);
  border-color: var(--focus);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
}

.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-ghost {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover { background: #f7f8fa; }

.btn-danger {
  background: #fff;
  color: var(--danger);
  border-color: #f0c2bd;
}

.btn-danger:hover { background: #fdf2f1; }

.btn-block { width: 100%; }

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin: -8px 0 12px;
  min-height: 1.2em;
}

/* Admin shell */
.admin-shell {
  max-width: 100%;
  padding: 16px 20px 40px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

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

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--sheet-header);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.95rem;
}

.panel-header-list {
  flex-wrap: wrap;
}

.panel-header-left {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
}

.panel-hint {
  font-weight: 400;
  font-size: 0.82rem;
  color: var(--muted);
}

.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.bulk-count {
  font-weight: 500;
  font-size: 0.82rem;
  color: var(--muted);
  margin-right: 4px;
}

.bulk-actions .btn:disabled {
  opacity: 0.45;
}

.panel-body { padding: 14px 16px; }

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

.field label {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.field input, .field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.field input:focus, .field select:focus, .sheet input:focus, .sheet select:focus {
  outline: 2px solid color-mix(in srgb, var(--focus) 30%, white);
  border-color: var(--focus);
}

.sheet-wrap {
  overflow: auto;
  max-height: calc(100vh - 280px);
}

.sheet {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
}

.sheet th, .sheet td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0;
  vertical-align: middle;
  white-space: nowrap;
}

.sheet th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--sheet-header);
  font-weight: 600;
  padding: 8px 10px;
  text-align: left;
  color: #344054;
}

.sheet th.col-check,
.sheet td.col-check {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 40px;
  min-width: 40px;
  text-align: center;
  padding: 6px 8px !important;
  background: var(--sheet-header);
}

.sheet td.col-check {
  background: #fafbfc;
  z-index: 1;
}

.sheet th.col-check { z-index: 4; }

.sheet td.col-id {
  padding: 6px 10px;
  font-variant-numeric: tabular-nums;
  background: #fafbfc;
}

.sheet .col-check input {
  min-width: 0;
  width: auto;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.sheet input, .sheet select {
  width: 100%;
  min-width: 110px;
  border: none;
  padding: 7px 8px;
  background: transparent;
  border-radius: 0;
}

.sheet input:disabled, .sheet select:disabled {
  color: var(--muted);
  background: #f5f6f8;
}

.sheet .col-narrow input { min-width: 70px; width: 80px; }
.sheet .col-mid input, .sheet .col-mid select { min-width: 100px; }
.sheet .col-wide input { min-width: 140px; }

.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-draft { background: #eef2f6; color: #475467; }
.status-signed { background: #e6f4ef; color: var(--ok); }
.status-edited { background: #fff3d6; color: #8a5a00; }

.row-actions {
  display: flex;
  gap: 4px;
  padding: 4px 8px;
}

.row-actions .btn {
  padding: 5px 8px;
  font-size: 0.75rem;
  font-weight: 500;
}

.link-cell {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
  font-size: 0.75rem;
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #1a1d23;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.2s ease;
  pointer-events: none;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.export-host {
  position: absolute;
  left: -10000px;
  top: 0;
  width: 820px;
  pointer-events: none;
}

.export-host .doc-page {
  margin: 0;
  box-shadow: none;
  width: 820px;
}

@media (max-width: 720px) {
  .admin-shell { padding: 12px; }
  .sheet-wrap { max-height: none; }
}
