@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --bg:           #f4f5f7;
  --surface:      #ffffff;
  --surface2:     #f0f2f5;
  --border:       #dde1e7;
  --text:         #1a1d23;
  --text-muted:   #6b7280;
  --accent:       #0a3060;
  --accent-hover: #0d4080;
  --accent-light: #e8f0fb;
  --active:       #1a6b3c;
  --active-bg:    #e6f4ed;
  --completed:    #1e5a8e;
  --completed-bg: #e8f2fb;
  --deleted:      #7f1d1d;
  --deleted-bg:   #fef2f2;
  --overdue:      #991b1b;
  --overdue-bg:   #fff1f1;
  --overdue-border: #fca5a5;
  --shadow:       0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.12);
  --radius:       10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 16px;
}

/* ── HEADER ──────────────────────────────────────────────────────────────── */
header {
  background: var(--accent);
  color: white;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  gap: 12px;
}

.header-left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.logo-mark {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.15);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; letter-spacing: -0.5px;
  flex-shrink: 0;
}

header h1 {
  font-family: 'DM Serif Display', serif;
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

header h1 span {
  opacity: 0.7;
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  display: block;
  font-weight: 400;
}

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

#user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#user-email-lbl {
  font-size: 12px;
  opacity: 0.7;
  white-space: nowrap;
}

#user-info button {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .8rem;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
}

#user-info button:hover { background: rgba(255,255,255,.2); }

/* ── BUTTONS ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary   { background: white; color: var(--accent); }
.btn-primary:hover { background: #f0f6ff; }

.btn-ghost     { background: rgba(255,255,255,0.12); color: white; border: 1px solid rgba(255,255,255,0.2); }
.btn-ghost:hover { background: rgba(255,255,255,0.2); }

.btn-outline   { background: white; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger    { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }

.btn-save      { background: var(--accent); color: white; }
.btn-save:hover { background: var(--accent-hover); }

.btn-complete  { background: var(--active-bg); color: var(--active); border: 1px solid #a7d7b8; }
.btn-complete:hover { background: #d0eddb; }

.btn-reopen    { background: var(--completed-bg); color: var(--completed); border: 1px solid #93c5fd; }
.btn-reopen:hover { background: #dbeafe; }

/* ── TAB NAVIGATION ──────────────────────────────────────────────────────── */
.tab-nav {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: 0 24px;
  display: flex;
  gap: 0;
  overflow-x: auto;
  position: sticky;
  top: 60px;
  z-index: 90;
}

.tab-btn {
  padding: 14px 18px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  transition: all 0.15s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.tab-badge {
  background: var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  line-height: 1.6;
}

.tab-btn.active .tab-badge { background: var(--accent-light); color: var(--accent); }
.tab-badge:empty { display: none; }

/* ── TOOLBAR ─────────────────────────────────────────────────────────────── */
.toolbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.search-wrap svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 8px 10px 8px 34px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  background: white;
  box-shadow: 0 0 0 3px rgba(10,48,96,0.08);
}

input[type="text"], input[type="date"], select, textarea {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  transition: border-color 0.15s;
}

input[type="text"]:focus, input[type="date"]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10,48,96,0.08);
}

.filter-select {
  padding: 8px 28px 8px 10px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
}

.count-badge {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  margin-left: auto;
  white-space: nowrap;
}

/* ── MAIN CONTENT ────────────────────────────────────────────────────────── */
main { padding: 24px 28px; max-width: 1200px; margin: 0 auto; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── SECTION BLOCKS ──────────────────────────────────────────────────────── */
.section-block { margin-bottom: 32px; }

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.section-header h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  font-weight: 400;
  color: var(--text);
}

.section-count {
  background: var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 12px;
}

.overdue-block .section-header h2 { color: var(--overdue); }
.overdue-block .section-count { background: #fee2e2; color: var(--overdue); }

/* ── ACTION CARDS ────────────────────────────────────────────────────────── */
.cards-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: stretch;
  transition: box-shadow 0.15s, border-color 0.15s;
  overflow: hidden;
}

.action-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: #b0becc;
}

.action-card.card-overdue {
  background: var(--overdue-bg);
  border-color: var(--overdue-border);
}

.action-card.card-overdue:hover { border-color: #f87171; }

.card-main {
  flex: 1;
  padding: 14px 18px;
  min-width: 0;
  cursor: pointer;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
  line-height: 1.4;
}

.card-overdue .card-title { color: #7f1d1d; }

.card-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.5;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.card-badges {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
}

.due-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.due-label.overdue {
  color: var(--overdue);
  font-weight: 700;
}

.card-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 10px 12px;
  border-left: 1px solid var(--border);
  background: var(--surface2);
}

.card-overdue .card-actions { background: #fde8e8; border-color: var(--overdue-border); }

/* ── BADGES ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
  text-transform: uppercase;
}

.badge-High     { background: #fee2e2; color: #991b1b; }
.badge-Medium   { background: #fef3c7; color: #92400e; }
.badge-Low      { background: #dcfce7; color: #166534; }
.badge-cat      { background: var(--accent-light); color: var(--accent); text-transform: none; font-size: 12px; font-weight: 600; letter-spacing: 0; }

.badge-status-open      { background: var(--active-bg); color: var(--active); }
.badge-status-completed { background: var(--completed-bg); color: var(--completed); }
.badge-status-deleted   { background: var(--deleted-bg); color: var(--deleted); }

.meta-chip {
  font-size: 12px;
  color: var(--text-muted);
  padding: 2px 7px;
  background: var(--surface2);
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ── ICON BUTTONS ────────────────────────────────────────────────────────── */
.icon-btn {
  width: 30px; height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  flex-shrink: 0;
}

.icon-btn:hover       { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.icon-btn.del:hover   { border-color: #fca5a5; color: #b91c1c; background: #fef2f2; }
.icon-btn.done:hover  { border-color: #86efac; color: #166534; background: #dcfce7; }
.icon-btn.undo:hover  { border-color: #93c5fd; color: #1e40af; background: #dbeafe; }

/* ── EMPTY STATE ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.empty-state svg { margin-bottom: 12px; opacity: 0.35; }
.empty-state p   { font-size: 15px; margin-bottom: 4px; color: var(--text); font-weight: 500; }
.empty-state small { font-size: 13px; }

/* ── SLIDE PANEL ─────────────────────────────────────────────────────────── */
.panel-overlay {
  position: fixed; inset: 0;
  background: rgba(10,20,40,0.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  backdrop-filter: blur(2px);
}

.panel-overlay.open { opacity: 1; pointer-events: all; }

.panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(780px, 95vw);
  background: var(--surface);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.panel.open { transform: translateX(0); }

.panel-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface2);
  flex-shrink: 0;
}

.panel-title {
  font-family: 'DM Serif Display', serif;
  font-size: 20px;
  font-weight: 400;
}

.panel-close {
  width: 32px; height: 32px;
  border-radius: 6px;
  background: none;
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}

.panel-close:hover { background: var(--border); color: var(--text); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface);
  flex-shrink: 0;
}

.panel-footer .spacer { flex: 1; }

/* ── FORM ────────────────────────────────────────────────────────────────── */
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

input[type="text"], input[type="date"], select {
  padding: 10px 13px;
  width: 100%;
  font-size: 14px;
}

textarea {
  padding: 10px 13px;
  width: 100%;
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
  font-size: 14px;
}

/* ── VIEW PANEL LAYOUT ───────────────────────────────────────────────────── */
.view-badges   { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.view-title    { font-family: 'DM Serif Display', serif; font-size: 22px; font-weight: 400; line-height: 1.35; color: var(--text); }

.view-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  background: var(--surface2);
  border-radius: 8px;
  padding: 16px 18px;
}

.view-field   { display: flex; flex-direction: column; gap: 4px; }
.view-label   { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-muted); }
.view-value   { font-size: 14px; color: var(--text); line-height: 1.5; }
.view-value.overdue { color: var(--overdue); font-weight: 700; }
.view-value.empty   { color: var(--text-muted); font-style: italic; }

.view-section { background: var(--surface2); border-radius: 8px; padding: 16px 18px; }
.view-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.view-desc { font-size: 14px; color: var(--text); line-height: 1.7; white-space: pre-wrap; word-break: break-word; }

/* ── COMMENTS ────────────────────────────────────────────────────────────── */
.comment-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.comment-item:last-of-type { border-bottom: none; }

.comment-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 6px;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 12px;
  align-items: center;
}

.link-btn {
  background: none;
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  text-decoration: underline;
}

.link-btn.danger:hover { color: #b91c1c; }

.add-comment-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.empty-note { font-size: 13px; color: var(--text-muted); font-style: italic; padding: 6px 0; }

/* ── ATTACHMENTS ─────────────────────────────────────────────────────────── */
.attach-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.attach-item:last-of-type { border-bottom: none; }

.attach-info { display: flex; align-items: center; gap: 10px; min-width: 0; }

.attach-icon { font-size: 20px; flex-shrink: 0; }

.attach-name {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  word-break: break-word;
}

.attach-name:hover { text-decoration: underline; }
.attach-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.attach-upload {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.upload-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 7px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  transition: all 0.15s;
  white-space: nowrap;
}

.upload-label:hover { border-color: var(--accent); color: var(--accent); }
.upload-progress { font-size: 12px; color: var(--text-muted); }

/* ── TOAST ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--text);
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
}

.toast.show    { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: #1a6b3c; }
.toast.error   { background: #b91c1c; }

/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  header { padding: 0 14px; gap: 8px; }
  header h1 { font-size: 15px; }
  header h1 span { display: none; }
  .header-actions .btn span { display: none; }
  main { padding: 14px 14px; }
  .toolbar { padding: 10px 14px; }
  .form-row { grid-template-columns: 1fr; }
  .view-meta-grid { grid-template-columns: 1fr 1fr; }
  .tab-btn { padding: 12px 12px; font-size: 13px; }
  .tab-nav { padding: 0 12px; }
  .panel-body { padding: 16px 16px; }
  .panel-footer { padding: 12px 16px; }
  .panel-header { padding: 16px 16px; }
  .card-main { padding: 12px 14px; }
}

@media (max-width: 420px) {
  .view-meta-grid { grid-template-columns: 1fr; }
}
