/* ─────────────────────────────────────────────────────────────────────────────
   Borne Dashboard — CSS mobile-first, sobre, professionnel
   ───────────────────────────────────────────────────────────────────────────── */

:root {
  --bg:          #f0f2f5;
  --surface:     #ffffff;
  --surface-alt: #f8f9fa;
  --border:      #e2e6ea;
  --text:        #1a1d23;
  --text-muted:  #6b7280;
  --text-light:  #9ca3af;

  --accent:      #2563eb;
  --accent-dark: #1d4ed8;
  --accent-bg:   #eff6ff;

  --green:       #16a34a;
  --green-bg:    #f0fdf4;
  --orange:      #d97706;
  --orange-bg:   #fffbeb;
  --red:         #dc2626;
  --red-bg:      #fef2f2;
  --gray:        #6b7280;
  --gray-bg:     #f3f4f6;

  --nav-h:      56px;
  --radius:     10px;
  --radius-sm:  6px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ── Reset & base ─────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigation ───────────────────────────────────────────────────────────── */

.nav {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex; align-items: center;
  padding: 0 16px;
  gap: 8px;
}

.nav-brand {
  font-weight: 700; font-size: 1.05rem;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}

.nav-brand-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
}

.nav-links {
  display: flex; gap: 2px;
  list-style: none;
  margin-left: 16px;
  overflow-x: auto;
  flex: 1;
}

.nav-links a {
  display: block;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .9rem;
  font-weight: 500;
  white-space: nowrap;
}

.nav-links a:hover, .nav-links a.active {
  background: var(--accent-bg);
  color: var(--accent);
  text-decoration: none;
}

.nav-logout {
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 20px 16px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.page-subtitle {
  color: var(--text-muted);
  font-size: .9rem;
  margin-top: 2px;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.card-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
}

/* ── KPI Cards ────────────────────────────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.kpi-sub {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Device Cards (overview) ──────────────────────────────────────────────── */

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

.device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: box-shadow .15s, border-color .15s;
}

.device-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
  text-decoration: none;
}

.device-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.device-name { font-weight: 600; font-size: 1rem; }
.device-id { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }

.device-meta {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 8px;
}

/* ── Status badges ────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-online  { background: var(--green-bg);  color: var(--green);  }
.badge-warning { background: var(--orange-bg); color: var(--orange); }
.badge-offline { background: var(--gray-bg);   color: var(--gray);   }
.badge-error   { background: var(--red-bg);    color: var(--red);    }
.badge-info    { background: var(--accent-bg); color: var(--accent); }
.badge-maintenance { background: var(--orange-bg); color: var(--orange); }

/* Status commandes */
.badge-pending   { background: var(--orange-bg); color: var(--orange); }
.badge-delivered { background: var(--accent-bg); color: var(--accent); }
.badge-done      { background: var(--green-bg);  color: var(--green);  }
.badge-rejected  { background: var(--red-bg);    color: var(--red);    }
.badge-deferred  { background: var(--orange-bg); color: var(--orange); }
.badge-expired   { background: var(--gray-bg);   color: var(--gray);   }
.badge-critical  { background: var(--red-bg);    color: var(--red);    }

/* ── Level badges ─────────────────────────────────────────────────────────── */

.level-info     { color: var(--accent);  background: var(--accent-bg); }
.level-warning  { color: var(--orange);  background: var(--orange-bg); }
.level-error    { color: var(--red);     background: var(--red-bg);    }
.level-critical { color: var(--red);     background: var(--red-bg);    }
.level-debug    { color: var(--gray);    background: var(--gray-bg);   }

/* ── Tables ───────────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  min-width: 600px;
}

th {
  background: var(--surface-alt);
  text-align: left;
  padding: 10px 14px;
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-alt); }

.td-mono { font-family: "SF Mono", "Fira Code", monospace; font-size: .8rem; }
.td-muted { color: var(--text-muted); font-size: .82rem; }
.td-truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  line-height: 1;
  text-decoration: none;
  transition: opacity .15s, box-shadow .15s;
}

.btn:hover { opacity: .88; text-decoration: none; }
.btn:active { opacity: .75; }

.btn-primary  { background: var(--accent);  color: #fff; border-color: var(--accent-dark); }
.btn-danger   { background: var(--red);     color: #fff; }
.btn-warning  { background: var(--orange);  color: #fff; }
.btn-ghost    { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-sm       { padding: 5px 11px; font-size: .8rem; }
.btn-export   { background: var(--green); color: #fff; }

/* ── Forms ────────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 14px; }

label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

input[type="text"],
input[type="password"],
input[type="date"],
select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  background: var(--surface);
  color: var(--text);
  appearance: none;
  transition: border-color .15s;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ── Filters bar ──────────────────────────────────────────────────────────── */

.filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.filters .form-group { margin-bottom: 0; min-width: 140px; }
.filters select, .filters input { padding: 7px 10px; }

/* ── Actions panel ────────────────────────────────────────────────────────── */

.actions-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background .15s, border-color .15s;
}

.action-btn:hover { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.action-btn.danger:hover { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.action-btn.warn:hover { background: var(--orange-bg); border-color: var(--orange); color: var(--orange); }

/* ── Pagination ───────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 16px 0;
  flex-wrap: wrap;
}

.pagination-info { color: var(--text-muted); font-size: .85rem; }

.page-btn {
  padding: 6px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

.page-btn:hover { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); text-decoration: none; }
.page-btn.current { background: var(--accent); color: #fff; border-color: var(--accent); pointer-events: none; }
.page-btn.disabled { opacity: .4; pointer-events: none; }

/* ── Flash messages ───────────────────────────────────────────────────────── */

.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  margin-bottom: 16px;
  border: 1px solid;
}

.flash-success { background: var(--green-bg); color: var(--green); border-color: #bbf7d0; }
.flash-error   { background: var(--red-bg);   color: var(--red);   border-color: #fecaca; }
.flash-info    { background: var(--accent-bg); color: var(--accent); border-color: #bfdbfe; }

/* ── Login page ───────────────────────────────────────────────────────────── */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
}

.login-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 4px;
  text-align: center;
}

.login-sub {
  color: var(--text-muted);
  font-size: .85rem;
  text-align: center;
  margin-bottom: 24px;
}

/* ── Device info block ────────────────────────────────────────────────────── */

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.info-item { }

.info-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.info-value {
  font-size: .95rem;
  font-weight: 500;
  color: var(--text);
}

/* ── Incidents feed ───────────────────────────────────────────────────────── */

.incident-list { list-style: none; }

.incident-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.incident-item:last-child { border-bottom: none; }

.incident-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0; margin-top: 6px;
}

.incident-dot.error, .incident-dot.critical { background: var(--red); }
.incident-dot.warning { background: var(--orange); }
.incident-dot.info    { background: var(--accent); }

.incident-msg {
  font-size: .875rem;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.incident-meta {
  font-size: .75rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Auto-refresh indicator ───────────────────────────────────────────────── */

.refresh-bar {
  font-size: .78rem;
  color: var(--text-light);
  text-align: right;
  padding: 4px 0 12px;
}

/* ── Utility ──────────────────────────────────────────────────────────────── */

.text-muted { color: var(--text-muted); }
.text-small { font-size: .82rem; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.empty-state {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
  font-size: .9rem;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--gray-bg);
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 500;
}

/* ── Cockpit overview ─────────────────────────────────────────────────────── */

.cockpit-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.header-status-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* ── Status pills (inline indicators) ────────────────────────────────────── */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status-pill.online      { background: var(--green-bg);  color: var(--green);  }
.status-pill.warning     { background: var(--orange-bg); color: var(--orange); }
.status-pill.offline     { background: var(--gray-bg);   color: var(--gray);   }
.status-pill.maintenance { background: var(--orange-bg); color: var(--orange); }
.status-pill.session     { background: var(--accent-bg); color: var(--accent); }

.status-pill-sm { font-size: .7rem; padding: 3px 8px; }
.status-pill-lg { font-size: .85rem; padding: 5px 14px; }

/* ── Alerts zone ──────────────────────────────────────────────────────────── */

.alerts-zone {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.alert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid;
}

.alert-item.alert-critical { background: var(--red-bg);    color: var(--red);    border-color: #fca5a5; }
.alert-item.alert-error    { background: var(--red-bg);    color: var(--red);    border-color: #fca5a5; }
.alert-item.alert-warning  { background: var(--orange-bg); color: var(--orange); border-color: #fcd34d; }

.alert-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  line-height: 1;
}

.alert-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.alert-device {
  font-weight: 700;
  font-size: .875rem;
}

.alert-msg {
  font-size: .82rem;
  opacity: .85;
}

.alert-action {
  font-size: .8rem;
  font-weight: 600;
  text-decoration: none;
  color: inherit;
  border: 1px solid currentColor;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  flex-shrink: 0;
}

.alert-action:hover { opacity: .8; text-decoration: none; }

/* ── KPI strip ────────────────────────────────────────────────────────────── */

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.kpi-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  box-shadow: var(--shadow);
  text-align: center;
}

.kpi-tile.accent {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: #fff;
}

.kpi-tile.accent .kpi-tile-label { color: rgba(255,255,255,.75); }

.kpi-tile-value {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
}

.kpi-tile.accent .kpi-tile-value { color: #fff; }

.kpi-tile-value.good { color: var(--green); }
.kpi-tile-value.warn { color: var(--orange); }

.kpi-tile-label {
  font-size: .73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-top: 5px;
}

/* ── Section title ────────────────────────────────────────────────────────── */

.section-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

/* ── Device cockpit cards ─────────────────────────────────────────────────── */

.device-cockpit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.device-cockpit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow .15s;
}

.device-cockpit-card:hover { box-shadow: var(--shadow-md); text-decoration: none; }

.status-border-online  { border-left-color: var(--green); }
.status-border-warning { border-left-color: var(--orange); }
.status-border-offline { border-left-color: var(--gray); }

.dcc-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dcc-status-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}

.dot-online  { background: var(--green); }
.dot-warning { background: var(--orange); animation: pulse-orange 2s infinite; }
.dot-offline { background: var(--gray); }

@keyframes pulse-orange {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

.dcc-name {
  font-weight: 700;
  font-size: .95rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dcc-page {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dcc-page-label {
  font-size: .83rem;
  color: var(--text-muted);
}

.session-active-badge {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--accent-bg);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 4px;
}

.dcc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag-warn { background: var(--orange-bg); color: var(--orange); }
.tag-time { background: transparent; color: var(--text-light); border: 1px solid var(--border); }

/* ── Device hero (device detail page) ────────────────────────────────────── */

.device-hero {
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  border-top-width: 5px;
}

.status-bg-online  { border-top-color: var(--green); }
.status-bg-warning { border-top-color: var(--orange); }
.status-bg-offline { border-top-color: var(--gray); }

.device-hero-body { flex: 1; }

.device-hero-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.device-hero-id {
  font-size: .82rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: "SF Mono","Fira Code",monospace;
}

.device-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.rename-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.rename-form input {
  width: auto;
  flex: 1;
  min-width: 150px;
  max-width: 260px;
  padding: 5px 9px;
  font-size: .85rem;
}

/* ── Info grid extended ───────────────────────────────────────────────────── */

.info-item-full {
  grid-column: 1 / -1;
}

/* ── Quick actions ────────────────────────────────────────────────────────── */

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.qbtn {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  line-height: 1;
  transition: opacity .15s, box-shadow .15s;
  white-space: nowrap;
}

.qbtn:hover { opacity: .88; }

.qbtn-ok     { background: var(--green-bg);  color: var(--green);  border-color: #bbf7d0; }
.qbtn-warn   { background: var(--orange-bg); color: var(--orange); border-color: #fde68a; }
.qbtn-danger { background: var(--red-bg);    color: var(--red);    border-color: #fca5a5; }

.qbtn-ok:hover     { background: #dcfce7; }
.qbtn-warn:hover   { background: #fef3c7; }
.qbtn-danger:hover { background: #fee2e2; }

/* ── Two-column grid ──────────────────────────────────────────────────────── */

.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 0;
}

/* ── Sale feed ────────────────────────────────────────────────────────────── */

.sale-feed { list-style: none; }

.sale-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.sale-item:last-child { border-bottom: none; }

.sale-item-left { flex: 1; min-width: 0; }

.sale-label {
  font-size: .875rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sale-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.sale-amount {
  font-size: .95rem;
  font-weight: 700;
}

.sale-status {
  display: flex;
  align-items: center;
  gap: 6px;
}

.delivery-icon {
  font-size: .9rem;
  font-weight: 700;
}

.delivery-icon.done    { color: var(--green); }
.delivery-icon.pending { color: var(--orange); }

/* ── Alerts list (alerts page) ─────────────────────────────────────────────── */

.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.alert-row-critical { border-left-color: var(--red); }
.alert-row-error    { border-left-color: var(--orange); }
.alert-row-resolved { border-left-color: var(--green); opacity: .75; }

.alert-row-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.alert-row-type {
  font-weight: 700;
  font-size: .9rem;
}

.alert-row-device {
  font-size: .82rem;
}

.alert-row-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .nav-links { gap: 0; margin-left: 8px; }
  .nav-links a { padding: 6px 9px; font-size: .82rem; }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }

  .device-grid { grid-template-columns: 1fr; }
  .device-cockpit-grid { grid-template-columns: 1fr; }

  .two-col-grid { grid-template-columns: 1fr; }

  .filters { flex-direction: column; }
  .filters .form-group { min-width: 100%; }

  .page-header { flex-direction: column; }
  .cockpit-header { flex-direction: column; }

  .info-grid { grid-template-columns: repeat(2, 1fr); }

  .container { padding: 14px 12px; }
  .card { padding: 14px; }

  .kpi-value { font-size: 1.3rem; }
  .kpi-tile-value { font-size: 1.4rem; }

  .device-hero { padding: 16px; }
  .device-hero-name { font-size: 1.2rem; }

  .rename-form input { max-width: 100%; }
  .rename-form { flex-direction: column; align-items: stretch; }

  .quick-actions .qbtn { flex: 1; min-width: calc(50% - 4px); text-align: center; }
}

@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi-strip { grid-template-columns: 1fr 1fr; }
  .nav-links a { padding: 5px 7px; font-size: .78rem; }
}
