:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-soft: #eef2f9;
  --panel-hover: #e7ecf5;
  --line: #dbe3f0;
  --text: #162031;
  --muted: #607089;
  --accent: #7c5cbf;
  --accent-soft: #ede9f8;
  --success: #1f9d62;
  --danger: #d64545;
  --warning: #dc7a00;
  --shadow: 0 14px 32px rgba(18, 31, 53, 0.08);
  --shadow-soft: 0 6px 18px rgba(18, 31, 53, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --board-width: 312px;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { line-height: 1.45; }

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: grid; grid-template-columns: auto auto auto 1fr;
  gap: 16px; align-items: center;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(219, 227, 240, 0.95);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #9f8ae0);
  color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: var(--shadow-soft);
  flex-shrink: 0;
}
.brand-title { font-size: 15px; font-weight: 800; }
.brand-subtitle { font-size: 12px; color: var(--muted); }

.toolbar, .status-bar, .topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search-wrap {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel);
}
.search-wrap span { font-size: 12px; color: var(--muted); font-weight: 700; }
.search-wrap input {
  border: 0; outline: 0; background: transparent; min-width: 220px; color: var(--text);
}

.btn, .icon-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  transition: 0.15s ease;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 14px;
  font-size: 13px; font-weight: 700;
  box-shadow: var(--shadow-soft);
}
.btn:hover, .icon-btn:hover { background: var(--panel-hover); transform: translateY(-1px); }
.btn:active, .icon-btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #694ba9; }
.btn-danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}
.btn-small { padding: 8px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
  border: 1px solid var(--line);
  background: var(--panel);
}
.pill-accent { background: var(--accent-soft); color: var(--accent); border-color: rgba(124, 92, 191, 0.2); }
.pill-muted { color: var(--muted); }

.board-shell { padding: 18px; flex: 1; }
.board {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(260px, 1fr));
  align-items: start;
}

.board-column {
  display: flex; flex-direction: column;
  min-height: 360px;
  border-radius: var(--radius);
  background: var(--panel-soft);
  border: 1px solid rgba(219, 227, 240, 0.9);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
}

.column-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 12px 8px;
}
.column-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }
.column-count {
  min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px;
  display: inline-grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 12px; color: var(--muted); font-weight: 800;
}

.column-body {
  padding: 6px 10px 12px;
  min-height: 250px;
  display: flex; flex-direction: column; gap: 10px;
  border-radius: 0 0 var(--radius) var(--radius);
}

.column-body.drag-over {
  background: rgba(124, 92, 191, 0.08);
  outline: 2px dashed rgba(124, 92, 191, 0.35);
  outline-offset: -6px;
}

.empty-state {
  margin-top: 6px;
  padding: 18px 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  background: rgba(255,255,255,0.45);
}

.task-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid rgba(219, 227, 240, 0.9);
  box-shadow: var(--shadow-soft);
  cursor: grab;
}
.task-card:active { cursor: grabbing; }
.task-card.dragging { opacity: 0.45; }

.task-top {
  display: flex; gap: 10px; align-items: flex-start; justify-content: space-between;
}
.task-title {
  margin: 0;
  font-size: 14px; font-weight: 800;
  line-height: 1.35;
  word-break: break-word;
}
.task-desc {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.task-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-size: 11px; color: var(--muted);
}
.task-chip {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  font-weight: 700;
}

.task-attachments {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 2px;
}
.task-attachments a {
  font-size: 11px;
  color: var(--accent);
  text-decoration: underline;
  word-break: break-all;
}

.task-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-top: 2px;
}

.overlay {
  position: fixed; inset: 0;
  background: rgba(15, 24, 39, 0.38);
  backdrop-filter: blur(2px);
  z-index: 40;
}

.modal, .drawer, .login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  border-radius: 20px;
  z-index: 50;
  display: flex; flex-direction: column;
  overflow: hidden;
}

.modal-header, .drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal-header h2, .drawer-header h2 { margin: 0; font-size: 18px; }
.drawer-header p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.modal-body {
  padding: 18px;
  overflow: auto;
  display: flex; flex-direction: column; gap: 16px;
}
.modal-footer, .drawer-footer, .drawer-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}
.modal-footer { justify-content: flex-end; }
.drawer-toolbar { border-top: 0; border-bottom: 1px solid var(--line); }

.field { display: flex; flex-direction: column; gap: 8px; }
.field span {
  font-size: 12px; font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.field input, .field textarea, .field select, .drawer-toolbar input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  background: #fff;
  color: var(--text);
}
.field input:focus, .field textarea:focus, .field select:focus, .drawer-toolbar input:focus {
  border-color: rgba(124, 92, 191, 0.5);
  box-shadow: 0 0 0 4px rgba(124, 92, 191, 0.08);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.attachments-header {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.help-text {
  font-size: 12px;
  color: var(--muted);
}

.attachment-list {
  display: flex; flex-direction: column; gap: 8px;
}
.attachment-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
}
.attachment-meta {
  min-width: 0;
  display: flex; flex-direction: column; gap: 4px;
}
.attachment-meta a {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-decoration: underline;
  word-break: break-all;
}
.attachment-meta small { color: var(--muted); }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(520px, calc(100vw - 16px));
  z-index: 50;
  display: flex; flex-direction: column;
}

.archive-list {
  flex: 1;
  overflow: auto;
  padding: 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.archive-item {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  display: flex; flex-direction: column; gap: 10px;
}
.archive-item h3 {
  margin: 0;
  font-size: 14px;
}
.archive-item p {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: pre-wrap;
}
.archive-item footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  max-width: min(560px, calc(100vw - 24px));
  padding: 12px 14px;
  border-radius: 14px;
  color: #fff;
  background: rgba(23, 32, 49, 0.96);
  box-shadow: var(--shadow);
  font-size: 13px; font-weight: 700;
}

.icon-btn {
  width: 36px; height: 36px;
  display: inline-grid; place-items: center;
  font-size: 16px;
}

.flash {
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
}
.flash-error {
  background: rgba(214, 69, 69, 0.1);
  color: var(--danger);
  border: 1px solid rgba(214, 69, 69, 0.15);
}

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(124, 92, 191, 0.18), transparent 30%),
    radial-gradient(circle at bottom left, rgba(31, 157, 98, 0.12), transparent 35%),
    var(--bg);
}
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: min(460px, 100%);
  border-radius: 22px;
  padding: 28px;
}
.login-eyebrow {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.login-card h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}
.login-copy {
  margin: 10px 0 18px;
  color: var(--muted);
}
.login-form {
  display: flex; flex-direction: column; gap: 14px;
}
.login-demo {
  margin-top: 18px;
  padding: 12px;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

@media (max-width: 1200px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
  }
  .board { grid-template-columns: repeat(2, minmax(260px, 1fr)); }
  .topbar-actions { justify-content: space-between; }
}

@media (max-width: 760px) {
  .board { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .search-wrap { width: 100%; }
  .search-wrap input { min-width: 0; }
  .modal, .drawer {
    width: calc(100vw - 12px);
    border-radius: 18px;
  }
  .drawer {
    left: 6px;
    right: 6px;
    top: 6px;
    bottom: 6px;
    width: auto;
  }
  .modal {
    top: 6px;
    left: 6px;
    right: 6px;
    bottom: 6px;
    transform: none;
    width: auto;
    max-height: none;
  }
  .modal-footer { justify-content: stretch; }
  .modal-footer .btn { flex: 1; }
}
