/* BauProof Lizenzserver — Admin UI
   Self-contained, no external assets (CSP-safe). System fonts only. */

:root {
  --bg: #eef2f7;
  --bg-grad-1: #f4f7fb;
  --bg-grad-2: #e6ecf4;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --border: #dbe2ec;
  --border-strong: #c6d0de;
  --text: #1b2733;
  --text-muted: #64748b;
  --brand: #1f4e79;
  --brand-600: #1a4468;
  --brand-700: #143451;
  --brand-accent: #2e7dd1;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --danger-border: #fecdca;
  --success: #067647;
  --success-bg: #ecfdf3;
  --success-border: #abefc6;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --warn-border: #fedf89;
  --gray-badge-bg: #eef1f5;
  --gray-badge-text: #475467;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08), 0 2px 6px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, #eaf1fa, transparent 55%),
    var(--bg);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Brand header ---------- */
.brand {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-700) 100%);
  color: #fff;
  box-shadow: var(--shadow-md);
}
.brand-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  display: grid;
  place-items: center;
  font-size: 20px;
  color: #cfe4ff;
  flex: none;
}
.brand-titles h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: 0.2px;
}
.brand-sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.72);
}
.brand-spacer { flex: 1; }
.session-box {
  display: flex;
  align-items: center;
  gap: 12px;
}
.session-email {
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.92);
}
.session-role {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

/* ---------- Layout ---------- */
.main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px;
}
.view { animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}
.card-title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 640;
}
.muted { color: var(--text-muted); font-size: 13.5px; margin: 0 0 16px; }

/* ---------- Login ---------- */
.login-view {
  display: flex;
  justify-content: center;
  padding-top: 6vh;
}
.login-card {
  width: 100%;
  max-width: 400px;
}

/* ---------- Dashboard grid ---------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(340px, 400px) 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 960px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
textarea { resize: vertical; }
input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(46, 125, 209, 0.15);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%2364748b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
}

.fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px 4px;
  margin: 0 0 14px;
  background: var(--surface-2);
}
.fieldset legend {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.limits-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.field-inline { margin-bottom: 10px; }

.features-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  padding-bottom: 8px;
}
.feature-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 2px;
}
.feature-check input { width: auto; margin: 0; accent-color: var(--brand-accent); }

.subpanel {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px 2px;
  margin-bottom: 14px;
  background: var(--surface-2);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s, opacity 0.12s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-600); }
.btn-secondary { background: var(--brand-accent); color: #fff; }
.btn-secondary:hover:not(:disabled) { background: #2670bd; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.brand .btn-ghost { color: #fff; border-color: rgba(255,255,255,0.4); }
.brand .btn-ghost:hover { background: rgba(255,255,255,0.12); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); }

/* ---------- Messages ---------- */
.error-msg {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  margin-bottom: 12px;
}
.result-panel {
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
}
.result-panel h3 { margin: 0 0 8px; font-size: 15px; color: var(--success); }
.result-panel code {
  font-family: var(--mono);
  font-size: 13.5px;
  background: rgba(6, 118, 71, 0.08);
  padding: 2px 6px;
  border-radius: 5px;
}

.toast {
  position: sticky;
  top: 12px;
  z-index: 30;
  margin-bottom: 16px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow-md);
}
.toast.toast-success { background: var(--success-bg); border: 1px solid var(--success-border); color: var(--success); }
.toast.toast-error { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger); }
.toast.toast-info { background: #eff8ff; border: 1px solid #b2ddff; color: #175cd3; }

/* ---------- License list ---------- */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.list-tools { display: flex; gap: 8px; align-items: center; }
.list-tools input[type="search"] { width: 180px; }

.table-scroll { overflow-x: auto; }
.license-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.license-table th,
.license-table td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.license-table th {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: var(--surface-2);
  position: sticky;
  top: 0;
}
.license-table tbody tr:hover { background: var(--surface-2); }
.license-table code {
  font-family: var(--mono);
  font-size: 13px;
}
.col-actions { text-align: right; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.2px;
}
.badge-active { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-revoked { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-superseded { background: var(--gray-badge-bg); color: var(--gray-badge-text); border: 1px solid var(--border-strong); }
.badge-expired { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); }

.expires-warn { color: var(--warn); font-weight: 600; }
.expires-past { color: var(--danger); font-weight: 600; }

.empty-state {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}
.modal-body-text { color: var(--text-muted); font-size: 14px; margin-bottom: 12px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* ---------- Loading ---------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--border-strong);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

[hidden] { display: none !important; }
