:root {
  --bg: #f4f6f7;
  --surface: #ffffff;
  --soft: #eef1f3;
  --line: #d9dee3;
  --text: #1f2933;
  --muted: #6b7480;
  --brand: #476582;
  --green: #47705a;
  --shadow: 0 18px 44px rgba(31, 41, 51, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  cursor: default;
}

* {
  caret-color: transparent;
}

input[type="text"],
input[type="password"],
input[type="search"],
input[type="email"],
input[type="number"],
input[type="url"],
input[type="tel"],
input:not([type]),
textarea {
  cursor: text;
  caret-color: auto;
}

input[type="checkbox"],
input[type="radio"],
input[type="color"],
input[type="file"] {
  cursor: pointer;
}

.check-item,
.permission-check {
  cursor: pointer;
}

form,
label,
fieldset,
legend,
.modal-head,
.modal-actions,
.modal-body,
.drawer-body,
.section-head,
.page-header,
.header-actions,
.danger-zone,
.permission-grid,
.permission-group,
.code-box,
.field span {
  cursor: default;
}

select {
  cursor: pointer;
}

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

button {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  caret-color: transparent;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card,
.panel,
.page-header,
.summary-card,
.column,
.task-card,
.modal,
.drawer {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(31, 41, 51, 0.02);
}

.login-card {
  width: min(380px, 100%);
  display: grid;
  gap: 16px;
  padding: 26px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 2px;
  font-size: 26px;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--surface);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand h1,
.page-header h2,
.modal-head h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.user-card {
  display: grid;
  gap: 3px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--soft);
}

.clickable-card,
.clickable-row {
  cursor: pointer;
}

.clickable-card:hover,
.clickable-row:hover {
  border-color: #c5ccd3;
  background: #f8fafb;
}

.user-card span,
.table-row span {
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 0 12px;
  font-weight: 800;
}

.nav-button.active {
  background: var(--soft);
}

.logout-button {
  margin-top: auto;
}

.main {
  min-width: 0;
  padding: 18px;
}

.page-header {
  padding: 16px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.header-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.compact-field {
  min-width: 220px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 11px;
  outline: none;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
input:not([type]):focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(71, 101, 130, 0.12);
}

input[type="checkbox"]:focus,
input[type="radio"]:focus,
input[type="color"]:focus {
  outline: none;
  box-shadow: none;
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.primary-button,
.ghost-button,
.danger-button,
.segment-button,
.icon-button {
  min-height: 42px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 800;
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

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

.ghost-button,
.segment-button {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
}

.danger-button {
  color: #8b514b;
  background: #f8eeec;
  border-color: #ead7d3;
}

.small {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  background: var(--soft);
  color: var(--muted);
}

.segmented {
  display: flex;
  padding: 4px;
  border-radius: var(--radius);
  background: var(--soft);
}

.segment-button {
  min-height: 34px;
  border-color: transparent;
  background: transparent;
}

.segment-button.active {
  background: var(--surface);
  border-color: var(--line);
}

.summary-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.summary-card {
  min-height: 78px;
  padding: 13px;
  display: grid;
  align-content: center;
  gap: 5px;
}

.summary-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.summary-card strong {
  font-size: 25px;
}

.board {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(5, minmax(230px, 1fr));
  gap: 12px;
}

.column {
  min-height: 430px;
  overflow: hidden;
  background: var(--soft);
  transition: border-color 160ms ease, background 160ms ease;
}

.column.drop-ready {
  border-color: var(--brand);
  background: #e8eef3;
}

.column-head {
  min-height: 56px;
  padding: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
}

.column-head h3 {
  margin: 0;
  font-size: 16px;
}

.column-head span,
.chip {
  min-height: 27px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.column-list {
  padding: 10px;
  display: grid;
  gap: 10px;
}

.column-list.drag-target-list .empty-state {
  display: none;
}

.empty-state {
  min-height: 84px;
  border: 1px dashed #c6cdd5;
  border-radius: var(--radius);
  color: var(--muted);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 12px;
  font-weight: 700;
}

.task-card {
  padding: 12px;
  display: grid;
  gap: 10px;
  transition: transform 160ms ease, box-shadow 160ms ease;
  user-select: none;
}

.task-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.task-card[data-can-drag="true"] {
  touch-action: none;
}

.task-card.pressing-card,
.task-card.pressing-card:hover {
  transform: none;
  border-color: var(--brand);
  background: #fbfcfd;
  box-shadow: 0 4px 10px rgba(31, 41, 51, 0.08), inset 0 0 0 2px rgba(71, 101, 130, 0.12);
}

.task-card.dragging-card,
.task-card.dragging-card:hover {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  transform: rotate(2deg);
  border-color: var(--brand);
  box-shadow: 0 18px 36px rgba(31, 41, 51, 0.16);
  animation: detach-card 140ms ease-out;
}

.task-card.saved-flash {
  animation: saved-flash 720ms ease-out;
}

.drag-placeholder {
  border: 2px dashed #b9c3cd;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.48);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

@keyframes detach-card {
  from {
    box-shadow: 0 4px 10px rgba(31, 41, 51, 0.08), inset 0 0 0 2px rgba(71, 101, 130, 0.12);
    transform: none;
  }

  to {
    box-shadow: 0 18px 36px rgba(31, 41, 51, 0.16);
    transform: rotate(2deg);
  }
}

@keyframes saved-flash {
  0% {
    border-color: var(--green);
    box-shadow: 0 0 0 0 rgba(71, 112, 90, 0.26), var(--shadow);
    background: #f2faf5;
  }

  45% {
    border-color: var(--green);
    box-shadow: 0 0 0 6px rgba(71, 112, 90, 0.1), var(--shadow);
    background: #f7fcf9;
  }

  100% {
    border-color: var(--line);
    box-shadow: 0 8px 20px rgba(31, 41, 51, 0.06);
    background: var(--surface);
  }
}

.task-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.task-meta,
.task-footer,
.card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.task-footer {
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.card-actions button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0 9px;
  font-weight: 800;
}

.progress-bar {
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: #dfe4e8;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: var(--green);
}

.admin-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.color-field input[type="color"] {
  min-height: 42px;
  padding: 4px;
  cursor: pointer;
  background: var(--surface);
}

.color-field {
  max-width: 96px;
}

.chip {
  border: 1px solid var(--line);
}

.panel {
  padding: 14px;
}

.section-head {
  min-height: 42px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.section-head h3 {
  margin: 0;
}

.table-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.table-row {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  transition: background 160ms ease, border-color 160ms ease;
}

.table-row > div {
  min-width: 0;
  overflow: hidden;
}

.table-row strong,
.table-row span {
  display: block;
}

.table-row > div strong,
.table-row > div span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-row .chip {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clickable-card,
.clickable-row,
.chip,
.user-row,
.user-row-main {
  user-select: none;
  -webkit-user-select: none;
}

.user-row {
  position: relative;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 6px 12px;
  transition: background 160ms ease, border-color 160ms ease;
  overflow: hidden;
}

.user-row-main {
  min-width: 0;
  grid-row: 1 / span 2;
  display: grid;
  gap: 2px;
}

.user-row-main strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row-main span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row > .chip {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  max-width: 150px;
}

.user-row .toggle-user-button {
  grid-column: 2;
  grid-row: 2;
  justify-self: end;
  min-height: 30px;
  padding: 0 11px;
  font-size: 12px;
}

.user-row.inactive {
  background:
    repeating-linear-gradient(
      135deg,
      transparent 0,
      transparent 10px,
      rgba(31, 41, 51, 0.06) 10px,
      rgba(31, 41, 51, 0.06) 11px
    ),
    var(--surface);
  border-color: #d2d6db;
}

.user-row.inactive .user-row-main strong {
  color: var(--muted);
  text-decoration: line-through;
}

.user-row.inactive .chip {
  opacity: 0.6;
}

.checklist-builder {
  display: grid;
  gap: 6px;
  margin-bottom: 6px;
}

.checklist-builder:empty {
  display: none;
}

.checklist-draft-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  font-size: 14px;
}

.checklist-draft-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.checklist-draft-item .icon-button {
  width: 28px;
  min-height: 28px;
  font-size: 16px;
}

.checklist-add {
  display: flex;
  gap: 8px;
}

.checklist-add input {
  flex: 1;
}

.modal,
.drawer {
  border: 0;
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  transition: opacity 160ms ease, transform 160ms ease;
  box-shadow: var(--shadow);
}

.modal {
  width: min(560px, calc(100vw - 28px));
}

.drawer {
  width: min(500px, calc(100vw - 24px));
  height: 100vh;
  max-height: 100vh;
  margin: 0 0 0 auto;
  border-radius: 0;
  transform: translateX(18px);
}

.modal::backdrop,
.drawer::backdrop {
  background: rgba(31, 41, 51, 0);
  transition: background 160ms ease;
}

.modal.visible,
.drawer.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.drawer.visible {
  transform: translateX(0);
}

.modal.visible::backdrop,
.drawer.visible::backdrop {
  background: rgba(31, 41, 51, 0.22);
}

.modal-body,
.drawer-body {
  display: grid;
  gap: 13px;
  padding: 6px;
}

.drawer-body {
  padding: 20px;
}

.modal-head,
.modal-actions,
.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-head {
  justify-content: space-between;
}

.modal-actions {
  justify-content: flex-end;
}

.inline-form {
  align-items: stretch;
}

.inline-form input {
  flex: 1;
}

.danger-zone {
  margin-top: 6px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
}

.permission-grid {
  display: grid;
  gap: 10px;
}

.permission-group {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  display: grid;
  gap: 8px;
}

.permission-group legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.permission-check {
  min-height: 32px;
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.permission-check input {
  width: 18px;
  min-height: 18px;
}

.code-box {
  border: 1px solid #d7e2da;
  border-radius: var(--radius);
  background: #f4faf6;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.code-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.code-box strong {
  font-size: 18px;
  word-break: break-word;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.description-box,
.comments p,
.idea-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
}

.detail-title {
  margin: 8px 0 4px;
}

.checklist,
.comments,
.idea-list {
  display: grid;
  gap: 8px;
}

.check-item {
  min-height: 38px;
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
}

.check-item input {
  width: 18px;
  min-height: 18px;
}

.check-item.done span {
  color: var(--muted);
  text-decoration: line-through;
}

.idea-card {
  display: grid;
  gap: 7px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: #9b3d35;
  font-weight: 700;
}

.drawer-body {
  padding: 14px 16px;
  gap: 10px;
}

.drawer-body .field span {
  font-size: 11px;
}

.drawer-body input,
.drawer-body select,
.drawer-body textarea {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}

.drawer-body textarea {
  min-height: 72px;
}

.drawer-body .primary-button,
.drawer-body .ghost-button,
.drawer-body .danger-button,
.drawer-body .icon-button {
  min-height: 34px;
  padding: 0 11px;
  font-size: 13px;
}

.drawer-body .icon-button {
  width: 32px;
  min-height: 32px;
  padding: 0;
}

.drawer-body .modal-head h2 {
  font-size: 18px;
}

.drawer-body .code-box {
  padding: 9px 10px;
  gap: 4px;
}

.drawer-body .code-box span {
  font-size: 11px;
}

.drawer-body .code-box strong {
  font-size: 15px;
}

.drawer-body .code-box .ghost-button {
  min-height: 30px;
  font-size: 12px;
  padding: 0 9px;
  justify-self: start;
}

.drawer-body .permission-grid {
  gap: 7px;
}

.drawer-body .permission-group {
  padding: 8px;
  gap: 5px;
}

.drawer-body .permission-group legend {
  font-size: 11px;
}

.drawer-body .permission-check {
  min-height: 26px;
  font-size: 13px;
}

.drawer-body .check-item {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 13px;
}

.drawer-body .danger-zone {
  padding-top: 9px;
}

.drawer-body h2.detail-title {
  font-size: 18px;
  margin: 6px 0 3px;
  line-height: 1.25;
}

.drawer-body section {
  display: grid;
  gap: 6px;
}

.drawer-body section h3 {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.drawer-body .description-box {
  padding: 8px 10px;
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
}

.drawer-body .checklist,
.drawer-body .comments {
  gap: 6px;
}

.drawer-body .comments p {
  padding: 8px 10px;
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.drawer-body .empty-state {
  min-height: 44px;
  padding: 8px 10px;
  font-size: 12px;
}

.drawer-body .chip {
  min-height: 22px;
  font-size: 11px;
  padding: 0 8px;
}

.drawer-body .muted {
  font-size: 12px;
}

.drawer-body .inline-form input {
  min-height: 32px;
}

.drawer-body .inline-form .ghost-button {
  min-height: 32px;
}

.primary-button:hover {
  background: #3b566f;
}

.primary-button:active {
  background: #2f475e;
  transform: translateY(1px);
}

.ghost-button:hover,
.segment-button:hover {
  background: var(--soft);
  border-color: #c5ccd3;
}

.ghost-button:active,
.segment-button:active {
  background: #e2e7eb;
  transform: translateY(1px);
}

.segment-button.active {
  box-shadow: 0 1px 2px rgba(31, 41, 51, 0.08);
}

.danger-button:hover {
  background: #f1ddd9;
  border-color: #ddc1bc;
}

.danger-button:active {
  background: #e8cec8;
  transform: translateY(1px);
}

.icon-button:hover {
  background: #dde2e6;
  color: var(--text);
}

.icon-button:active {
  background: #cdd3d8;
  transform: translateY(1px);
}

.nav-button:hover {
  background: var(--soft);
}

.nav-button.active:hover {
  background: #e3e8eb;
}

.nav-button:active {
  transform: translateY(1px);
}

.card-actions button:hover {
  background: #f4f6f7;
  border-color: #c5ccd3;
}

.card-actions button:active {
  background: #e8ecef;
  transform: translateY(1px);
}

button:disabled,
button:disabled:hover,
button:disabled:active {
  opacity: 0.5;
  cursor: not-allowed;
  background: var(--soft);
  border-color: var(--line);
  color: var(--muted);
  transform: none;
}

button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

@keyframes button-saved {
  0% {
    background: var(--brand);
    box-shadow: 0 0 0 0 rgba(71, 112, 90, 0);
  }
  25% {
    background: var(--green);
    box-shadow: 0 0 0 5px rgba(71, 112, 90, 0.22);
  }
  70% {
    background: var(--green);
    box-shadow: 0 0 0 8px rgba(71, 112, 90, 0);
  }
  100% {
    background: var(--brand);
    box-shadow: none;
  }
}

.primary-button.saved-flash,
.primary-button.saved-flash:hover,
.primary-button.saved-flash:active {
  animation: button-saved 900ms ease-out;
  background: var(--brand);
  transform: none;
}

@media (max-width: 1180px) {
  .board {
    display: flex;
    overflow-x: auto;
    padding-bottom: 8px;
  }

  .column {
    min-width: 270px;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .page-header,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }
}
