:root {
  --blue: #26405a;
  --sky: #2d96d3;
  --green: #84e889;
  --yellow: #f2ea83;
  --red: #ef7478;
  --line: #c8d1d8;
  --line-soft: #dde5ea;
  --text: #111827;
  --muted-text: #667085;
  --bg: #edf2f5;
  --panel: #fbfcfd;
  --table-head: #eef3f6;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

a { color: inherit; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: #fbfcfd;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.06);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px; }
.topbar a {
  padding: 8px 10px;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 3px;
}
.topbar a.active { background: #e8f1f8; border-color: #b9cedd; }
.muted { color: var(--muted-text); margin-left: 10px; }

main { padding: 12px; }
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.login-box {
  width: min(420px, calc(100vw - 24px));
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 22px;
}
.login-box h1 { margin: 0 0 18px; font-size: 22px; }
.login-form { display: grid; gap: 12px; }
.login-form label, .login-form input, .login-form button { width: 100%; }
.panel, .table-panel, .month {
  background: var(--panel);
  border: 1px solid var(--line);
  margin-bottom: 10px;
  padding: 10px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.flash {
  padding: 10px 12px;
  margin-bottom: 10px;
  border: 1px solid #a7d8a9;
  background: #e9f9ea;
}
.flash.error { border-color: #e79797; background: #fdecec; }

.entry-form, .filters, .toolbar, .import-export {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
}
label { display: grid; gap: 4px; font-size: 13px; }
input, select, button, .button {
  min-height: 34px;
  border: 1px solid var(--line);
  padding: 7px 10px;
  font: inherit;
}
input, select {
  background: #fff;
  min-width: 120px;
  border-radius: 3px;
}
input:focus, select:focus {
  outline: 2px solid #b9ddf3;
  outline-offset: 0;
  border-color: var(--sky);
}
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: var(--sky);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  border-radius: 3px;
}
button:hover, .button:hover { filter: brightness(0.96); }
.secondary { background: #7f8c8d; }
.success { background: #27ae60; }
.danger { background: #c0392b; }
.mini, .small-button { min-height: 28px; padding: 5px 9px; font-size: 12px; }
.small-button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  background: var(--blue);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

.totals { margin-top: 10px; font-weight: 600; display: flex; flex-wrap: wrap; gap: 8px; }
.import-export { margin-top: 10px; }

.split {
  display: grid;
  grid-template-columns: minmax(650px, 832px) minmax(520px, 1fr);
  gap: 10px;
}
h2 { margin: 0 0 10px; font-size: 16px; }
h3 { margin: 0 0 12px; font-size: 15px; }
.scroll { overflow: auto; max-height: 68vh; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { border: 1px solid #9fa9af; padding: 6px; text-align: left; vertical-align: top; }
th {
  background: var(--table-head);
  position: sticky;
  top: 0;
  z-index: 1;
  border-color: #aab6bd;
}
td { border-color: #b6c0c7; }
tbody tr:hover td { background: #f5f9fb; }
.week-row { cursor: pointer; }
tbody tr.selected:hover td,
tr.selected:hover td,
tr.state-ok td,
tr.state-complet td,
tr.state-surcharge td { background: #fff; }
tr.state-ok td:last-child { background: #dff7e2; }
tr.state-complet td:last-child { background: #fbf3b6; }
tr.state-surcharge td:last-child { background: #f7c5c8; }
tr.selected td,
tbody tr.selected:hover td { background: #0d83d4; color: #fff; }
.table-panel.large {
  background: #f8fafb;
}
.table-panel.large table {
  table-layout: fixed;
  width: 1307px;
  max-width: 100%;
}
.table-panel.large th:nth-child(1),
.table-panel.large td:nth-child(1) { width: 64px; }
.table-panel.large th:nth-child(2),
.table-panel.large td:nth-child(2) { width: 96px; }
.table-panel.large th:nth-child(3),
.table-panel.large td:nth-child(3) { width: 150px; }
.table-panel.large th:nth-child(4),
.table-panel.large td:nth-child(4) { width: 41px; }
.table-panel.large th:nth-child(5),
.table-panel.large td:nth-child(5) { width: 38px; }
.table-panel.large th:nth-child(6),
.table-panel.large td:nth-child(6) { width: 78px; }
.table-panel.large th:nth-child(7),
.table-panel.large td:nth-child(7) { width: 72px; }
.table-panel.large th:nth-child(8),
.table-panel.large td:nth-child(8) { width: 112px; }
.table-panel.large th:nth-child(9),
.table-panel.large td:nth-child(9) { width: 188px; }
.table-panel:first-child {
  font-size: 14px;
}
.table-panel:first-child th,
.table-panel:first-child td {
  padding: 6px;
}
.table-panel:first-child table {
  table-layout: fixed;
}
.table-panel:first-child th:nth-child(1),
.table-panel:first-child td:nth-child(1) { width: 74px; }
.table-panel:first-child th:nth-child(2),
.table-panel:first-child td:nth-child(2) { width: 66px; }
.table-panel:first-child th:nth-child(3),
.table-panel:first-child td:nth-child(3) { width: 62px; }
.table-panel:first-child th:nth-child(4),
.table-panel:first-child td:nth-child(4) { width: 82px; }
.table-panel:first-child th:nth-child(5),
.table-panel:first-child td:nth-child(5) { width: 70px; }
.table-panel:first-child th:nth-child(6),
.table-panel:first-child td:nth-child(6) { width: 58px; }
.table-panel:first-child th:nth-child(7),
.table-panel:first-child td:nth-child(7) { width: 76px; }
.week-card.state-ok { background: #e8f8e9; }
.week-card.state-complet { background: #fbf3b6; }
.week-card.state-surcharge { background: #f7c5c8; }
.status-red { background: #f7c5c8 !important; }
.status-yellow { background: #fbf3b6 !important; }
.status-green { background: #dff7e2 !important; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions form { margin: 0; }
.table-panel.large .actions {
  flex-wrap: nowrap;
  align-items: center;
  white-space: nowrap;
}
.table-panel.large .actions .button,
.table-panel.large .actions button {
  width: auto;
}

.week-log {
  margin-top: 22px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 10px;
  width: 1307px;
  max-width: 100%;
}
.week-log-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.format-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.format-toolbar button {
  min-width: 34px;
  min-height: 30px;
  padding: 4px 8px;
  background: #edf3f7;
  color: var(--text);
  border: 1px solid var(--line);
}
.log-editor {
  min-height: 210px;
  border: 3px solid #111;
  background: #fff;
  padding: 10px;
  overflow: auto;
}
.log-editor:focus {
  outline: 2px solid #b9ddf3;
  outline-offset: 2px;
}
.log-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.log-delete-form {
  margin-top: 8px;
}

.month h2 {
  margin: -11px 0 12px;
  display: inline-block;
  background: #fff;
  padding: 0 6px;
}
.week-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
}
.week-card {
  min-height: 140px;
  border: 1px solid #6d7377;
  padding: 12px;
  position: relative;
}
.week-card input { width: 70px; min-width: 70px; min-height: 28px; padding: 4px 6px; }
.week-card p { margin: 9px 0; }

@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .split { grid-template-columns: 1fr; }
  .scroll { max-height: none; }
  input, select { width: 100%; }
  label { width: 100%; }
  .entry-form button, .filters button, .button { width: 100%; }
}
