/* ANKA Administration Panel — thème sombre turquoise / anthracite */
:root {
  --bg: #15181c;
  --bg-2: #1b1f24;
  --panel: #22272e;
  --panel-2: #2a3038;
  --line: #343b45;
  --line-2: #3f4753;
  --text: #e6eaef;
  --muted: #98a2ae;
  --faint: #6b7480;
  --accent: #1ec8c2;
  --accent-2: #17a5a0;
  --accent-soft: rgba(30, 200, 194, .14);
  --ok: #3ccf7a;
  --warn: #f0b429;
  --danger: #ef5b5b;
  --info: #4aa3ff;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  --sidebar: 248px;
  --sidebar-mini: 68px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .6em; font-weight: 600; letter-spacing: .2px; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }

/* ---------- structure ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: 0 0 var(--sidebar); background: var(--bg-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; transition: width .2s, flex-basis .2s;
  overflow: hidden; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-weight: 700; font-size: 16px; }
.brand-logo { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #0f6f6c); display: grid; place-items: center; color: #08201f; font-weight: 800; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 10px 20px; }
.nav-section { color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; padding: 14px 10px 6px; white-space: nowrap; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; color: var(--muted); white-space: nowrap;
}
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: 0 0 18px; }
body.sidebar-collapsed .sidebar { width: var(--sidebar-mini); flex-basis: var(--sidebar-mini); }
body.sidebar-collapsed .nav-section, body.sidebar-collapsed .nav a span, body.sidebar-collapsed .brand-text { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; display: flex; align-items: center; gap: 14px; padding: 0 22px; border-bottom: 1px solid var(--line);
  background: rgba(21, 24, 28, .85); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 10;
}
.topbar .title { font-weight: 600; font-size: 15px; }
.icon-btn { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.icon-btn svg { width: 18px; height: 18px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.user-chip { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; color: var(--accent); font-weight: 700; }
.content { padding: 22px; max-width: 1600px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 2px 0 0; color: var(--muted); }

/* ---------- composants ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; position: relative; overflow: hidden; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .sub { color: var(--faint); font-size: 12px; margin-top: 2px; }
.stat::after { content: ""; position: absolute; right: -20px; top: -20px; width: 80px; height: 80px; border-radius: 50%; background: var(--accent-soft); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { color: var(--ok); background: rgba(60, 207, 122, .1); border-color: rgba(60, 207, 122, .3); }
.badge.warn { color: var(--warn); background: rgba(240, 180, 41, .1); border-color: rgba(240, 180, 41, .3); }
.badge.danger { color: var(--danger); background: rgba(239, 91, 91, .1); border-color: rgba(239, 91, 91, .3); }
.badge.info { color: var(--info); background: rgba(74, 163, 255, .1); border-color: rgba(74, 163, 255, .3); }
.badge.accent { color: var(--accent); background: var(--accent-soft); border-color: rgba(30, 200, 194, .35); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(60, 207, 122, .18); }
.dot.danger { background: var(--danger); box-shadow: 0 0 0 3px rgba(239, 91, 91, .18); }
.dot.warn { background: var(--warn); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06201f; }
.btn.primary:hover { background: #31dcd6; }
.btn.danger { background: rgba(239, 91, 91, .12); border-color: rgba(239, 91, 91, .5); color: #ff8a8a; }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.warn { background: rgba(240, 180, 41, .12); border-color: rgba(240, 180, 41, .5); color: var(--warn); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn svg { width: 16px; height: 16px; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid var(--text); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }

input, select, textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line-2); color: var(--text); border-radius: 8px; padding: 8px 11px; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
label { display: block; color: var(--muted); font-size: 12.5px; margin-bottom: 5px; font-weight: 600; }
.field { margin-bottom: 12px; }
.field small { color: var(--faint); display: block; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 400; margin: 0; }
.input-group { display: flex; gap: 8px; }
.input-group input { flex: 1; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; background: var(--bg-2); position: sticky; top: 0; }
tbody tr:hover { background: rgba(255, 255, 255, .02); }
tbody tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
.empty { text-align: center; color: var(--faint); padding: 26px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--accent); border-color: var(--accent); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.progress { height: 8px; background: var(--bg-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); width: 0; transition: width .4s; }
.progress.warn > span { background: var(--warn); }
.progress.danger > span { background: var(--danger); }

.console {
  background: #0d0f12; border: 1px solid var(--line); border-radius: 8px; padding: 12px; color: #cfd8e3; max-height: 460px; overflow: auto;
  white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: 12.5px; line-height: 1.45;
}
.console .l-err { color: #ff7b7b; }
.console .l-warn { color: #f5c860; }
.console .l-ok { color: #5fe39a; }
.console .l-step { color: var(--accent); font-weight: 700; }

.alert { padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); margin-bottom: 14px; }
.alert.warn { border-color: rgba(240, 180, 41, .45); background: rgba(240, 180, 41, .08); }
.alert.danger { border-color: rgba(239, 91, 91, .45); background: rgba(239, 91, 91, .08); }
.alert.info { border-color: rgba(74, 163, 255, .45); background: rgba(74, 163, 255, .08); }
.alert.ok { border-color: rgba(60, 207, 122, .45); background: rgba(60, 207, 122, .08); }

/* instances */
.instances { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.instance { background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.instance.down { border-color: rgba(239, 91, 91, .35); }
.instance.disabled { opacity: .55; }
.instance .name { font-weight: 600; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.instance .meta { color: var(--muted); font-size: 12px; margin-top: 6px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.instance .acts { margin-top: 10px; display: flex; gap: 6px; }

/* items */
.item-icon { width: 32px; height: 32px; border-radius: 6px; background: var(--bg-2); border: 1px solid var(--line); object-fit: contain; image-rendering: pixelated; flex: 0 0 32px; }
.item-cell { display: flex; align-items: center; gap: 10px; }
.attr-list { margin: 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--info); }

/* graphiques */
.chart { position: relative; width: 100%; height: 240px; }
.chart svg { width: 100%; height: 100%; display: block; }
.chart .tip { position: absolute; pointer-events: none; background: var(--panel-2); border: 1px solid var(--line-2); padding: 6px 10px; border-radius: 6px; font-size: 12px; box-shadow: var(--shadow); white-space: nowrap; transform: translate(-50%, -110%); }
.gauge { display: flex; align-items: center; gap: 14px; }
.gauge svg { width: 72px; height: 72px; flex: 0 0 72px; }
.gauge .g-val { font-size: 20px; font-weight: 700; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* calendrier */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar .dow { color: var(--faint); font-size: 12px; text-align: center; padding: 4px; }
.calendar .day { min-height: 92px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px; font-size: 12px; }
.calendar .day.other { opacity: .4; }
.calendar .day.today { border-color: var(--accent); }
.calendar .day .n { color: var(--muted); font-weight: 600; }
.calendar .ev { display: block; margin-top: 4px; padding: 2px 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.calendar .ev.task { background: rgba(74, 163, 255, .12); color: var(--info); }

/* notifications */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 1000; max-width: 420px; }
.toast { background: var(--panel-2); border: 1px solid var(--line-2); border-left: 4px solid var(--accent); border-radius: 8px; padding: 12px 14px; box-shadow: var(--shadow); animation: slidein .2s ease-out; }
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast strong { display: block; margin-bottom: 2px; }

/* fenêtres modales */
.modal-back { position: fixed; inset: 0; background: rgba(5, 7, 9, .7); display: grid; place-items: center; z-index: 900; padding: 20px; animation: fade .15s; }
.modal { background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; width: 100%; max-width: 560px; box-shadow: var(--shadow); max-height: 92vh; display: flex; flex-direction: column; }
.modal.wide { max-width: 900px; }
.modal-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* connexion */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, rgba(30, 200, 194, .12), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; padding: 0 0 18px; font-size: 18px; }
.secret-box { font-family: var(--mono); font-size: 16px; letter-spacing: 2px; background: var(--bg-2); border: 1px dashed var(--accent); padding: 10px; border-radius: 8px; text-align: center; word-break: break-all; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: auto; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s; width: var(--sidebar) !important; }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow); }
  body.sidebar-collapsed .nav-section, body.sidebar-collapsed .nav a span, body.sidebar-collapsed .brand-text { display: initial; }
  .content { padding: 14px; }
  .topbar { padding: 0 12px; }
  .hide-sm { display: none !important; }
}
@media (max-width: 560px) {
  .grid-6, .grid-4 { grid-template-columns: 1fr 1fr; }
  .calendar .day { min-height: 60px; }
}

/* espacement vertical des blocs de page */
.content > .grid, .content > .card, .content > .tabs-panel, .content > .alert { margin-top: 16px; }
.content > .page-head + * { margin-top: 0; }
.legend i.lg-accent { background: var(--accent); }
.legend i.lg-info { background: var(--info); }
.legend i.lg-warn { background: var(--warn); }
.legend i.lg-ok { background: var(--ok); }
.hist-range { width: auto; }
.w-auto { width: auto; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.small { font-size: 12.5px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { margin: 0; min-width: 160px; }
.inline-form .field.wide { flex: 1; min-width: 240px; }
.map-thumb { color: var(--muted); }

/* Compléments (pages administration, journaux, développement) */
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.perm-group { margin-top: 10px; display: grid; gap: 4px; }
.perm-group .faint { text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
table.table td.right, table.table th.right, .right { text-align: right; }
.console.tall { max-height: 640px; }
.mono { font-family: var(--mono); }
.break { word-break: break-all; }
.bin-card .kv dd { word-break: break-all; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.console.only-issues span:not(.l-err):not(.l-warn) { display: none; }
.item-icon.no-icon { background: repeating-linear-gradient(45deg, var(--bg-2), var(--bg-2) 4px, var(--line) 4px, var(--line) 5px); }
details summary { cursor: pointer; color: var(--accent); }
