/* ================================================================
   IMMO-TOOL — Dark Luxury Financial Dashboard
   ================================================================ */

/* ----------------------------------------------------------------
   0. CSS CUSTOM PROPERTIES
---------------------------------------------------------------- */
:root {
  --bg-primary:    #0f1117;
  --bg-secondary:  #1a1d27;
  --bg-tertiary:   #252836;
  --text-primary:  #e8e6e3;
  --text-secondary:#8b8d97;
  --accent:        #c9a84c;
  --accent-hover:  #dbb85c;
  --success:       #4ade80;
  --warning:       #fbbf24;
  --danger:        #f87171;
  --border:        #2d3040;

  --sidebar-width: 260px;
  --header-height: 64px;
  --radius-sm:     6px;
  --radius-md:     12px;
  --radius-lg:     16px;
  --shadow-card:   0 4px 24px rgba(0, 0, 0, 0.45);
  --shadow-modal:  0 16px 64px rgba(0, 0, 0, 0.7);
  --transition:    0.2s ease;
}

/* ----------------------------------------------------------------
   1. RESET & BASE
---------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 400;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  line-height: 1.25;
}

h3, h4, h5, h6 {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 600;
  line-height: 1.3;
}

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

ul, ol { list-style: none; }

img, svg { display: block; max-width: 100%; }

button { cursor: pointer; font-family: inherit; }

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

/* ----------------------------------------------------------------
   2. SCROLLBAR
---------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border);
}

/* ----------------------------------------------------------------
   3. LOGIN OVERLAY
---------------------------------------------------------------- */
#login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  /* noise-like texture via layered gradients */
  background:
    radial-gradient(ellipse at 20% 80%, rgba(201, 168, 76, 0.06) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 20%, rgba(201, 168, 76, 0.04) 0%, transparent 55%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(255,255,255,0.005) 2px,
      rgba(255,255,255,0.005) 4px
    ),
    var(--bg-primary);
  padding: 1.5rem;
}

.login-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.75rem 2.5rem 2.25rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-modal);
  position: relative;
  overflow: hidden;
}

/* subtle top accent line */
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.login-icon {
  font-size: 2rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: rgba(201, 168, 76, 0.08);
  border: 1px solid rgba(201, 168, 76, 0.2);
  border-radius: var(--radius-md);
}

.login-title {
  font-size: 1.75rem;
  text-align: center;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.login-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 2rem;
}

.login-error {
  margin-top: 0.875rem;
  font-size: 0.85rem;
  color: var(--danger);
  min-height: 1.25rem;
  text-align: center;
}

.btn-login {
  width: 100%;
  margin-top: 0.5rem;
}

/* ----------------------------------------------------------------
   4. FORM ELEMENTS
---------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-group input,
.form-group select,
.form-group textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
select,
textarea {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 0.65rem 0.9rem;
  font-size: 0.95rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

.form-group input::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 168, 76, 0.12);
}

textarea { resize: vertical; min-height: 100px; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238b8d97' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.2rem;
  cursor: pointer;
}

/* Checkbox */
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ----------------------------------------------------------------
   5. BUTTONS
---------------------------------------------------------------- */
.btn-primary {
  background: var(--accent);
  color: #0f1117;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px rgba(201, 168, 76, 0.25);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.2rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn-secondary:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
  background: var(--bg-tertiary);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.35);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.2rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), border-color var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.btn-danger:hover {
  background: rgba(248, 113, 113, 0.1);
  border-color: var(--danger);
}

.btn-icon {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: color var(--transition), background var(--transition);
}
.btn-icon:hover {
  color: var(--text-primary);
  background: var(--border);
}

.btn-logout {
  font-size: 0.8rem;
  padding: 0.45rem 1rem;
}

/* ----------------------------------------------------------------
   6. SIDEBAR
---------------------------------------------------------------- */
#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.4rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-height);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.sidebar-logo-icon {
  color: var(--accent);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}
.sidebar-logo-text strong {
  font-weight: 700;
  color: var(--accent);
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.2rem;
  transition: color var(--transition);
}
.sidebar-close:hover { color: var(--text-primary); }

.nav-list {
  padding: 0.75rem 0.75rem 0.5rem;
  flex: 1;
}

.nav-list li { margin-bottom: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition), background var(--transition), border-left-color var(--transition);
  border-left: 2px solid transparent;
  position: relative;
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
  text-decoration: none;
}

.nav-item.active {
  color: var(--accent);
  background: rgba(201, 168, 76, 0.07);
  border-left-color: var(--accent);
  font-weight: 600;
}

.nav-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-label { flex: 1; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-version {
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.5;
}

/* Mobile backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 190;
  backdrop-filter: blur(2px);
}

/* ----------------------------------------------------------------
   7. APP BODY / LAYOUT
---------------------------------------------------------------- */
.app-body {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition);
}

/* ----------------------------------------------------------------
   8. HEADER
---------------------------------------------------------------- */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.header-username {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 0.6rem;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(255,255,255,0.1);
  touch-action: manipulation;
  z-index: 100;
  position: relative;
  transition: background var(--transition);
}
.hamburger:hover { background: var(--bg-tertiary); }
.hamburger span {
  display: block;
  width: 22px;
  height: 2.5px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: background var(--transition);
}
.hamburger:hover span { background: var(--text-primary); }

/* ----------------------------------------------------------------
   9. MAIN CONTENT
---------------------------------------------------------------- */
#content {
  flex: 1;
  padding: 2rem 1.75rem;
  max-width: 1400px;
  width: 100%;
}

/* ----------------------------------------------------------------
   10. CARDS
---------------------------------------------------------------- */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
  border-color: rgba(45, 48, 64, 0.8);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  gap: 1rem;
}

.card-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
}

.card-value {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  margin-top: 0.4rem;
}

.card-delta {
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 0.35rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.card-delta.up   { color: var(--success); }
.card-delta.down { color: var(--danger); }

/* KPI grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* Section grid */
.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

/* ----------------------------------------------------------------
   11. PAGE HEADER
---------------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.75rem;
  color: var(--text-primary);
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.2rem;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ----------------------------------------------------------------
   12. TABLES
---------------------------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

thead th {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.85rem 1.1rem;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

thead th:first-child { border-radius: var(--radius-md) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-md) 0 0; }

tbody tr {
  border-bottom: 1px solid rgba(45, 48, 64, 0.5);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:nth-child(even) {
  background: rgba(37, 40, 54, 0.25);
}

tbody tr:hover {
  background: var(--bg-tertiary);
  cursor: pointer;
}

td {
  padding: 0.85rem 1.1rem;
  color: var(--text-primary);
  vertical-align: middle;
}

td.muted { color: var(--text-secondary); }

/* ----------------------------------------------------------------
   13. STATUS BADGES
---------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-success {
  background: rgba(74, 222, 128, 0.12);
  color: var(--success);
  border: 1px solid rgba(74, 222, 128, 0.2);
}

.badge-warning {
  background: rgba(251, 191, 36, 0.12);
  color: var(--warning);
  border: 1px solid rgba(251, 191, 36, 0.2);
}

.badge-danger {
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.2);
}

.badge-neutral {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.badge-accent {
  background: rgba(201, 168, 76, 0.1);
  color: var(--accent);
  border: 1px solid rgba(201, 168, 76, 0.2);
}

/* ----------------------------------------------------------------
   14. MODAL
---------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  transform: translateY(12px);
  transition: transform var(--transition);
  position: relative;
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 1.5rem 0;
  margin-bottom: 1.25rem;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.2rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.modal-body {
  padding: 0 1.5rem 1.5rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg-tertiary);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Tooltip for assumptions */
.tooltip-hint {
  cursor: help;
  border-bottom: 1px dashed var(--text-secondary);
}
#app-tooltip {
  position: fixed;
  z-index: 9999;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.8rem;
  line-height: 1.5;
  max-width: 360px;
  white-space: normal;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s;
}
#app-tooltip.visible {
  opacity: 1;
}
.tooltip-hint:hover {
  border-color: var(--accent) !important;
}

/* ----------------------------------------------------------------
   15. TOOLBAR (search + actions above tables)
---------------------------------------------------------------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: 0.75rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  pointer-events: none;
}

.search-input-wrapper input {
  padding-left: 2.2rem;
  min-width: 220px;
  width: auto;
}

/* ----------------------------------------------------------------
   16. EMPTY STATE
---------------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.empty-state p {
  font-size: 0.875rem;
  max-width: 320px;
  line-height: 1.5;
}

.empty-state .btn-primary {
  margin-top: 1.25rem;
}

/* ----------------------------------------------------------------
   17. LOADING SPINNER
---------------------------------------------------------------- */
.spinner-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
}

.spinner {
  width: 36px;
  height: 36px;
  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); }
}

/* Inline spinner for buttons */
.spinner-sm {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0,0,0,0.2);
  border-top-color: #0f1117;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ----------------------------------------------------------------
   18. DIVIDER & MISC
---------------------------------------------------------------- */
.divider {
  height: 1px;
  background: var(--border);
  margin: 1.25rem 0;
}

.text-accent   { color: var(--accent); }
.text-success  { color: var(--success); }
.text-warning  { color: var(--warning); }
.text-danger   { color: var(--danger); }
.text-muted    { color: var(--text-secondary); }

.font-mono {
  font-family: 'Fira Mono', 'Cascadia Code', monospace;
  font-size: 0.875em;
}

.truncate {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* Flex utilities */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.gap-xs       { gap: 0.25rem; }
.gap-sm       { gap: 0.5rem; }
.gap-md       { gap: 1rem; }
.gap-lg       { gap: 1.5rem; }
.ml-auto      { margin-left: auto; }
.mt-1         { margin-top: 0.5rem; }
.mt-2         { margin-top: 1rem; }
.mb-1         { margin-bottom: 0.5rem; }
.mb-2         { margin-bottom: 1rem; }

/* ----------------------------------------------------------------
   19. SELECTION / CHECKBOX TABLE
---------------------------------------------------------------- */
.row-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

tbody tr.selected {
  background: rgba(201, 168, 76, 0.06) !important;
  border-left: 2px solid var(--accent);
}

/* ----------------------------------------------------------------
   20. PROGRESS BAR
---------------------------------------------------------------- */
.progress {
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.4s ease;
}
.progress-bar.success { background: var(--success); }
.progress-bar.danger  { background: var(--danger); }

/* ----------------------------------------------------------------
   21. NOTIFICATION / TOAST (if needed)
---------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 900;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.1rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 240px;
  max-width: 360px;
  animation: slideUp 0.25s ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }

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

/* ----------------------------------------------------------------
   22. HIGHLIGHT / GOLD ACCENT CARD (dashboard metrics)
---------------------------------------------------------------- */
.card.accent-border {
  border-color: rgba(201, 168, 76, 0.3);
  background: linear-gradient(135deg, rgba(201, 168, 76, 0.04) 0%, var(--bg-secondary) 60%);
}

.metric-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  flex-shrink: 0;
}

.metric-icon.gold   { background: rgba(201, 168, 76, 0.1);  color: var(--accent); }
.metric-icon.green  { background: rgba(74, 222, 128, 0.1);  color: var(--success); }
.metric-icon.red    { background: rgba(248, 113, 113, 0.1); color: var(--danger); }
.metric-icon.blue   { background: rgba(99, 179, 237, 0.1);  color: #63b3ed; }

/* ----------------------------------------------------------------
   23. TABS
---------------------------------------------------------------- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.65rem 1.1rem;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  margin-bottom: -1px;
}

.tab:hover { color: var(--text-primary); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ----------------------------------------------------------------
   24. RESPONSIVE
---------------------------------------------------------------- */
@media (max-width: 1024px) {
  #content {
    padding: 1.5rem 1.25rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }
}

@media (max-width: 768px) {
  /* Sidebar collapses off-screen */
  #sidebar {
    transform: translateX(calc(-1 * var(--sidebar-width)));
    box-shadow: none;
  }

  #sidebar.sidebar--open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.6);
  }

  .sidebar-close { display: flex; }

  .sidebar-backdrop.active {
    display: block;
  }

  .app-body {
    margin-left: 0;
  }

  .hamburger {
    display: flex;
  }

  #app-header {
    padding: 0 1rem;
  }

  #content {
    padding: 1.25rem 1rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .search-input-wrapper input {
    min-width: unset;
    width: 100%;
  }

  .modal {
    max-height: 95vh;
  }

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

  .section-grid {
    grid-template-columns: 1fr;
  }

  .header-username {
    display: none;
  }

  .card-value { font-size: 1.6rem; }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .login-card {
    padding: 2rem 1.5rem 1.75rem;
  }

  .login-title { font-size: 1.5rem; }

  /* iPhone: Tabellen horizontal scrollbar */
  .table-responsive,
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 600px;
  }

  /* iPhone: Formulare nicht zu klein */
  input, select, textarea {
    font-size: 16px !important; /* verhindert Auto-Zoom bei Focus auf iOS */
  }

  /* iPhone: Modals fullscreen */
  .modal {
    width: 95vw;
    max-height: 90vh;
    margin: 5vh auto;
  }

  /* iPhone: Buttons Touch-freundlich */
  .btn, .btn-primary, .btn-secondary, .btn-danger, button {
    min-height: 44px;
    min-width: 44px;
  }

  .nav-item {
    min-height: 48px;
    padding: 0.75rem 1rem;
  }

  /* iPhone: Filter-Dropdowns untereinander */
  .row.g-2 {
    flex-direction: column;
  }

  /* iPhone: Detail-Grids einspaltig */
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* iPhone Safe Area (Notch) */
  #app-header {
    padding-top: env(safe-area-inset-top, 0);
  }

  #sidebar {
    padding-top: env(safe-area-inset-top, 0);
  }

  #content {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
}

/* ----------------------------------------------------------------
   25. FOCUS VISIBLE ACCESSIBILITY
---------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
  outline: none;
}

/* ----------------------------------------------------------------
   26. PRINT (minimal)
---------------------------------------------------------------- */
@media print {
  #sidebar, #app-header { display: none; }
  .app-body { margin-left: 0; }
  #content { padding: 0; }
  body { background: #fff; color: #000; }
}
