:root {
  --bg: #f5f5f3;
  --panel: #ffffff;
  --border: #d8d8d3;
  --text: #1a1a17;
  --muted: #6b6b63;
  --accent: #1f6f4a;
  --accent-dark: #164d33;
  --red: #b3261e;
  --red-bg: #fbe9e7;
  --yellow: #8a6d00;
  --yellow-bg: #fbf3d9;
  --blue: #1a4b8f;
  --blue-bg: #e6edf7;
  --grey-bg: #ececea;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

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

header.topbar .brand { font-weight: 700; font-size: 16px; }
header.topbar nav a { margin-left: 14px; font-size: 13px; color: var(--muted); font-weight: 600; }
header.topbar nav a:first-child { margin-left: 0; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

h1 { font-size: 20px; margin: 0 0 12px; }
h2 { font-size: 15px; margin: 20px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.project-card { display: block; color: var(--text); }
.project-card:hover { border-color: var(--accent); text-decoration: none; }
.project-card .name { font-weight: 700; font-size: 15px; }
.project-card .meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.badge.client { background: var(--blue-bg); color: var(--blue); }
.badge.own_business { background: #ece6f7; color: #5a3d99; }
.badge.agency { background: #e2f3ea; color: var(--accent-dark); }
.badge.not_started { background: var(--grey-bg); color: var(--muted); }
.badge.submitted { background: var(--blue-bg); color: var(--blue); }
.badge.pending_review { background: var(--yellow-bg); color: var(--yellow); }
.badge.live { background: #dff3e6; color: var(--accent-dark); }
.badge.parked { background: var(--grey-bg); color: var(--muted); }

.progress-bar {
  background: var(--grey-bg);
  border-radius: 6px;
  height: 8px;
  overflow: hidden;
  margin: 8px 0 4px;
}
.progress-bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
}
.progress-label { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }

table.list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.list th, table.list td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
table.list th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }

.waiting-row.overdue { background: var(--red-bg); }
.waiting-row .days { font-weight: 700; }
.waiting-row.overdue .days { color: var(--red); }

.status-pill {
  border: none;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.status-not_started { background: var(--grey-bg); color: var(--muted); }
.status-in_progress { background: var(--blue-bg); color: var(--blue); }
.status-waiting { background: var(--yellow-bg); color: var(--yellow); }
.status-done { background: #dff3e6; color: var(--accent-dark); }
.status-skipped { background: var(--grey-bg); color: var(--muted); text-decoration: line-through; }

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.task-row:last-child { border-bottom: none; }
.task-main { flex: 1; min-width: 200px; }
.task-title { font-weight: 600; }
.task-howto { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.task-howto p { margin: 0 0 4px; }
.task-waiting-info { font-size: 12.5px; color: var(--yellow); margin-top: 2px; }
.task-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.task-actions form { display: inline; }
.link-btn {
  background: none; border: none; color: var(--muted); font-size: 12px;
  cursor: pointer; padding: 2px 4px; text-decoration: underline;
}
.link-btn:hover { color: var(--text); }

details.inline-form { display: inline-block; }
details.inline-form summary { list-style: none; cursor: pointer; }
details.inline-form summary::-webkit-details-marker { display: none; }
details.inline-form .popover {
  margin-top: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 6px;
}
details.inline-form input[type=text] {
  width: 220px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 4px;
}

.details-box { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; }
.detail-field { font-size: 13.5px; }
.detail-field .k { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.detail-field .v { display: flex; align-items: center; gap: 6px; }
.copy-btn {
  border: 1px solid var(--border); background: var(--panel); border-radius: 4px;
  font-size: 11px; padding: 1px 6px; cursor: pointer; color: var(--muted);
}
.copy-btn.copied { color: var(--accent); border-color: var(--accent); }

.btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; color: #fff; }

form.stack label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 3px; }
form.stack input, form.stack select, form.stack textarea {
  width: 100%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 5px; font-size: 14px;
  font-family: inherit;
}
form.stack textarea { min-height: 70px; }

.empty { color: var(--muted); font-size: 13px; padding: 10px 0; }

@media (max-width: 600px) {
  header.topbar nav a { margin-left: 10px; font-size: 12px; }
  .grid { grid-template-columns: 1fr; }
  table.list, table.list thead { display: block; }
}
