:root {
  --bg: #12151a;
  --panel: #1b1f26;
  --panel-alt: #21262e;
  --border: #2a2f38;
  --text: #e8eaed;
  --text-dim: #9aa1ac;
  --accent: #d9a441;
  --accent-dim: #8a6a2c;
  --success: #4caf7d;
  --danger: #e5484d;

  --font-ui: "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Code", "Consolas", "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
}

h1, h2 { font-weight: 600; margin: 0; }

button {
  font-family: inherit;
  cursor: pointer;
}

input {
  font-family: inherit;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 3px;
  padding: 8px 10px;
  font-size: 14px;
}
input:focus {
  outline: 2px solid var(--accent-dim);
  outline-offset: 1px;
}

/* ---------- Écran de connexion ---------- */
.login-screen {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-panel {
  width: 340px;
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.login-mark {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #1a1400;
  font-family: var(--font-mono);
  font-weight: 700;
  border-radius: 3px;
  margin-bottom: 16px;
}
.login-panel h1 {
  font-size: 20px;
  margin-bottom: 6px;
}
.login-sub {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 20px;
  line-height: 1.5;
}
.login-panel form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.login-panel label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
}
.login-panel button {
  margin-top: 18px;
  background: var(--accent);
  border: none;
  color: #1a1400;
  font-weight: 600;
  padding: 10px;
  border-radius: 3px;
}
.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
}

/* ---------- Application ---------- */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: 220px 1fr;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}
.sidebar-mark {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #1a1400;
  font-family: var(--font-mono);
  font-weight: 700;
  border-radius: 3px;
  margin-bottom: 24px;
}
.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nav-item {
  background: none;
  border: none;
  color: var(--text-dim);
  text-align: left;
  padding: 9px 10px;
  border-radius: 3px;
  font-size: 14px;
  border-left: 2px solid transparent;
}
.nav-item:hover { color: var(--text); background: var(--panel-alt); }
.nav-item.active {
  color: var(--text);
  border-left: 2px solid var(--accent);
  background: var(--panel-alt);
}
.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.whoami {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.whoami .role-tag {
  display: inline-block;
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  padding: 1px 5px;
  border-radius: 2px;
}
.link-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  padding: 0;
  text-decoration: underline;
}
.link-btn:hover { color: var(--text); }

.content {
  padding: 32px 40px;
  overflow-y: auto;
}
.view-header { margin-bottom: 20px; }
.view-header p {
  color: var(--text-dim);
  font-size: 13px;
  margin: 6px 0 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 20px;
}
.form-panel { padding: 20px; }

table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody td.mono, .mono { font-family: var(--font-mono); font-size: 13px; }

.ticket-input {
  width: 120px;
  padding: 6px 8px;
  font-size: 13px;
}

.btn-primary {
  background: var(--accent);
  border: none;
  color: #1a1400;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 3px;
  font-size: 13px;
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 12px;
  border-radius: 3px;
  font-size: 13px;
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-dim); }

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 1px;
  margin-right: 6px;
}
.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--text-dim); }

/* ---------- Formulaire ajout poste ---------- */
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.field-row label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 5px;
}
.field-row input { width: 100%; }

.token-box {
  margin-top: 16px;
  padding: 14px;
  background: var(--panel-alt);
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
}
.token-box p {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-dim);
}
.token-box code {
  display: block;
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
  color: var(--accent);
}

/* ---------- Modal de résultat ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-panel {
  width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 24px;
}
.modal-status {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.modal-label {
  font-size: 11px;
  color: var(--text-dim);
  margin: 14px 0 2px;
}
.modal-value {
  font-size: 14px;
  margin: 0;
}
.modal-password {
  font-family: var(--font-mono);
  font-size: 17px;
  color: var(--accent);
  letter-spacing: 0.5px;
  padding: 8px 10px;
  background: var(--panel-alt);
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
  margin-top: 4px;
  word-break: break-all;
}
.modal-close {
  margin-top: 20px;
  width: 100%;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px;
  border-radius: 3px;
}

[hidden] { display: none !important; }
