:root {
  color-scheme: light;
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-soft: #f7f8fa;
  --ink: #111827;
  --muted: #647081;
  --line: #d7dde6;
  --line-strong: #aeb8c6;
  --primary: #1f4e79;
  --primary-dark: #163a5c;
  --accent: #b7791f;
  --warning: #b54708;
  --danger: #b42318;
  --green: #d9ead3;
  --yellow: #fff2cc;
  --orange: #fce5cd;
  --red: #f4cccc;
  --shadow: 0 14px 38px rgba(21, 34, 52, .12);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  min-height: 100vh;
}

body.login-mode {
  display: block;
  background:
    linear-gradient(105deg, rgba(8, 13, 22, .94) 0%, rgba(8, 13, 22, .78) 42%, rgba(8, 13, 22, .3) 100%),
    url("/static/img/abidjan-container-terminal.png?v=20260728-1748") center / cover fixed,
    #1b2430;
}

.login-screen {
  display: none;
  min-height: 100vh;
  grid-template-columns: minmax(320px, 1fr) 390px;
  width: min(1120px, calc(100vw - 48px));
  margin: 0 auto;
  justify-content: stretch;
  align-items: center;
  gap: 48px;
  padding: 24px;
}

body.login-mode .login-screen { display: grid; }
body.login-mode .sidebar,
body.login-mode main { display: none; }

.login-visual {
  position: relative;
  min-height: 480px;
  border-radius: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.login-visual::after {
  content: "Pilotage flotte international";
  position: absolute;
  left: 0;
  bottom: 34px;
  padding: 0;
  border-radius: 0;
  color: white;
  background: transparent;
  max-width: 680px;
  font-size: 56px;
  line-height: 1;
  font-weight: 850;
  text-shadow: 0 12px 36px rgba(0, 0, 0, .42);
}

.login-visual img {
  display: none;
}

.login-form {
  width: min(380px, 100%);
  display: grid;
  gap: 12px;
  padding: 28px;
  background: rgba(255, 255, 255, .94);
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .32);
  backdrop-filter: blur(12px);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.login-brand strong { display: block; font-size: 20px; }
.login-brand small { color: var(--muted); display: block; margin-top: 2px; }

#loginError {
  min-height: 18px;
  color: var(--danger);
}

.sidebar {
  background: #121a27;
  color: white;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(255,255,255,.08);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #d8a33a;
  color: #121a27;
  font-weight: 800;
  flex: 0 0 auto;
}

.brand small { color: #b9c3d3; display: block; margin-top: 3px; }

nav { display: grid; gap: 14px; overflow: auto; padding-right: 2px; }
.nav-group { display: grid; gap: 4px; }
.nav-group small {
  color: #91a1b7;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  padding: 0 10px 3px;
  text-transform: uppercase;
}

nav button {
  text-align: left;
  background: transparent;
  color: #dce4ef;
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  min-height: 38px;
  justify-content: flex-start;
}

nav button.active,
nav button:hover {
  background: rgba(255,255,255,.12);
  color: white;
}

.session-box {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,.1);
}

.session-box small { color: #b9c3d3; }
.session-box button { width: 100%; }

input, select, textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: white;
  color: var(--ink);
  font: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(34, 84, 154, .18);
  border-color: var(--primary);
}

textarea { min-height: 80px; resize: vertical; }

button, .button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: white;
  border-radius: 6px;
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .12) inset;
}

button:hover, .button:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
button.secondary { background: white; color: var(--ink); border-color: var(--line-strong); }
button.secondary:hover { background: var(--panel-soft); color: var(--ink); border-color: var(--primary); }
button.danger { background: var(--danger); border-color: var(--danger); }
button.icon { width: 34px; min-height: 34px; padding: 0; background: transparent; color: var(--ink); border-color: transparent; font-size: 24px; }

main { min-width: 0; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.94);
  position: sticky;
  top: 0;
  z-index: 3;
  backdrop-filter: blur(10px);
}

h1, h2, h3 { margin: 0; letter-spacing: 0; }
h1 { font-size: 24px; line-height: 1.15; }
.topbar p { margin: 5px 0 0; color: var(--muted); max-width: 780px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

#view { padding: 22px 24px 42px; }

.dashboard-visual {
  display: grid;
  align-items: end;
  background:
    linear-gradient(90deg, rgba(8, 13, 22, .94) 0%, rgba(8, 13, 22, .78) 48%, rgba(8, 13, 22, .24) 100%),
    url("/static/img/abidjan-container-terminal.png?v=20260728-1748") center / cover;
  color: white;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid rgba(17, 24, 39, .24);
  box-shadow: var(--shadow);
  min-height: 318px;
}

.dashboard-copy {
  width: min(760px, 100%);
  padding: 34px;
}
.dashboard-visual span {
  display: block;
  color: #f6c46a;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}
.dashboard-visual strong {
  display: block;
  margin-top: 8px;
  font-size: 36px;
  line-height: 1.15;
}
.dashboard-visual small {
  display: block;
  color: #cbd5e1;
  margin-top: 10px;
}

.dashboard-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.dashboard-chips b {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 999px;
  background: rgba(255, 255, 255, .1);
  color: white;
  font-size: 13px;
}

.dashboard-photo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
  min-width: 0;
}

.dashboard-photo-grid figure {
  position: relative;
  min-height: 154px;
  margin: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(16,24,40,.06);
  background: #111827;
}

.dashboard-photo-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.dashboard-photo-grid figcaption {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 5px 8px;
  border-radius: 5px;
  background: rgba(17, 24, 39, .82);
  color: white;
  font-size: 12px;
  font-weight: 750;
}

.media-credit {
  color: var(--muted);
  font-size: 11px;
  margin-top: 10px;
}

.media-credit a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  box-shadow: 0 1px 2px rgba(16,24,40,.03);
}

.stat.as-button {
  color: var(--ink);
  display: block;
  text-align: left;
  min-height: 96px;
  width: 100%;
  cursor: pointer;
}

.stat.as-button:hover {
  background: #fbfcfe;
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.stat span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  line-height: 1.12;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.stat small { display: block; color: var(--muted); margin-top: 8px; }

.ops-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 14px;
}

.panel h2 {
  font-size: 16px;
  margin-bottom: 12px;
  color: #1d2939;
}
.priority-list { margin: 0; padding-left: 18px; display: grid; gap: 7px; }
.priority-list strong { color: var(--primary); }

.toolbar-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(16,24,40,.03);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.toolbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.table-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(16,24,40,.06);
}

table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 940px;
}

th, td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

tbody tr:hover td { background: #f5f8fc; }
tbody tr:last-child td { border-bottom: 0; }

th {
  background: #e9eef5;
  position: sticky;
  top: 0;
  z-index: 1;
  color: #2b3442;
  box-shadow: 0 1px 0 rgba(17, 24, 39, .06);
}

.select-column {
  width: 40px;
  min-width: 40px;
  text-align: center;
}

.select-column input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--primary);
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 24px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.sort-button:hover { background: transparent; color: var(--primary); }
.sort-button span {
  margin-left: auto;
  color: #667085;
  font-size: 11px;
  white-space: nowrap;
}

.filter-row th {
  top: 39px;
  background: #f6f8fb;
  padding: 6px 8px;
}

.filter-row input,
.filter-row select {
  width: 100%;
  min-width: 104px;
  min-height: 32px;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  font-size: 12px;
}

.filter-row input::placeholder { color: #98a2b3; }
tr.selected td { background: #edf6ff; }
tr.yellow td { background: var(--yellow); }
tr.green td { background: var(--green); }
tr.orange td { background: var(--orange); }
tr.red td { background: var(--red); }

.badge {
  border-radius: 999px;
  padding: 3px 8px;
  border: 1px solid #c7d1df;
  background: #f8fafc;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  color: #233044;
  font-weight: 700;
  font-size: 12px;
}

.row-actions {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(760px, calc(100vw - 24px));
  box-shadow: 0 24px 80px rgba(0,0,0,.22);
}

dialog::backdrop { background: rgba(16,24,40,.45); }
dialog header, dialog footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

dialog footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

#modalBody {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.field-full { grid-column: 1 / -1; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 13px; }

.check-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.check-field input {
  width: auto;
  min-height: auto;
}

.import-zone { display: grid; gap: 12px; max-width: 780px; }
pre { background: #101828; color: white; padding: 14px; border-radius: 8px; overflow: auto; }

@media (max-width: 1060px) {
  body { grid-template-columns: 236px minmax(0, 1fr); }
  .toolbar { grid-template-columns: 1fr; }
  .toolbar-actions { justify-content: flex-start; }
}

@media (max-width: 760px) {
  body { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  nav {
    grid-auto-flow: column;
    grid-auto-columns: minmax(180px, 1fr);
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .topbar { position: static; align-items: flex-start; flex-direction: column; }
  .topbar, #view { padding-left: 16px; padding-right: 16px; }
  .login-screen { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .dashboard-visual { grid-template-columns: 1fr; }
  .dashboard-copy { padding: 24px; }
  .dashboard-visual strong { font-size: 30px; }
  .dashboard-photo-grid { grid-template-columns: 1fr; }
  .dashboard-photo-grid figure { min-height: 126px; }
  .actions, .toolbar-actions { width: 100%; }
  .actions > *, .toolbar-actions > * { flex: 1 1 150px; }
  .ops-grid { grid-template-columns: 1fr; }
  #modalBody { grid-template-columns: 1fr; }
}
