/* ===========================================================
   Gestion d'outillage - feuille de style
   =========================================================== */
:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #f59e0b;
  --brand-dark: #b45309;
  --dark: #0f172a;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #0ea5e9;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: #2563eb; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
.hidden { display: none !important; }

/* ------------------------------------------------- connexion */
.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 55%, #334155 100%);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 18px;
  padding: 32px;
  box-shadow: 0 24px 60px rgba(2, 6, 23, .45);
}
.login-card .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-card .logo .mark {
  width: 46px; height: 46px; border-radius: 12px; background: var(--brand);
  display: grid; place-items: center; font-size: 24px;
}
.login-card h1 { font-size: 20px; }
.login-card .sub { color: var(--muted); font-size: 13px; }

/* ------------------------------------------------- structure */
.app { display: none; min-height: 100%; }
.app.ready { display: block; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--dark); color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
}
.topbar .mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--brand);
  display: grid; place-items: center; font-size: 18px; flex: none;
}
.topbar .title { font-weight: 700; font-size: 15px; line-height: 1.1; }
.topbar .company { font-size: 11px; color: #94a3b8; }
.topbar .spacer { flex: 1; }
.topbar .who { text-align: right; font-size: 12px; line-height: 1.2; }
.topbar .who strong { display: block; font-size: 13px; }
.topbar .who span { color: #94a3b8; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #334155; color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
  cursor: pointer; border: 0;
}

.layout { display: flex; align-items: flex-start; }
.sidebar {
  width: 232px; flex: none; padding: 16px 12px; position: sticky; top: 54px;
  height: calc(100vh - 54px); overflow: auto;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: #334155; text-decoration: none; font-weight: 500; font-size: 14px;
}
.sidebar a:hover { background: #e2e8f0; }
.sidebar a.active { background: var(--dark); color: #fff; }
.sidebar a .ico { width: 20px; text-align: center; }
.sidebar .pill {
  margin-left: auto; background: var(--brand); color: #111827; font-size: 11px;
  font-weight: 800; border-radius: 999px; padding: 1px 7px;
}
.sidebar a.active .pill { background: var(--brand); }

main { flex: 1; padding: 20px 24px 80px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h2 { font-size: 22px; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.bottom-nav { display: none; }

/* ------------------------------------------------- composants */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head {
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card-head h3 { font-size: 15px; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 16px; }

.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 26px; font-weight: 800; margin-top: 4px; }
.stat.accent { border-left: 4px solid var(--brand); }
.stat.danger { border-left: 4px solid var(--danger); }
.stat.ok { border-left: 4px solid var(--ok); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--dark); color: #fff; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: #111827; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: #f8fafc; filter: none; }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #334155; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 10px;
  background: #fff; outline: none;
}
.input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); }
textarea { min-height: 84px; resize: vertical; }
.row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.row-3 { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); }
.checkbox { display: flex; gap: 9px; align-items: flex-start; font-size: 14px; margin-bottom: 8px; }
.checkbox input { margin-top: 3px; width: 17px; height: 17px; flex: none; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input, .toolbar select { width: auto; min-width: 150px; flex: 1 1 170px; }

table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.list td { padding: 11px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: #f8fafc; }
.table-wrap { overflow-x: auto; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: #e2e8f0; color: #334155; white-space: nowrap;
}
.badge.ok { background: #d1fae5; color: #065f46; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.danger { background: #fee2e2; color: #991b1b; }
.badge.info { background: #e0f2fe; color: #075985; }
.badge.muted { background: #e2e8f0; color: #475569; }

.thumb {
  width: 44px; height: 44px; border-radius: 9px; object-fit: cover; background: #e2e8f0;
  display: grid; place-items: center; color: #94a3b8; flex: none;
}
.cell-main { display: flex; align-items: center; gap: 10px; }
.cell-main .t { font-weight: 600; }
.cell-main .s { font-size: 12px; color: var(--muted); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; }

/* ------------------------------------------------- modal */
.modal-back {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 60;
  display: flex; align-items: flex-start; justify-content: center; padding: 24px;
  overflow: auto;
}
.modal {
  background: var(--card); border-radius: 16px; width: 100%; max-width: 640px;
  box-shadow: 0 30px 70px rgba(2, 6, 23, .4); margin: auto;
}
.modal.wide { max-width: 900px; }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; position: sticky; top: 0; background: #fff;
  border-radius: 16px 16px 0 0; z-index: 2;
}
.modal-head h3 { font-size: 17px; }
.modal-head .x {
  margin-left: auto; border: 0; background: #f1f5f9; width: 32px; height: 32px;
  border-radius: 8px; cursor: pointer; font-size: 17px; color: #475569;
}
.modal-body { padding: 20px; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px;
  justify-content: flex-end; position: sticky; bottom: 0; background: #fff; border-radius: 0 0 16px 16px;
}

/* ------------------------------------------------- divers */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--dark); color: #fff; padding: 12px 16px; border-radius: 10px;
  box-shadow: var(--shadow); max-width: 340px; font-size: 14px;
}
.toast.error { background: var(--danger); }
.toast.ok { background: #047857; }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

.sig-pad {
  border: 2px dashed #cbd5e1; border-radius: 12px; background: #fff;
  touch-action: none; width: 100%; height: 190px; display: block;
}
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; font-size: 14px;
}
.file-item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.perm-group { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.perm-group h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.link-box {
  display: flex; gap: 8px; align-items: center; background: #f8fafc; border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; word-break: break-all;
}
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--line); position: relative; font-size: 14px; }
.timeline li::before {
  content: ''; position: absolute; left: -6px; top: 16px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--brand);
}
.timeline .when { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------- mobile */
@media (max-width: 860px) {
  .sidebar { display: none; }
  main { padding: 16px 14px 88px; }
  .row, .row-3 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .page-head h2 { font-size: 19px; }
  .modal-back { padding: 0; }
  .modal { border-radius: 16px 16px 0 0; max-width: none; margin: auto 0 0; min-height: 92vh; }
  .modal-head { border-radius: 16px 16px 0 0; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    flex: 1; text-align: center; text-decoration: none; color: #64748b; font-size: 10.5px;
    padding: 6px 2px; border-radius: 10px; position: relative;
  }
  .bottom-nav a .ico { display: block; font-size: 19px; line-height: 1.3; }
  .bottom-nav a.active { color: var(--brand-dark); background: #fff7ed; }
  .bottom-nav .pill {
    position: absolute; top: 2px; right: 22%; background: var(--danger); color: #fff;
    font-size: 10px; border-radius: 999px; padding: 0 5px; font-weight: 700;
  }
  table.list.responsive thead { display: none; }
  table.list.responsive tbody tr {
    display: block; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; padding: 6px 4px;
  }
  table.list.responsive td { display: flex; gap: 10px; border: 0; padding: 6px 10px; }
  table.list.responsive td::before {
    content: attr(data-label); color: var(--muted); font-size: 12px; min-width: 96px; flex: none;
  }
  table.list.responsive td.no-label::before { content: ''; min-width: 0; }
}

@media print {
  .topbar, .sidebar, .bottom-nav, .page-head .actions { display: none !important; }
  main { padding: 0; }
  .card { box-shadow: none; border: 0; }
}
