:root {
  --bg: #f6f4ef;
  --bg-soft: #efece5;
  --bg-card: #ffffff;
  --bg-elev: #faf8f3;
  --border: #e6e2d8;
  --border-strong: #d8d3c5;
  --text: #1d1c1a;
  --text-soft: #4a4845;
  --muted: #8a857d;
  --accent: #c8351f;
  --accent-soft: #f7e6e2;
  --accent-strong: #a82a17;
  --admin: #c8351f;
  --client: #2563eb;
  --client-soft: #e6efff;
  --ok: #1f8a4a;
  --ok-soft: #e2f3e8;
  --warn: #b6760a;
  --warn-soft: #fbf0d8;
  --danger: #b3261e;
  --shadow-sm: 0 1px 2px rgba(17,16,15,.04);
  --shadow-md: 0 1px 3px rgba(17,16,15,.06), 0 4px 12px rgba(17,16,15,.04);
  --shadow-lg: 0 4px 24px rgba(17,16,15,.08);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: .85rem 1.4rem;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: saturate(150%) blur(8px);
}
.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  letter-spacing: -.01em;
}
.brand:hover { color: var(--text); }
.brand-logo { height: 30px; width: auto; display: block; }
.topbar nav { display: flex; gap: .25rem; flex: 1; }
.topbar nav a {
  color: var(--text-soft);
  padding: .45rem .85rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 14px;
  transition: background .15s, color .15s;
}
.topbar nav a:hover { color: var(--text); background: var(--bg-soft); }
.topbar nav a.active { color: var(--accent); background: var(--accent-soft); }
.topbar nav a.try-new {
  margin-left: auto;
  background: linear-gradient(135deg, #fff4ef 0%, #fde6df 100%);
  color: var(--accent);
  font-weight: 600;
  border: 1px solid var(--accent-soft);
}
.topbar nav a.try-new:hover { background: linear-gradient(135deg, #fde6df, #fbd6cc); }
.topbar .user { display: flex; align-items: center; gap: .7rem; }

/* ---------- Layout ---------- */
.container {
  max-width: 780px;
  margin: 1.8rem auto;
  padding: 0 1.2rem;
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
  border-style: dashed;
  background: transparent;
  box-shadow: none;
}
.login-card {
  max-width: 380px;
  margin: 6rem auto;
  padding: 2rem 1.8rem;
  box-shadow: var(--shadow-lg);
}

/* ---------- Typography ---------- */
h1, h2, h3 { color: var(--text); margin: 0 0 .55rem; line-height: 1.25; letter-spacing: -.015em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error {
  background: #fdecea;
  border: 1px solid #f5c2bd;
  color: #8a1c14;
  padding: .55rem .75rem;
  border-radius: var(--radius-sm);
  margin-bottom: .8rem;
  font-size: 13px;
}

/* ---------- Forms ---------- */
label { display: block; margin: .6rem 0; font-size: 14px; color: var(--text-soft); font-weight: 500; }
input[type=text], input[type=password], input[type=date], input:not([type]), textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: .6rem .8rem;
  border-radius: var(--radius-sm);
  font: inherit;
  resize: vertical;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 80px; }

input[type=file] {
  color: var(--muted);
  font-size: 13px;
  padding: .35rem 0;
}
input[type=file]::-webkit-file-upload-button {
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: .35rem .7rem;
  font: inherit;
  font-size: 13px;
  margin-right: .6rem;
  cursor: pointer;
  color: var(--text);
}
input[type=file]::-webkit-file-upload-button:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- Buttons ---------- */
button, .primary, .link {
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: .5rem .95rem;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text);
  transition: all .15s;
}
button:hover { background: var(--bg-soft); }
.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(200,53,31,.25);
}
.primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  box-shadow: 0 2px 6px rgba(200,53,31,.3);
}
.link {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding: .35rem .55rem;
}
.link:hover { color: var(--text); background: var(--bg-soft); }
.link.danger { color: var(--danger); }
.link.danger:hover { background: #fdecea; color: var(--danger); }
.inline { display: inline; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .2px;
  text-transform: uppercase;
}
.badge-admin { background: var(--accent-soft); color: var(--accent); }
.badge-client { background: var(--client-soft); color: var(--client); }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, #ffffff 0%, #fff7f4 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem 1.6rem;
  margin-bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow-md);
}
.hero-text { flex: 1 1 280px; }
.hero-text h1 { font-size: 24px; margin: 0 0 .3rem; }
.hero-text p { margin: 0; color: var(--text-soft); }
.hero-stats { display: flex; gap: .5rem; flex-wrap: wrap; }
.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .65rem .9rem;
  min-width: 76px;
  text-align: center;
  display: flex;
  flex-direction: column;
}
.stat-num { font-size: 24px; font-weight: 700; line-height: 1; color: var(--text); letter-spacing: -.02em; }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-top: .25rem; font-weight: 600; }
.stat-progress { color: var(--warn); }
.stat-done { color: var(--ok); }

/* ---------- Composer ---------- */
.composer { padding: 1.1rem 1.2rem 1rem; }
.composer h2 { margin-bottom: .8rem; }
.composer textarea { min-height: 90px; }
.composer-row {
  display: flex;
  gap: .7rem;
  align-items: center;
  margin-top: .8rem;
  flex-wrap: wrap;
}
.composer-row input[type=file] { flex: 1; min-width: 200px; }
.composer-row label { margin: 0; display: flex; align-items: center; gap: .4rem; }
.composer-row label input[type=date] { width: auto; padding: .35rem .55rem; }

/* ---------- Posts ---------- */
.post-head, .todo-head {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: .6rem;
  flex-wrap: wrap;
}
.post-head time, .todo-head .small {
  color: var(--muted);
  font-size: 12px;
  margin-left: auto;
}
.post-body {
  white-space: pre-wrap;
  margin-bottom: .6rem;
  color: var(--text);
  line-height: 1.6;
}
.todo-body {
  white-space: pre-wrap;
  color: var(--text-soft);
  margin: .35rem 0 .65rem;
  font-size: 14px;
  line-height: 1.55;
}

/* ---------- File galleries ---------- */
.files {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  margin: .6rem 0;
}
.files img {
  max-width: 240px;
  max-height: 200px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  object-fit: cover;
  transition: transform .15s, box-shadow .15s;
  cursor: zoom-in;
}
.files img:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.file-link {
  background: var(--bg-elev);
  padding: .4rem .75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 500;
  transition: all .15s;
}
.file-link:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- Comments ---------- */
.comments {
  border-top: 1px solid var(--border);
  margin-top: .9rem;
  padding-top: .7rem;
}
.comment {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  margin: .55rem 0;
  padding: .65rem .85rem;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.comment-head { display: flex; align-items: center; gap: .5rem; }
.comment-head time { color: var(--muted); font-size: 11px; margin-left: auto; }
.comment-body {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
  line-height: 1.55;
}
.comment-body a { color: var(--client); text-decoration: underline; }
.comment-files video, .comment-files audio { max-width: 100%; border-radius: var(--radius-sm); }
.comment-files video { max-height: 300px; background: #000; }
.comment-files audio { width: 100%; min-width: 260px; }

.reply {
  display: flex;
  gap: .5rem;
  margin-top: .7rem;
  align-items: center;
  flex-wrap: wrap;
}
.reply input[name="body"] { flex: 1; min-width: 180px; }
.attach-btn {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
}
.attach-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.attach-btn input[type="file"] { display: none; }
.attach-btn.has-files {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.attach-btn.has-files::after {
  content: attr(data-count);
  margin-left: .35rem;
  font-size: 12px;
  font-weight: 600;
}

/* ---------- Filters ---------- */
.filters {
  display: flex;
  gap: .4rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.filter {
  padding: .35rem .9rem;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
  text-transform: capitalize;
  transition: all .15s;
}
.filter:hover { border-color: var(--border-strong); color: var(--text); }
.filter.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 1px 3px rgba(200,53,31,.25);
}

/* ---------- Todo statuses ---------- */
.status {
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
}
.status-open { background: var(--bg-elev); color: var(--muted); border: 1px solid var(--border); }
.status-in_progress { background: var(--warn-soft); color: var(--warn); }
.status-done { background: var(--ok-soft); color: var(--ok); }
.todo-done { opacity: .65; }
.todo-done h3 { text-decoration: line-through; color: var(--muted); }
.todo-actions {
  display: flex;
  gap: .35rem;
  margin-top: .7rem;
  flex-wrap: wrap;
  padding-top: .55rem;
  border-top: 1px solid var(--border);
}

/* ---------- Login ---------- */
.login-card .login-logo { display: block; max-width: 160px; height: auto; margin: 0 auto 1rem; }
.login-card h1 { text-align: center; margin-bottom: .35rem; }
.login-card p.muted { text-align: center; margin-bottom: 1.2rem; }
.login-card form button { width: 100%; margin-top: .8rem; padding: .65rem; font-size: 15px; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .container { padding: 0 .85rem; margin: 1rem auto; }
  .topbar { gap: .8rem; padding: .65rem .9rem; }
  .topbar nav { gap: 0; }
  .topbar nav a { padding: .35rem .55rem; font-size: 13px; }
  .hero { padding: 1.1rem; gap: 1rem; }
  .hero-text h1 { font-size: 19px; }
  .hero-stats { width: 100%; justify-content: space-between; }
  .stat { min-width: 0; flex: 1; padding: .5rem .4rem; }
  .stat-num { font-size: 19px; }
  .files img { max-width: 100%; max-height: 240px; }
  .card { padding: .95rem 1rem; }
  .login-card { margin: 2rem auto; padding: 1.5rem 1.2rem; }
}
