:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #d9dee7;
  --brand: #2563eb;
  --brand-dark: #1749b7;
  --danger: #b42318;
  --shadow: 0 12px 32px rgba(20, 31, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1060px;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", Arial, sans-serif;
}

.hidden {
  display: none !important;
}

.loginView {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.loginPanel {
  width: 390px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.loginPanel h1 {
  margin-bottom: 6px;
}

.loginPanel p {
  color: var(--muted);
  margin-bottom: 18px;
}

.loginHint {
  margin-top: 12px;
}

.errorText {
  min-height: 20px;
  margin-top: 10px;
  color: var(--danger);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
  font-weight: 700;
}

h3 {
  font-size: 14px;
  font-weight: 700;
}

.topbar p {
  color: var(--muted);
  margin-top: 3px;
}

.viewTabs {
  display: inline-flex;
  gap: 4px;
  margin-top: 10px;
  padding: 3px;
  background: #eef2f7;
  border-radius: 8px;
}

.viewTab {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  padding: 6px 10px;
}

.viewTab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(20, 31, 51, 0.10);
}

.topActions,
.panelHeader,
.memberForm,
.cardMeta,
.cardFooter,
.stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.userBadge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 10px;
  background: #eef2f7;
  border-radius: 7px;
  font-weight: 600;
}

.actor {
  display: flex;
  align-items: center;
  gap: 8px;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(560px, 1fr) 300px;
  gap: 14px;
  padding: 14px;
}

.leftPane,
.rightPane {
  display: grid;
  gap: 14px;
  align-content: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.panelHeader {
  justify-content: space-between;
  margin-bottom: 12px;
}

label {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
}

label span {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 8px 9px;
  outline: none;
}

textarea {
  resize: vertical;
}

.richTextBox {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.richTextBox:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.richTextToolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.richFormatButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.richFormatButton:hover {
  border-color: var(--brand);
  background: #eef3ff;
}

.richBoldButton {
  font-size: 15px;
}

.richColorButton::before {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--format-color);
  content: "";
}

.richClearButton {
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.richToolbarLabel {
  color: var(--muted);
  font-size: 12px;
}

.richTextInput {
  min-height: 98px;
  padding: 8px 9px;
  outline: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.richTextInput:empty::before {
  color: #9ca3af;
  content: attr(data-placeholder);
  pointer-events: none;
}

.richTextReadonly .richTextInput {
  min-height: 0;
  background: #f8fafc;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.button,
.iconButton,
.linkButton {
  border: 0;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.button:hover {
  background: var(--brand-dark);
}

.button.ghost {
  background: #eef3ff;
  color: var(--brand-dark);
}

.button.ghost.active {
  background: #dbeafe;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.35);
}

.button.small {
  min-height: 30px;
  padding: 6px 10px;
}

.dangerButton {
  background: var(--danger);
}

.dangerButton:hover {
  background: #8f1b13;
}

.dangerButton:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.linkButton {
  background: transparent;
  color: var(--brand);
  padding: 4px;
}

.linkButton.danger {
  color: var(--danger);
}

.iconButton {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: #eef2f7;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.stats {
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.archiveToolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
}

.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 108px;
}

.stat strong {
  display: block;
  font-size: 18px;
}

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

.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  align-items: start;
}

.column {
  background: #e9edf3;
  border: 1px solid #d3d9e3;
  border-radius: 8px;
  min-height: 180px;
  overflow: hidden;
}

.columnHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 10px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.columnTitle {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.columnTitle h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.columnHandle {
  cursor: grab;
  user-select: none;
}

.columnHandle:active {
  cursor: grabbing;
}

.dragHandle {
  color: var(--muted);
  font-size: 16px;
  letter-spacing: 0;
  line-height: 1;
}

.column.dragging {
  opacity: 0.58;
}

.column.dragOver {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.column.taskDropTarget {
  outline: 2px dashed #16a34a;
  outline-offset: 2px;
}

.columnBody {
  display: grid;
  gap: 8px;
  padding: 8px;
}

.taskCard {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
}

.taskCard:hover {
  border-color: #aab7cc;
  box-shadow: 0 8px 18px rgba(20, 31, 51, 0.10);
}

.taskCard[draggable="true"] {
  cursor: grab;
}

.taskCard[draggable="true"]:active {
  cursor: grabbing;
}

.taskCard.dragging {
  opacity: 0.55;
}

.taskCard h3 {
  margin-bottom: 8px;
  word-break: break-word;
}

.cardMeta,
.cardFooter {
  flex-wrap: wrap;
}

.quickActions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.miniAction {
  border: 1px solid #bdd0ff;
  background: #eef3ff;
  color: var(--brand-dark);
  border-radius: 6px;
  padding: 4px 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.miniAction.done {
  border-color: #b7e4c7;
  background: #e8f8ef;
  color: #166534;
}

.miniAction.blocked {
  border-color: #fecaca;
  background: #fff1f2;
  color: #b42318;
}

.miniAction.archive {
  border-color: #d1d5db;
  background: #f3f4f6;
  color: #374151;
}

.miniAction.restore {
  border-color: #bbf7d0;
  background: #ecfdf3;
  color: #15803d;
}

.chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: 999px;
  padding: 3px 7px;
  background: #eef2f7;
  color: #3d4756;
  font-size: 12px;
  white-space: nowrap;
}

.chip.critical {
  background: #ffe8e5;
  color: #9f1c12;
}

.chip.high {
  background: #fff0cf;
  color: #8a5b00;
}

.chip.done {
  background: #ddf7e8;
  color: #166534;
}

.assigneeDot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 5px;
}

.empty {
  color: var(--muted);
  padding: 10px;
  text-align: center;
}

.memberList,
.activityFeed {
  display: grid;
  gap: 8px;
}

#activityPanel.collapsed #activityFeed {
  display: none;
}

#activityPanel.collapsed .panelHeader {
  margin-bottom: 8px;
}

.panelTools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.activityToolbar {
  display: flex;
  margin: -4px 0 10px;
}

.activityToggleButton {
  width: 100%;
  min-width: 0;
  white-space: nowrap;
}

.memberRow,
.activityItem {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: #fff;
}

.memberRow {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 8px;
  align-items: center;
}

.memberActions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.memberColor {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.activityItem time,
.muted {
  color: var(--muted);
  font-size: 12px;
}

dialog {
  width: min(900px, 92vw);
  border: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.28);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.35);
}

.dialogShell {
  padding: 0;
}

.dialogHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.memberDialog {
  width: min(540px, 92vw);
}

.memberEditor {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.memberEditor label {
  margin: 0;
}

.memberEditor .errorText {
  min-height: 0;
  margin: 0;
}

.memberEditorActions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.memberEditorActions .button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.taskEditor {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.editorGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.comments {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #f8fafc;
}

.comment {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
}

.attachments {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #f8fafc;
}

.attachment {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
}

.attachment a {
  color: var(--brand-dark);
  font-weight: 600;
  text-decoration: none;
  word-break: break-word;
}

.uploadRow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.metaLine {
  color: var(--muted);
}

.inlineCheck {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.inlineCheck input {
  width: auto;
}

.memberForm {
  flex-wrap: wrap;
  align-items: flex-end;
}

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

.statusRow {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto auto;
  gap: 6px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: #fff;
}

.statusForm {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.statusForm input {
  flex: 1;
}

.memberForm input[type="text"],
.memberForm input[type="password"],
.memberForm input:not([type]) {
  min-width: 120px;
  flex: 1 1 120px;
}

.memberForm input[type="color"] {
  width: 42px;
  min-width: 42px;
  padding: 2px;
}

@media (max-width: 1300px) {
  .layout {
    grid-template-columns: 300px 1fr;
  }

  .rightPane {
    grid-column: 1 / -1;
  }

  .board {
    grid-template-columns: repeat(3, minmax(190px, 1fr));
  }
}
