:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6eb;
  --text: #1c1f24;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1);
  --radius: 8px;
  --st-idee: #6b7280;
  --st-tournage: #2563eb;
  --st-montage: #d97706;
  --st-postee: #16a34a;
  --st-resultat: #7c3aed;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 1.5rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem; position: sticky; top: 0; z-index: 10;
}
.brand a {
  display: inline-flex; align-items: center; gap: .75rem;
  text-decoration: none; line-height: 1;
}
.brand a:hover { text-decoration: none; opacity: .85; }
.brand-logo {
  height: 30px; width: auto; max-width: 140px;
  display: block; flex-shrink: 0;
}
.brand-text {
  color: var(--text-muted); font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .12em;
  padding-left: .75rem; border-left: 1px solid var(--border);
  white-space: nowrap;
}
.mainnav { display: flex; gap: .5rem; flex: 1; }
.mainnav a { color: var(--text-muted); padding: .35rem .75rem; border-radius: 6px; }
.mainnav a:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.usermenu { display: flex; align-items: center; gap: 1rem; font-size: .9rem; color: var(--text-muted); }
.logout { color: var(--danger); }

.container { max-width: 1200px; margin: 1.5rem auto; padding: 0 1.5rem; }

.page-head {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem;
}
.page-head-actions { display: inline-flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.trash-actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.trash-actions form { margin: 0; }
h1 { margin: 0; font-size: 1.5rem; }
h2 { font-size: 1.15rem; margin-top: 2rem; }

/* Login / setup card */
.login-card {
  max-width: 420px; margin: 4rem auto; padding: 2rem;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.login-card h1 { font-size: 1.4rem; margin-bottom: .25rem; }
.login-card .subtitle { color: var(--text-muted); margin-top: 0; margin-bottom: 1.5rem; font-size: .95rem; }
.login-card form { display: flex; flex-direction: column; gap: 1rem; }
.login-card label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; }

/* Forms */
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=date], input[type=number], input[type=search], select, textarea {
  font: inherit; padding: .55rem .75rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
textarea { resize: vertical; min-height: 80px; font-family: inherit; }
label { font-size: .9rem; color: var(--text); }
fieldset { border: 1px solid var(--border); border-radius: 6px; padding: .75rem 1rem; margin: 0; }
legend { padding: 0 .5rem; font-size: .85rem; color: var(--text-muted); }
.checkbox { display: inline-flex; align-items: center; gap: .35rem; margin-right: 1rem; font-weight: normal; }
.checkbox input { width: auto; margin: 0; }

.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
  background: var(--surface); padding: 1.5rem;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.form-grid > label { display: flex; flex-direction: column; gap: .35rem; }
.field-full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: .75rem; }

/* Buttons */
.btn {
  display: inline-block; padding: .55rem 1rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { filter: brightness(.95); color: #fff; }
.btn-sm { padding: .3rem .65rem; font-size: .85rem; }
.btn-link { background: transparent; border: none; color: var(--primary); padding-left: 0; padding-right: 0; }
.btn-link:hover { background: transparent; text-decoration: underline; }

/* Filters */
.filters {
  display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem;
  background: var(--surface); padding: .75rem;
  border: 1px solid var(--border); border-radius: var(--radius);
}
.filters input, .filters select { width: auto; min-width: 140px; }

/* Table */
.table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.table th, .table td { padding: .65rem .75rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { background: #f9fafb; font-weight: 600; font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.table tbody tr:hover { background: var(--bg); }
.table tbody tr:last-child td { border-bottom: 0; }

/* Client cards (dashboard) */
.client-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.client-card {
  display: block; padding: 1rem 1.25rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: var(--text);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.client-card:hover {
  transform: translateY(-1px); box-shadow: var(--shadow);
  text-decoration: none; border-color: #c7d2fe;
}
.client-name { font-weight: 600; font-size: 1.05rem; margin-bottom: .65rem; }
.client-stats { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .65rem; }
.client-total { color: var(--text-muted); font-size: .85rem; }

/* Platform icons */
.platform-list { display: inline-flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.platform-icon {
  width: 22px; height: 22px; object-fit: contain; border-radius: 4px;
  background: #fff; padding: 1px;
  vertical-align: middle;
}
.platform-icon-sm { width: 22px; height: 22px; }
.platform-icon-md { width: 28px; height: 28px; }
.platform-pill {
  display: inline-block; padding: .1rem .5rem; font-size: .72rem;
  background: #eef0f3; color: var(--text-muted); border-radius: 10px; font-weight: 600;
}
.platforms-field .platform-choice {
  display: inline-flex; align-items: center; gap: .4rem;
  margin: .15rem .5rem .15rem 0; padding: .25rem .55rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  cursor: pointer; transition: background .12s ease, border-color .12s ease;
}
.platforms-field .platform-choice:hover { background: var(--bg); }
.platforms-field .platform-choice input { margin: 0; }
.platforms-field .platform-choice .platform-icon { width: 18px; height: 18px; }

/* Status badges */
.badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 12px;
  font-size: .75rem; font-weight: 600; color: #fff; line-height: 1.4;
}
.badge-idee { background: var(--st-idee); }
.badge-tournage { background: var(--st-tournage); }
.badge-montage { background: var(--st-montage); }
.badge-postee { background: var(--st-postee); }
.badge-resultat { background: var(--st-resultat); }

/* Flash */
.flash { padding: .65rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: .9rem; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.flash-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* Misc */
.muted { color: var(--text-muted); }
.month-picker { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.history { margin-top: 2rem; background: var(--surface); padding: 1rem 1.5rem; border-radius: var(--radius); border: 1px solid var(--border); }
.history ul { list-style: none; padding: 0; margin: .5rem 0; }
.history li { padding: .5rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.history li:last-child { border: 0; }
.hint { font-size: .8rem; color: var(--text-muted); margin-top: 1rem; }
code { background: #eef0f3; padding: .1rem .35rem; border-radius: 4px; font-size: .85em; }

@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: .75rem; padding: .75rem 1rem; }
  .mainnav { width: 100%; order: 3; flex-wrap: wrap; }
  .usermenu { font-size: .8rem; }
  .filters { flex-direction: column; }
  .filters input, .filters select { width: 100%; }
  .container { padding: 0 1rem; margin: 1rem auto; }
}
