:root {
  --bg: #ffffff;
  --ink: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --red: #fecaca;
  --red-border: #ef4444;
  --yellow: #fef3c7;
  --yellow-border: #f59e0b;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: #fafafa;
  color: var(--ink);
}

.hidden { display: none !important; }

/* ---------- Lock screen ---------- */
.lock-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
}
.lock-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 320px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.lock-box h1 { font-size: 20px; margin: 0 0 6px; }
.lock-box p { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.lock-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 12px;
}
.lock-box button {
  width: 100%;
  padding: 10px 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
}
.lock-box button:hover { background: var(--accent-hover); }
.error { color: #dc2626 !important; font-size: 13px; }

/* ---------- App shell ---------- */
.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 32px 64px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.app-header h1 { font-size: 22px; margin: 0; }

.add-event-btn {
  width: 100%;
  padding: 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  background: #eff6ff;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  margin-bottom: 28px;
  transition: background 0.15s;
}
.add-event-btn:hover { background: #dbeafe; }

.relock-link {
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}

/* ---------- Event blocks ---------- */
.event-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 28px;
  padding: 16px;
  overflow-x: auto;
}

.event-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.event-title-input {
  font-size: 17px;
  font-weight: 700;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 8px;
  flex: 1;
  background: transparent;
}
.event-title-input:hover, .event-title-input:focus {
  border-color: var(--border);
  background: #fafafa;
  outline: none;
}

table.items-table, table.owners-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 900px;
}
table.owners-table { min-width: 0; }

.items-table th, .owners-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.items-table td, .owners-table td {
  padding: 4px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.items-table tr.row-yellow { background: var(--yellow); }
.items-table tr.row-red { background: var(--red); }

.cell-input, .cell-textarea, .cell-select {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 7px;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  resize: none;
  color: var(--ink);
}
.cell-input:hover, .cell-textarea:hover, .cell-select:hover,
.cell-input:focus, .cell-textarea:focus, .cell-select:focus {
  border-color: var(--border);
  background: #fff;
  outline: none;
}
.cell-textarea { min-height: 34px; }

td.owner-cell { position: relative; min-width: 160px; }
td.item-cell { min-width: 140px; }
td.desc-cell, td.dep-cell, td.blocks-cell { min-width: 160px; }
td.deadline-cell { min-width: 130px; }
td.status-cell { min-width: 120px; }

.mention-dropdown {
  position: absolute;
  z-index: 20;
  top: 100%;
  left: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  min-width: 180px;
  max-height: 180px;
  overflow-y: auto;
}
.mention-option {
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
}
.mention-option:hover, .mention-option.active { background: #eff6ff; }

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--muted);
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
}
.icon-btn:hover { background: #fee2e2; color: #dc2626; }

.comments-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
  white-space: nowrap;
}
.comments-btn:hover { border-color: var(--accent); color: var(--accent); }

.add-row-btn {
  margin-top: 10px;
  padding: 7px 14px;
  font-size: 13px;
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink);
}
.add-row-btn:hover { background: #e5e7eb; }

/* ---------- Owners section ---------- */
.owners-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 40px;
}
.owners-section h2 { font-size: 16px; margin: 0 0 12px; }
.owners-table th:last-child, .owners-table td:last-child { width: 36px; }

/* ---------- Comment modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-box {
  background: var(--bg);
  border-radius: var(--radius);
  width: 420px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.modal-header h3 { margin: 0; font-size: 15px; }
.comment-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  min-height: 80px;
}
.comment-bubble {
  position: relative;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 8px 26px 8px 10px;
  font-size: 13px;
}
.comment-body { white-space: pre-wrap; word-break: break-word; }
.comment-time {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.delete-comment-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
}
.delete-comment-btn:hover { background: #fee2e2; color: #dc2626; }
.comment-input-row { display: flex; gap: 6px; }
.comment-input-row textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  font-family: inherit;
  font-size: 13px;
  resize: none;
  min-height: 40px;
}
.comment-input-row button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 13px;
}
.comment-input-row button:hover { background: var(--accent-hover); }
.empty-note { color: var(--muted); font-size: 13px; text-align: center; padding: 12px 0; }
