/* Panel Firmowy — panel.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-bg:   #0f1623;
  --sidebar-w:    220px;
  --accent:       #3b82f6;
  --accent-h:     #2563eb;
  --text:         #1e293b;
  --text-m:       #64748b;
  --border:       #e2e8f0;
  --bg:           #f8fafc;
  --white:        #ffffff;
  --danger:       #ef4444;
  --success:      #22c55e;
  --warning:      #f59e0b;
  --radius:       6px;
  --shadow:       0 1px 3px rgba(0,0,0,.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

/* ── Layout ── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #94a3b8;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}

.sidebar-brand {
  padding: 20px 16px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -.3px;
}

.brand-icon { color: var(--accent); font-size: 20px; }

.sidebar-nav { list-style: none; flex: 1; padding: 10px 0; overflow-y: auto; }

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  color: #94a3b8;
  text-decoration: none;
  border-radius: 4px;
  margin: 1px 8px;
  transition: background .12s, color .12s;
  font-size: 13.5px;
}

.sidebar-nav li a:hover { background: rgba(255,255,255,.06); color: #e2e8f0; }
.sidebar-nav li a.active { background: var(--accent); color: #fff; }

.nav-section {
  padding: 14px 16px 4px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: #475569;
}

.nav-icon { font-size: 15px; width: 18px; text-align: center; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.sidebar-user { margin-bottom: 8px; }
.user-name { color: #e2e8f0; font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: #64748b; text-transform: uppercase; letter-spacing: .05em; }

.password-link {
  display: block;
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: rgba(59,130,246,.12);
  border: 1px solid rgba(59,130,246,.32);
  border-radius: var(--radius);
  color: #bfdbfe;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.password-link:hover,
.password-link.active {
  background: rgba(59,130,246,.22);
  color: #eff6ff;
}

.btn-logout {
  width: 100%;
  padding: 7px;
  background: rgba(255,255,255,.06);
  color: #94a3b8;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: background .12s;
}
.btn-logout:hover { background: rgba(255,255,255,.12); color: #e2e8f0; }

/* ── Main content ── */
.main { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; }
.content { max-width: 1200px; padding: 32px; }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 21px; font-weight: 700; }

/* ── Alerts ── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13.5px;
  border: 1px solid transparent;
}
.alert-success { background: #f0fdf4; border-color: #86efac; color: #15803d; }
.alert-error   { background: #fef2f2; border-color: #fca5a5; color: #b91c1c; }
.alert-warning { background: #fffbeb; border-color: #fcd34d; color: #b45309; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 15px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s, opacity .12s;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:disabled, .btn-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); color: #fff; }
.btn-secondary { background: var(--white); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-success   { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Tables ── */
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.table th, .table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table th {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-m);
  background: #f8fafc;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.table-sm th, .table-sm td { padding: 7px 12px; }
.table-sm { font-size: 13px; }

.row-inactive td { opacity: .55; }
.actions { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.nowrap { white-space: nowrap; }

code {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  background: #f1f5f9;
  padding: 2px 5px;
  border-radius: 3px;
}

code.path {
  font-size: 11px;
  max-width: 220px;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #e2e8f0;
  color: var(--text-m);
}
.badge-admin        { background: #ede9fe; color: #6d28d9; }
.badge-module_admin { background: #dbeafe; color: #1d4ed8; }
.badge-operator     { background: #dcfce7; color: #15803d; }
.badge-viewer       { background: #f1f5f9; color: #475569; }
.badge-warning      { background: #fef3c7; color: #92400e; }

/* ── Status dots ── */
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  flex-shrink: 0;
}
.dot-online   { background: var(--success); }
.dot-offline  { background: #cbd5e1; }
.dot-pending  { background: var(--warning); }
.dot-approved { background: var(--success); }
.dot-rejected { background: var(--danger); }

/* ── Module grid ── */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}

.module-card {
  background: var(--white);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 11px;
  transition: box-shadow .18s;
}
.module-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.1); }
.module-card.offline { opacity: .7; }

.module-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.module-name { font-size: 16px; font-weight: 700; color: var(--text); }

.module-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill-online   { background: #dcfce7; color: #15803d; }
.pill-offline  { background: #f1f5f9; color: #64748b; }

.module-desc { color: var(--text-m); font-size: 13px; flex: 1; }
.module-actions { margin-top: auto; }

/* ── Two-col layout ── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.two-col h2 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }

@media (max-width: 800px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ── Section headings ── */
.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-m);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 10px;
  margin-top: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

/* ── Forms ── */
.form-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  max-width: 540px;
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  transition: border-color .12s, box-shadow .12s;
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.form-group input:disabled { background: var(--bg); color: var(--text-m); }
.form-group textarea { resize: vertical; min-height: 80px; }

.form-hint { font-size: 12px; color: var(--text-m); margin-top: 3px; }

.form-check label {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-weight: 400;
}

.form-actions {
  display: flex;
  gap: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* ── Empty states ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-m);
}
.empty-note { color: var(--text-m); font-size: 13px; padding: 12px 0; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  color: var(--text-m);
  font-size: 13px;
}

/* ── Browser auth cards ── */
.browser-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  justify-content: space-between;
}

.browser-info { flex: 1; min-width: 0; }
.browser-hash { font-family: 'Consolas', monospace; font-size: 12px; color: var(--text-m); }
.browser-meta { font-size: 12px; color: var(--text-m); margin-top: 2px; }
.browser-actions { display: flex; gap: 6px; flex-shrink: 0; }

.browser-card.pending  { border-left: 3px solid var(--warning); }
.browser-card.approved { border-left: 3px solid var(--success); }
.browser-card.rejected { border-left: 3px solid var(--danger); }

/* ── Login page ── */
body.login-page {
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-container { width: 100%; max-width: 380px; padding: 20px; }

.login-box {
  background: var(--white);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
}

.login-brand {
  text-align: center;
  font-size: 21px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.login-brand .brand-icon { color: var(--accent); }
.login-form .form-group { margin-bottom: 15px; }

.password-card {
  border-top: 3px solid var(--accent);
}

.password-generator {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.permission-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.permission-manifest {
  color: var(--text-m);
  font-size: 13px;
  line-height: 1.7;
  min-width: 0;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.permission-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.permission-option {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px;
  background: #fff;
}

.permission-option input { margin-top: 3px; }
.permission-option span { display: grid; gap: 2px; min-width: 0; }
.permission-option code { width: fit-content; }
.permission-option small { color: var(--text-m); font-size: 12px; }

.manual-manifest {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.manual-manifest summary {
  cursor: pointer;
  font-weight: 600;
}

.manual-manifest textarea {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  resize: vertical;
}
