/* ── Reset & base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Surfaces — navy-tinted dark to match the PatchGuard logo background */
  --bg:        #0b1322;
  --sidebar:   #111a2e;
  --card:      #17223a;
  --card2:     #1d2a47;
  --border:    #2b3a5c;
  --text:      #e6edf3;
  --muted:     #94a3bc;

  /* Brand colours pulled from the PatchGuard logo */
  --accent:    #2470e8;       /* PatchGuard blue */
  --accent-h:  #4a8cf0;       /* hover */
  --gold:      #f0a836;       /* PatchGuard amber accent */
  --gold-h:    #f5bb55;

  /* Status */
  --success:   #1f9a48;
  --success-t: #2db862;
  --warning:   #f0a836;
  --danger:    #e85046;
  --danger-bg: #3d1c1c;

  --radius:    6px;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ──────────────────────────────────────────────────────────────────── */
#topbar {
  height: 64px;
  background: #0d1117;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 14px;
  flex-shrink: 0;
}
/* Brand mark — circular icon + wordmark text. Icon PNG has a transparent
   background; the wordmark is real text so it picks up brand colours. */
.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
  color: var(--text);
  transition: opacity .15s ease;
}
.topbar-brand:hover { opacity: .85; }

.topbar-logo {
  height: 44px;
  max-height: 44px;
  width: auto;
  display: block;
  object-fit: contain;
}
.brand-text {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text);
}
.brand-guard { color: var(--gold); }

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 auto 24px auto;
}
.login-logo-img {
  height: 110px;
  max-height: 110px;
  width: auto;
  display: block;
  object-fit: contain;
  margin-bottom: 14px;
}
.login-wordmark {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text);
  line-height: 1;
}
.login-tagline {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.5px;
}
.spacer { flex: 1; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 999px; font-size: 12px;
}
.role-badge {
  font-size: 10px; text-transform: uppercase; letter-spacing: .8px;
  background: var(--accent); color: #fff;
  padding: 2px 7px; border-radius: 4px;
}
.role-badge.customer { background: var(--success-t); }

/* ── Container ──────────────────────────────────────────────────────────────── */
.page { padding: 24px 32px; max-width: 1400px; margin: 0 auto; width: 100%; }
.page h1 { font-size: 22px; margin-bottom: 4px; }
.page-subtitle { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.section { margin-bottom: 32px; }
.section h2 { font-size: 15px; margin-bottom: 12px; font-weight: 600; }

/* ── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.card-title { font-size: 13px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card2); color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 14px; border-radius: var(--radius);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.btn:hover { background: #2d333b; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover  { background: var(--accent-h); }
.btn-danger   { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover   { background: #ff6b6b; }
.btn-success  { background: var(--success-t); border-color: var(--success-t); color: #fff; }
.btn-sm       { padding: 4px 10px; font-size: 11px; }
.btn-block    { width: 100%; justify-content: center; padding: 10px; }

/* ── Form controls ──────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; color: var(--muted); font-weight: 500; }
.form-control {
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  width: 100%;
}
.form-control:focus { border-color: var(--accent); }
select.form-control { cursor: pointer; }

/* ── Login screen ───────────────────────────────────────────────────────────── */
#login-shell {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 36px 32px 28px;
  width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}

/* ── Table ──────────────────────────────────────────────────────────────────── */
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; font-size: 12px; }
th {
  background: var(--card2); color: var(--muted);
  font-weight: 600; text-transform: uppercase; letter-spacing: .5px; font-size: 11px;
  border-bottom: 1px solid var(--border);
}
td { border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

/* ── Stat tiles ─────────────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.stat-tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-tile .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-tile .value { font-size: 24px; font-weight: 700; margin-top: 4px; }

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 12px; display: flex; gap: 8px; align-items: flex-start; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
.alert-info   { background: rgba(31,111,235,.1); color: var(--accent-h); border: 1px solid var(--accent); }

/* ── Badge ─────────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; }
.badge-success { background: rgba(46,160,67,.15); color: var(--success-t); }
.badge-danger  { background: rgba(248,81,73,.15);  color: var(--danger); }
.badge-info    { background: rgba(31,111,235,.15); color: var(--accent-h); }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; font-size: 12px; min-width: 240px;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  animation: slide-in .25s ease-out;
}
.toast.success { border-left: 3px solid var(--success-t); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes slide-in { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 24px; width: 480px; max-width: 92vw;
}
.modal h2 { font-size: 17px; margin-bottom: 16px; }
.modal-footer { margin-top: 20px; display: flex; gap: 8px; justify-content: flex-end; }

/* ── Utility ────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex { display: flex; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8   { margin-top: 8px; }
.mt-12  { margin-top: 12px; }
.mt-16  { margin-top: 16px; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-sm { font-size: 12px; }
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
