/* ----------------------------------------------------------------------------
 * ResQware Design System
 * Font/Color/Spacing tokens and component styles.
 * Target: Desktop 1280px+. Below 1024px a mobile gate takes over.
 * -------------------------------------------------------------------------- */

:root {
  /* Primary palette --------------------------------------------------- */
  --resq-navy:       #1a2744;
  --resq-navy-dark:  #111c33;
  --resq-navy-mid:   #2d4a7a;
  --resq-navy-950:   #0d1526;
  --resq-red:        #cc2222;
  --resq-red-light:  #fce8e8;

  /* UI greys ---------------------------------------------------------- */
  --resq-bg:              #f0f2f5;
  --resq-surface:         #ffffff;
  --resq-border:          #e5e7eb;
  --resq-border-strong:   #d1d5db;

  /* Text -------------------------------------------------------------- */
  --resq-text-primary:    #111827;
  --resq-text-secondary:  #6b7280;
  --resq-text-muted:      #9ca3af;
  --resq-text-on-dark:    #e5e7eb;
  --resq-text-on-dark-muted: #94a3b8;

  /* Status ------------------------------------------------------------ */
  --resq-blue:           #378add;
  --resq-blue-bg:        #e6f1fb;
  --resq-green:          #3b6d11;
  --resq-green-bg:       #eaf3de;
  --resq-amber:          #ba7517;
  --resq-amber-bg:       #faeeda;
  --resq-red-status:     #a32d2d;
  --resq-red-status-bg:  #fcebeb;

  /* Layout metrics ---------------------------------------------------- */
  --resq-sidebar-width: 220px;
  --resq-topbar-height: 48px;

  /* Shadows (subtle; no "card lift" look) ----------------------------- */
  --resq-shadow-sm: 0 1px 0 rgba(17, 24, 39, 0.04);
  --resq-shadow-md: 0 1px 2px rgba(17, 24, 39, 0.05),
                    0 1px 1px rgba(17, 24, 39, 0.04);
  --resq-shadow-menu: 0 10px 20px -10px rgba(17, 24, 39, 0.25),
                      0 4px 10px -6px rgba(17, 24, 39, 0.1);

  /* Radii (restrained; behördentauglich) ------------------------------ */
  --resq-radius-sm: 3px;
  --resq-radius:    5px;
  --resq-radius-lg: 8px;
}

/* Reset --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'DM Sans', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--resq-text-primary);
  background: var(--resq-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* Typography ---------------------------------------------------------- */
.resq-display { font-family: 'Syne', sans-serif; font-weight: 500; letter-spacing: -0.01em; }
.resq-page-title {
  font-family: 'Syne', sans-serif;
  font-weight: 500;
  font-size: 16px;
  letter-spacing: -0.01em;
  margin: 0;
}
.resq-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--resq-text-secondary);
}
.resq-muted { color: var(--resq-text-secondary); }
.resq-muted-light { color: var(--resq-text-muted); }

/* Scrollbar (WebKit) -------------------------------------------------- */
.resq-scroll::-webkit-scrollbar,
main::-webkit-scrollbar { width: 10px; height: 10px; }
.resq-scroll::-webkit-scrollbar-track,
main::-webkit-scrollbar-track { background: transparent; }
.resq-scroll::-webkit-scrollbar-thumb,
main::-webkit-scrollbar-thumb {
  background: var(--resq-border-strong);
  border-radius: 5px;
  border: 2px solid var(--resq-bg);
}
.resq-scroll::-webkit-scrollbar-thumb:hover,
main::-webkit-scrollbar-thumb:hover { background: #a6adba; }

/* ----------------------------------------------------------------------------
 * App shell: sidebar + topbar + main
 * -------------------------------------------------------------------------- */
.resq-app {
  display: grid;
  grid-template-columns: var(--resq-sidebar-width) 1fr;
  grid-template-rows: var(--resq-topbar-height) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

.resq-sidebar {
  grid-area: sidebar;
  background: var(--resq-navy);
  color: var(--resq-text-on-dark);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--resq-navy-950);
  position: sticky;
  top: 0;
  height: 100vh;
}
.resq-back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 6px;
  font-size: 11px;
  line-height: 1;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: color .12s ease;
}
.resq-back-link:hover { color: rgba(255,255,255,0.95); }
.resq-back-link__icon { width: 12px; height: 12px; flex-shrink: 0; display: block; }
.resq-back-link__text { white-space: nowrap; }
.resq-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.resq-sidebar__brand-mark {
  width: 24px; height: 24px;
  display: inline-flex;
  align-items: center; justify-content: center;
  color: var(--resq-red);
  flex-shrink: 0;
}
.resq-app-mark {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--resq-red);
  color: #fff;
  border-radius: 6px;
  flex-shrink: 0;
}
.resq-sidebar__brand-text {
  font-family: 'Syne', sans-serif;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: #ffffff;
  line-height: 1.2;
}
.resq-sidebar__brand-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.resq-sidebar__org {
  font-size: 11px;
  color: var(--resq-text-on-dark-muted);
  padding: 6px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.resq-sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px 12px;
}
.resq-nav-group { padding: 10px 8px 4px; }
.resq-nav-group__label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--resq-text-on-dark-muted);
  padding: 6px 8px;
}
.resq-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  font-size: 13px;
  border-radius: var(--resq-radius);
  color: var(--resq-text-on-dark);
  transition: background-color 0.12s ease, color 0.12s ease;
}
.resq-nav-item:hover { background: var(--resq-navy-dark); }
.resq-nav-item.is-active {
  background: var(--resq-navy-dark);
  color: #ffffff;
  box-shadow: inset 2px 0 0 var(--resq-red);
}
.resq-nav-item__icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}
.resq-nav-item.is-active .resq-nav-item__icon { opacity: 1; }

.resq-sidebar__footer {
  padding: 10px 12px 14px;
  border-top: 1px solid var(--resq-navy-dark);
  background: var(--resq-navy-950);
}
.resq-storage {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 4px 10px;
}
.resq-storage__label {
  display: flex; justify-content: space-between;
  font-size: 11px;
  color: var(--resq-text-on-dark-muted);
}
.resq-storage__bar {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
}
.resq-storage__fill {
  display: block;
  height: 100%;
  background: var(--resq-blue);
  transition: width 0.2s ease;
}
.resq-storage--warn .resq-storage__fill { background: var(--resq-amber); }
.resq-storage--crit .resq-storage__fill { background: var(--resq-red); }

.resq-user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border-radius: var(--resq-radius);
  color: var(--resq-text-on-dark);
}
.resq-user-chip:hover { background: var(--resq-navy-dark); }
.resq-avatar {
  width: 28px; height: 28px;
  border-radius: 999px;
  background: var(--resq-navy-mid);
  color: #fff;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
  overflow: hidden;
}
.resq-avatar img { width: 100%; height: 100%; object-fit: cover; }
.resq-user-chip__meta { line-height: 1.2; overflow: hidden; }
.resq-user-chip__name { font-size: 13px; color: #fff; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.resq-user-chip__role { font-size: 11px; color: var(--resq-text-on-dark-muted); }

/* Topbar -------------------------------------------------------------- */
.resq-topbar {
  grid-area: topbar;
  background: var(--resq-surface);
  border-bottom: 1px solid var(--resq-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.resq-topbar__title { flex: 1; display: flex; align-items: center; gap: 10px; }
.resq-topbar__actions { display: flex; align-items: center; gap: 8px; }

/* Main ---------------------------------------------------------------- */
.resq-main {
  grid-area: main;
  overflow-y: auto;
  padding: 24px 28px;
}
.resq-content-narrow { max-width: 960px; }

/* ----------------------------------------------------------------------------
 * Components
 * -------------------------------------------------------------------------- */

/* Breadcrumb */
.resq-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--resq-text-secondary);
}
.resq-breadcrumb__sep { color: var(--resq-text-muted); }
.resq-breadcrumb__item { color: var(--resq-text-secondary); }
.resq-breadcrumb__item--current { color: var(--resq-text-primary); font-weight: 500; }

/* Card / surface */
.resq-card {
  background: var(--resq-surface);
  border: 1px solid var(--resq-border);
  border-radius: var(--resq-radius);
  box-shadow: var(--resq-shadow-sm);
}
.resq-card__header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--resq-border);
  display: flex; justify-content: space-between; align-items: center;
}
.resq-card__body { padding: 16px; }
.resq-card__title { font-size: 14px; font-weight: 500; margin: 0; }

/* Buttons */
.resq-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--resq-radius);
  border: 1px solid var(--resq-border-strong);
  background: var(--resq-surface);
  color: var(--resq-text-primary);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  transition: background-color .12s ease, border-color .12s ease;
}
.resq-btn:hover { background: #f9fafb; border-color: #b8bfcc; }
.resq-btn--primary {
  background: var(--resq-navy);
  color: #fff;
  border-color: var(--resq-navy);
}
.resq-btn--primary:hover { background: var(--resq-navy-dark); border-color: var(--resq-navy-dark); }
.resq-btn--danger {
  background: var(--resq-red);
  color: #fff;
  border-color: var(--resq-red);
}
.resq-btn--danger:hover { background: var(--resq-red-status); border-color: var(--resq-red-status); }
.resq-btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--resq-text-secondary);
}
.resq-btn--ghost:hover { background: #f3f4f6; color: var(--resq-text-primary); }
.resq-btn--sm { padding: 4px 8px; font-size: 12px; }
.resq-btn__icon { width: 14px; height: 14px; }

/* Tables */
.resq-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.resq-table thead th {
  text-align: left;
  font-weight: 500;
  color: var(--resq-text-secondary);
  padding: 8px 12px;
  background: #f7f8fa;
  border-bottom: 1px solid var(--resq-border);
  position: sticky; top: 0;
}
.resq-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--resq-border);
}
.resq-table tbody tr:hover { background: #fafbfc; }
.resq-table tbody tr:last-child td { border-bottom: none; }

/* Forms */
.resq-form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.resq-form-row__label {
  font-size: 12px;
  font-weight: 500;
  color: var(--resq-text-primary);
}
.resq-input, .resq-select, .resq-textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--resq-border-strong);
  border-radius: var(--resq-radius);
  background: var(--resq-surface);
  font-size: 13px;
  color: var(--resq-text-primary);
  transition: border-color .12s ease, box-shadow .12s ease;
}
.resq-input:focus, .resq-select:focus, .resq-textarea:focus {
  outline: none;
  border-color: var(--resq-navy-mid);
  box-shadow: 0 0 0 3px rgba(45, 74, 122, 0.15);
}
.resq-form-help { font-size: 12px; color: var(--resq-text-secondary); }
.resq-form-error { font-size: 12px; color: var(--resq-red-status); }

/* Badges */
.resq-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.resq-badge--info   { background: var(--resq-blue-bg);       color: var(--resq-blue); }
.resq-badge--ok     { background: var(--resq-green-bg);      color: var(--resq-green); }
.resq-badge--warn   { background: var(--resq-amber-bg);      color: var(--resq-amber); }
.resq-badge--danger { background: var(--resq-red-status-bg); color: var(--resq-red-status); }
.resq-badge--neutral{ background: #f3f4f6;                   color: var(--resq-text-secondary); }

/* Toast container (Alpine-driven) */
.resq-toast-stack {
  position: fixed;
  bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 50;
}
.resq-toast {
  background: var(--resq-surface);
  border: 1px solid var(--resq-border);
  border-left-width: 3px;
  border-left-color: var(--resq-navy-mid);
  box-shadow: var(--resq-shadow-menu);
  padding: 10px 14px;
  min-width: 260px;
  max-width: 420px;
  border-radius: var(--resq-radius);
  font-size: 13px;
}
.resq-toast--ok    { border-left-color: var(--resq-green); }
.resq-toast--warn  { border-left-color: var(--resq-amber); }
.resq-toast--error { border-left-color: var(--resq-red); }

/* Modal */
.resq-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(13, 21, 38, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 40;
}
.resq-modal {
  background: var(--resq-surface);
  border-radius: var(--resq-radius-lg);
  box-shadow: var(--resq-shadow-menu);
  width: 480px; max-width: calc(100% - 48px);
}
.resq-modal__header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--resq-border);
  display: flex; justify-content: space-between; align-items: center;
}
.resq-modal__body { padding: 18px; }
.resq-modal__footer {
  padding: 12px 18px;
  border-top: 1px solid var(--resq-border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* Empty state */
.resq-empty {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  color: var(--resq-text-secondary);
}
.resq-empty__icon {
  width: 44px; height: 44px;
  color: var(--resq-text-muted);
  margin-bottom: 12px;
}
.resq-empty__title { font-size: 14px; font-weight: 500; color: var(--resq-text-primary); }
.resq-empty__sub { font-size: 13px; margin-top: 4px; }

/* Auth / marketing centered layouts */
.resq-centered {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--resq-bg);
  padding: 24px;
}
.resq-auth-card {
  background: var(--resq-surface);
  border: 1px solid var(--resq-border);
  border-radius: var(--resq-radius-lg);
  box-shadow: var(--resq-shadow-md);
  width: 400px; max-width: 100%;
  padding: 28px;
  margin-left: auto;
  margin-right: auto;
}
.resq-auth-card__brand {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 18px;
  color: var(--resq-navy);
}
.resq-auth-card__brand strong {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 16px;
}

/* Marketing shell (resqware.de) */
.resq-marketing { background: #fff; color: var(--resq-text-primary); }
.resq-marketing__nav {
  max-width: 1180px; margin: 0 auto;
  padding: 20px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.resq-marketing__hero {
  max-width: 960px; margin: 0 auto;
  padding: 80px 24px 64px;
  text-align: left;
}
.resq-marketing__hero h1 {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 44px;
  line-height: 1.1;
  margin: 0 0 18px;
  letter-spacing: -0.02em;
}
.resq-marketing__hero p {
  font-size: 16px;
  color: var(--resq-text-secondary);
  max-width: 560px;
}

/* Mobile gate: below 1024px replace everything with a message. */
.resq-mobile-gate { display: none; }
@media (max-width: 1023px) {
  .resq-app, .resq-centered, .resq-marketing { display: none !important; }
  .resq-mobile-gate {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 32px;
    text-align: center;
    background: var(--resq-bg);
  }
  .resq-mobile-gate__brand {
    font-family: 'Syne', sans-serif;
    font-weight: 600;
    font-size: 20px;
    color: var(--resq-navy);
    margin-bottom: 12px;
  }
  .resq-mobile-gate__text {
    color: var(--resq-text-secondary);
    max-width: 360px;
  }
}

/* Utility helpers used in templates ---------------------------------- */
.resq-flex { display: flex; }
.resq-flex-between { display: flex; justify-content: space-between; align-items: center; }
.resq-gap-2 { gap: 8px; } .resq-gap-3 { gap: 12px; } .resq-gap-4 { gap: 16px; }
.resq-mt-2 { margin-top: 8px; } .resq-mt-3 { margin-top: 12px; } .resq-mt-4 { margin-top: 16px; } .resq-mt-6 { margin-top: 24px; }
.resq-mb-2 { margin-bottom: 8px; } .resq-mb-4 { margin-bottom: 16px; } .resq-mb-6 { margin-bottom: 24px; }
.resq-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.resq-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.resq-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
