/* =============================================
   Fenniq Admin Portal – Styles
   ============================================= */

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

:root {
  --accent:      #8B0000;
  --accent-dark: #6B0000;
  --sidebar-bg:  #111827;

  --bg:          #F4F6F9;
  --surface:     #FFFFFF;
  --border:      #E8EAED;
  --text-1:      #111827;
  --text-2:      #6B7280;
  --text-3:      #9CA3AF;

  --green:       #10B981;
  --green-bg:    #ECFDF5;
  --green-text:  #065F46;

  --orange:      #F59E0B;
  --orange-bg:   #FFFBEB;
  --orange-text: #92400E;

  --red:         #EF4444;
  --red-bg:      #FEF2F2;
  --red-text:    #991B1B;

  --blue:        #3B82F6;
  --blue-bg:     #EFF6FF;
  --blue-text:   #1D4ED8;

  --gray-bg:     #F3F4F6;
  --gray-text:   #374151;

  --radius:      12px;
  --radius-sm:   8px;
  --sidebar-w:   240px;

  --shadow-sm:   0 1px 2px rgba(0,0,0,0.05);
  --shadow:      0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:   0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg:   0 20px 60px rgba(0,0,0,0.16);
}

html, body { height: 100%; }

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text-1);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a    { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, select, textarea { font-family: inherit; }


/* ─── Screens ──────────────────────────────── */

.screen { display: none; }

#screen-login.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

#screen-app.active {
  display: flex;
  min-height: 100vh;
}


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

.login-wrap {
  background: var(--surface);
  border-radius: 18px;
  padding: 52px 48px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.3s ease;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 36px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: #fff;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.brand-logo.sm { width: 30px; height: 30px; font-size: 11px; border-radius: 7px; }

.brand-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.2px;
}

.login-title {
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-1);
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-2);
  margin-bottom: 28px;
}

.login-error {
  background: var(--red-bg);
  color: var(--red-text);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}

.login-wrap .form-group { margin-bottom: 16px; }
.login-wrap label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }


/* ─── Sidebar ──────────────────────────────── */

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header .brand-logo { background: var(--accent); }
.sidebar-header .brand-name { color: #fff; font-size: 15px; }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}

.nav-item:hover  { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.9); }
.nav-item.active { background: rgba(139,0,0,0.55); color: #fff; }

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.user-details   { flex: 1; min-width: 0; }
.user-name  { display: block; font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { display: block; font-size: 11px; color: rgba(255,255,255,0.45); }

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: rgba(255,255,255,0.45);
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.btn-logout:hover { color: #fff; background: rgba(255,255,255,0.08); }


/* ─── Main Content ─────────────────────────── */

.main-content {
  flex: 1;
  min-width: 0;
  padding: 32px 36px;
  overflow-y: auto;
}


/* ─── Views ────────────────────────────────── */

.view { display: none; }
.view.active { display: block; }


/* ─── Page Header ──────────────────────────── */

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

.page-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-1);
}

.page-sub {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 2px;
}


/* ─── KPI Grid ─────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

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

.kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 22px 22px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 18px;
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon svg { width: 22px; height: 22px; }

.kpi-accent { background: #fdf2f2; color: var(--accent); }
.kpi-blue   { background: var(--blue-bg);   color: var(--blue);   }
.kpi-green  { background: var(--green-bg);  color: var(--green);  }
.kpi-orange { background: var(--orange-bg); color: var(--orange); }

.kpi-body  { display: flex; flex-direction: column; }

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.1;
  color: var(--text-1);
}


/* ─── Dashboard two-column grid ─────────────── */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}


/* ─── Card ─────────────────────────────────── */

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title { font-size: 15px; font-weight: 600; color: var(--text-1); }


/* ─── Table ────────────────────────────────── */

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table thead th {
  padding: 11px 20px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #FAFAFA;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #FAFAFA; }

.data-table tbody td {
  padding: 13px 20px;
  font-size: 14px;
  color: var(--text-1);
  vertical-align: middle;
}

.data-table tfoot td {
  padding: 13px 20px;
  font-size: 14px;
  color: var(--text-1);
  vertical-align: middle;
  background: #FAFAFA;
  border-top: 2px solid var(--border);
}

.data-table td.dim { color: var(--text-2); }

.empty-row td {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-3);
  font-size: 14px;
}

.customer-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cust-avatar {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.cust-name { font-weight: 500; }


/* ─── Badge ────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-green  { background: var(--green-bg);  color: var(--green-text);  }
.badge-blue   { background: var(--blue-bg);   color: var(--blue-text);   }
.badge-orange { background: var(--orange-bg); color: var(--orange-text); }
.badge-red    { background: var(--red-bg);    color: var(--red-text);    }
.badge-gray   { background: var(--gray-bg);   color: var(--gray-text);   }
.badge-accent { background: #fdf2f2;          color: var(--accent);      }


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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
  cursor: pointer;
  border: none;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }

.btn-outline {
  background: transparent;
  color: var(--text-1);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg); color: var(--text-1); }

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


/* ─── Form Inputs ──────────────────────────── */

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-1);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  appearance: none;
}

.form-input::placeholder { color: var(--text-3); }

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139,0,0,0.08);
}

textarea.form-input { resize: vertical; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}


/* ─── Search ───────────────────────────────── */

.search-box { position: relative; width: 260px; }

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-3);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-1);
  background: var(--surface);
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input::placeholder { color: var(--text-3); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139,0,0,0.08); }


/* ─── Tabs ─────────────────────────────────── */

.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 0;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover  { color: var(--text-1); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }


/* ─── Tab content ──────────────────────────── */

.tab-content-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}


/* ─── Info grid (Übersicht tab) ─────────────── */

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.info-item { display: flex; flex-direction: column; gap: 4px; }

.info-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-value { font-size: 14px; color: var(--text-1); font-weight: 500; }


/* ─── Utilization bar ──────────────────────── */

.util-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.util-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.util-label { font-size: 13px; font-weight: 600; color: var(--text-1); }
.util-pct   { font-size: 15px; font-weight: 700; }

.util-track {
  height: 10px;
  background: var(--bg);
  border-radius: 100px;
  overflow: hidden;
}

.util-fill-lg {
  height: 100%;
  border-radius: 100px;
  transition: width 0.4s ease;
}

.util-fill-lg.util-blue { background: var(--blue); }
.util-fill-lg.util-red  { background: var(--red);  }

.util-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-2);
}

/* Inline mini bar (dashboard table) */
.util-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 100px;
  overflow: hidden;
}

.util-fill {
  height: 100%;
  border-radius: 100px;
}

.util-fill.util-green { background: var(--green); }
.util-fill.util-red   { background: var(--red);   }


/* ─── Alerts (dashboard) ───────────────────── */

.alerts-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.no-alerts {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-3);
  font-size: 14px;
}

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

.alert-warning { background: var(--orange-bg); border-color: #FCD34D; }
.alert-alert   { background: var(--red-bg);    border-color: #FCA5A5; }

.alert-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-title { font-size: 13px; font-weight: 600; color: var(--text-1); }
.alert-msg   { font-size: 12px; color: var(--text-2); margin-top: 2px; }


/* ─── SAP Cards grid ───────────────────────── */

.sap-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.sap-cards-grid .card { margin-bottom: 0; }


/* ─── Notes box ────────────────────────────── */

.notes-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
}


/* ─── Settings form ────────────────────────── */

.settings-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}


/* ─── Modal ────────────────────────────────── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
  margin: 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 16px; font-weight: 600; }

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 20px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--bg); color: var(--text-1); }

.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 24px 20px;
}


/* ─── Toast ────────────────────────────────── */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideInRight 0.2s ease;
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0);    }
}


/* ─── Animations ───────────────────────────── */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0);    }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}


/* ─── Language switcher (sidebar) ──────────── */

.sidebar-lang {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.lang-sep { color: rgba(255,255,255,0.25); font-size: 12px; }

.lang-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.lang-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
.lang-btn--active { color: #fff !important; }


/* ─── Sortable table headers ────────────────── */

.data-table th[data-sort] { cursor: pointer; user-select: none; }
.data-table th[data-sort]:hover { background: rgba(0,0,0,0.04); }

.sort-ind {
  opacity: 0.35;
  font-size: 9px;
  margin-left: 3px;
  display: inline-block;
}

.data-table th.sort-asc  .sort-ind,
.data-table th.sort-desc .sort-ind { opacity: 1; }
