: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;
  user-select: none;
  caret-color: transparent;
}

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

button {
  cursor: pointer;
}

.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;
  user-select: text;
  caret-color: auto;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(71, 101, 130, 0.12);
}

.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);
}

.danger-icon-button {
  color: #9b423a;
  background: #f8eeec;
  border-color: #ead7d3;
}

.danger-icon-button:hover {
  background: #f2dfdc;
  box-shadow: 0 6px 14px rgba(155, 66, 58, 0.12);
}

.danger-icon-button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.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: 8px;
  display: grid;
  gap: 8px;
}

.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: 9px 10px;
  display: grid;
  gap: 7px;
  transition: transform 160ms ease, box-shadow 160ms ease;
  user-select: none;
}

.task-card .chip {
  min-height: 23px;
  padding: 0 8px;
  font-size: 11px;
}

.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: 14px;
  line-height: 1.25;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

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

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

.task-footer > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.status-action {
  color: #637182;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.status-action:hover {
  transform: translateY(-1px);
}

.status-action svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card-actions .status-action-done {
  color: #47705a;
  background: #edf6f0;
  border-color: #d4e7da;
}

.card-actions .status-action-rework,
.card-actions .status-action-return {
  color: #8a6a27;
  background: #f8f2df;
  border-color: #eadfb9;
}

.card-actions .status-action-paused {
  color: #476582;
  background: #edf3f8;
  border-color: #d7e2ec;
}

.card-actions .status-action-start,
.card-actions .status-action-review {
  color: #5f6b78;
  background: #f5f7f8;
  border-color: #dce2e7;
}

.progress-bar {
  height: 5px;
  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(4, minmax(240px, 1fr));
  align-items: start;
  gap: 14px;
}

.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: 8px;
  transition: background 160ms ease, border-color 160ms ease;
}

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

.user-row {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "main action"
    "role action";
  align-items: center;
  gap: 7px 10px;
  background: #fff;
  transition: background 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

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

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

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

.user-row.inactive {
  opacity: 0.62;
}

.user-row > .chip {
  grid-area: role;
  justify-self: start;
  max-width: 100%;
}

.toggle-user-button {
  grid-area: action;
  justify-self: end;
  white-space: nowrap;
}

.modal,
.drawer {
  border: 0;
  padding: 0;
  overflow: hidden;
  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));
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
}

.drawer {
  width: min(460px, calc(100vw - 16px));
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  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;
  align-content: start;
  gap: 12px;
  padding: 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.modal-body {
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
}

.drawer-body {
  height: 100%;
  max-height: 100vh;
  max-height: 100dvh;
  gap: 10px;
  padding: 14px;
}

.drawer .modal-head h2 {
  font-size: 20px;
  line-height: 1.2;
}

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

.drawer .detail-title {
  margin: 6px 0 2px;
  font-size: 20px;
  line-height: 1.22;
}

.drawer h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}

.drawer section {
  display: grid;
  gap: 7px;
}

.drawer input,
.drawer select,
.drawer textarea {
  min-height: 36px;
  padding: 6px 9px;
  font-size: 14px;
}

.drawer .inline-form .ghost-button,
.drawer .inline-form .primary-button,
.drawer .inline-form .danger-button {
  min-height: 36px;
  font-size: 14px;
}

.drawer .description-box,
.drawer .comment-card,
.drawer .check-item {
  padding: 8px 9px;
  font-size: 14px;
}

.drawer .check-item {
  min-height: 34px;
}

.drawer .field span,
.drawer .muted {
  font-size: 12px;
}

.drawer .comments {
  max-height: clamp(150px, 30dvh, 260px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #eef1f3;
  scrollbar-gutter: stable;
}

.drawer .comment-card {
  gap: 5px;
  border-color: #dde3e8;
  background: #fff;
  box-shadow: 0 1px 0 rgba(31, 41, 51, 0.03);
}

.drawer .comment-card p {
  line-height: 1.35;
}

.drawer .comment-head time {
  font-size: 11px;
}

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

.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;
}

.permission-check small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.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,
.comment-card,
.idea-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
}

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

.comment-card p {
  margin: 0;
  line-height: 1.45;
}

.comment-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.comment-head time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.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;
}

@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;
  }

  .user-row {
    grid-template-columns: 1fr;
    grid-template-areas:
      "main"
      "role"
      "action";
  }

  .toggle-user-button {
    justify-self: stretch;
  }
}
