:root {
  --ink: #101816;
  --ink-soft: #4d5c56;
  --line: rgba(16, 24, 22, 0.1);
  --paper: #edf2ef;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #fbfcfb;
  --accent: #0b7a5a;
  --accent-deep: #06563f;
  --accent-soft: #d8f0e6;
  --warn: #9a6700;
  --danger: #b42318;
  --shadow: 0 20px 60px rgba(16, 24, 22, 0.1);
  --radius: 22px;
  --font: "Pretendard Variable", Pretendard, "Noto Sans KR", sans-serif;
  --display: "Space Grotesk", "Instrument Sans", var(--font);
  --ui: "Instrument Sans", var(--font);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(900px 480px at 8% -8%, rgba(11, 122, 90, 0.16), transparent 55%),
    radial-gradient(700px 420px at 100% 0%, rgba(16, 60, 90, 0.1), transparent 50%),
    linear-gradient(165deg, #e8eee9 0%, #f4f7f5 42%, #e7eef2 100%);
  background-attachment: fixed;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); }
.stack { display: grid; gap: 12px; }

.boot {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--ink-soft);
}
.boot-mark, .brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #0b7a5a, #149e74);
  color: #fff;
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 24px rgba(11, 122, 90, 0.28);
}
.brand-mark { width: 40px; height: 40px; font-size: 0.78rem; }

.app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 14px 14px;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 10px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand strong {
  display: block;
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: -0.04em;
  line-height: 1.1;
}
.brand em {
  display: block;
  margin-top: 2px;
  font-style: normal;
  font-size: 0.86rem;
  color: var(--ink-soft);
}
.top-actions { display: flex; gap: 8px; }

.btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.75);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-family: var(--ui);
  font-weight: 600;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(16,24,22,0.22); }
.btn-primary,
.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-dark {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.btn-ghost { background: transparent; }
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-block { width: 100%; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.86rem; }
.linkish {
  border: 0;
  background: none;
  color: var(--accent-deep);
  font-weight: 600;
  padding: 0;
}

.flash {
  padding: 12px 14px;
  border-radius: 14px;
  background: #e8f3ff;
  color: #184a7a;
  font-weight: 500;
}
.flash.error { background: #fdecec; color: var(--danger); }

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 420px) 1fr;
  gap: 12px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.compose, .board, .access-card, .detail {
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255,255,255,0.7);
  box-shadow: var(--shadow);
}

.compose {
  border-radius: 22px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.compose-head, .board-head {
  padding: 14px 14px 0;
}
.compose-head h1, .board-head h2, .access-card h1 {
  margin: 0;
  font-family: var(--display);
  letter-spacing: -0.04em;
}
.compose-head h1 { font-size: 1.2rem; }
.compose-head p, .board-head .muted {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
}
.compose-body {
  padding: 10px 14px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.compose-body.dense { gap: 8px; }
.compose-foot {
  display: grid;
  gap: 8px;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,0.45);
  min-width: 0;
}
.compose-actions {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 6px;
  min-width: 0;
}
.compose-actions .btn-accent { justify-self: stretch; }

label {
  display: grid;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-soft);
  font-family: var(--ui);
  min-width: 0;
}
input, select, textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0.48rem 0.62rem;
  background: rgba(255,255,255,0.9);
  font-size: 0.88rem;
}
textarea {
  resize: none;
  min-height: 0;
  height: 52px;
}
input[type="date"],
input[type="datetime-local"],
input[type="number"] {
  min-width: 0;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(11, 122, 90, 0.25);
  border-color: rgba(11, 122, 90, 0.45);
}

.duo,
.triple {
  display: grid;
  gap: 6px;
  min-width: 0;
}
.duo { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.triple { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-block { display: grid; gap: 6px; min-width: 0; }
.field-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink-soft);
  font-family: var(--ui);
}
.company-inline {
  display: grid;
  gap: 6px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(11, 122, 90, 0.06);
  border: 1px dashed rgba(11, 122, 90, 0.25);
}

.issue-box {
  border-radius: 12px;
  padding: 8px 10px;
  background: #10231c;
  color: #e8fff4;
  font-size: 0.8rem;
  line-height: 1.35;
  max-height: 88px;
  overflow: auto;
}
.issue-box.muted { opacity: 0.85; max-height: none; }
.issue-box code {
  display: inline-block;
  margin-top: 2px;
  padding: 0.12rem 0.35rem;
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  letter-spacing: 0.1em;
  font-size: 0.92rem;
}
.issue-box a { color: #9dffd3; text-decoration: underline; }

.board {
  border-radius: 22px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}
.board-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 10px;
}
.board-head h2 { font-size: 1.15rem; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.65);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.84rem;
  font-family: var(--ui);
  font-weight: 600;
  color: var(--ink-soft);
}
.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.board-split {
  display: grid;
  grid-template-columns: minmax(240px, 0.95fr) 1.05fr;
  gap: 0;
  min-height: 0;
  border-top: 1px solid var(--line);
}
.list {
  overflow: auto;
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,0.35);
}
.contract-item {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  padding: 14px 16px;
  display: grid;
  gap: 6px;
  transition: background .15s ease;
}
.contract-item:hover { background: rgba(11, 122, 90, 0.05); }
.contract-item.active {
  background: linear-gradient(90deg, rgba(11,122,90,0.12), rgba(11,122,90,0.03));
  box-shadow: inset 3px 0 0 var(--accent);
}
.contract-item .title {
  font-family: var(--ui);
  font-weight: 650;
  font-size: 0.98rem;
  letter-spacing: -0.02em;
}
.contract-item .meta {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--ink-soft);
  font-size: 0.82rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.12rem 0.5rem;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.badge.warn { background: #fff3d6; color: var(--warn); }
.badge.danger { background: #fdecec; color: var(--danger); }
.badge.done { background: #e7eef8; color: #1d4f91; }

.detail {
  box-shadow: none;
  border: 0;
  border-radius: 0;
  background: var(--panel-solid);
  overflow: auto;
  padding: 18px;
}
.detail-empty {
  min-height: 240px;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 6px;
  color: var(--ink-soft);
}
.detail-empty strong {
  font-family: var(--display);
  color: var(--ink);
  font-size: 1.15rem;
}
.detail-body { display: grid; gap: 14px; }
.detail-body h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.3rem;
  letter-spacing: -0.03em;
}
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.party-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.party-list li {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(16,24,22,0.04);
  font-size: 0.92rem;
}

.preview-dock {
  width: 100%;
  height: 280px;
  border: 0;
  border-top: 1px solid var(--line);
  background: #fff;
}

.access-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.access-card {
  width: min(440px, 100%);
  border-radius: 28px;
  padding: 28px 24px;
  display: grid;
  gap: 14px;
}
.access-card h1 {
  font-size: 2rem;
  line-height: 1.05;
}
.code-input {
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-size: 1.28rem;
  text-align: center;
  font-family: var(--display);
}

@media (max-width: 1100px) {
  .app { height: auto; overflow: auto; }
  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .compose-body { overflow: visible; }
  .board-split { grid-template-columns: 1fr; }
  .list {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 280px;
  }
}
