/* ============================================================
   Gleam & Go Kundenportal — CSS Framework
   Design tokens consistent with gleam-and-go.de
   ============================================================ */

/* ── Custom Properties ──────────────────────────────────────── */
:root {
  --teal:         #0A7B6C;
  --teal-dark:    #085e52;
  --teal-deep:    #063D36;
  --teal-light:   #E6F5F3;
  --teal-mid:     #12A896;
  --gold:         #C8992A;
  --gold-light:   #FDF3DC;
  --dark:         #1C2833;
  --grey:         #6C7A89;
  --light-bg:     #F8FFFE;
  --border:       #DDE8E7;
  --white:        #ffffff;
  --red:          #e53e3e;
  --red-light:    #fff5f5;
  --green:        #38a169;
  --green-light:  #f0fff4;
  --blue:         #3182ce;
  --blue-light:   #ebf8ff;

  --shadow-sm:    0 1px 4px rgba(0,0,0,0.06);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.12);

  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    16px;

  --sidebar-w:    240px;
  --topbar-h:     60px;

  --font:         'Plus Jakarta Sans', 'Segoe UI', Arial, sans-serif;
}

/* ── Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  color: var(--dark);
  background: var(--light-bg);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { font-family: var(--font); cursor: pointer; }

/* ── Typography ─────────────────────────────────────────────── */
h1 { font-size: 1.5rem; font-weight: 800; line-height: 1.3; }
h2 { font-size: 1.15rem; font-weight: 700; line-height: 1.4; }
h3 { font-size: 1rem;    font-weight: 700; }
.text-sm   { font-size: 0.82rem; }
.text-xs   { font-size: 0.75rem; }
.text-grey { color: var(--grey); }
.text-red  { color: var(--red); }
.text-green { color: var(--green); }
.text-right { text-align: right; }
.font-mono  { font-family: 'Consolas', 'Courier New', monospace; letter-spacing: 0.3px; }
.font-semibold { font-weight: 600; }
.font-bold     { font-weight: 700; }

/* ── Utilities ──────────────────────────────────────────────── */
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.p-0   { padding: 0 !important; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 0.88rem;
  border: 2px solid transparent;
  transition: all 0.18s ease;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }

.btn-primary {
  background: var(--teal);
  color: var(--white);
  border-color: var(--teal);
}
.btn-primary:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(10,123,108,0.25);
}
.btn-outline {
  background: transparent;
  color: var(--teal);
  border-color: var(--teal);
}
.btn-outline:hover { background: var(--teal); color: var(--white); }

.btn-secondary {
  background: var(--white);
  color: var(--dark);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--grey); }

.btn-danger {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}
.btn-danger:hover { background: #c53030; }

.btn-sm {
  padding: 5px 14px;
  font-size: 0.8rem;
}
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group   { margin-bottom: 18px; }
.form-label   {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 6px;
  letter-spacing: 0.2px;
}
.form-label-link {
  font-weight: 500;
  color: var(--teal);
  font-size: 0.78rem;
}
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--dark);
  background: var(--white);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(10,123,108,0.12);
}
.form-input::placeholder { color: #b0bec5; }
.form-textarea { resize: vertical; min-height: 96px; }

.input-with-toggle { position: relative; }
.input-with-toggle .form-input { padding-right: 44px; }
.input-toggle-btn {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: var(--grey); padding: 4px;
  display: flex; align-items: center;
}
.input-toggle-btn:hover { color: var(--teal); }

.form-check   { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.check-input  {
  width: 16px; height: 16px;
  accent-color: var(--teal);
  cursor: pointer;
}
.check-label  { font-size: 0.88rem; cursor: pointer; }

.form-hint    { font-size: 0.78rem; color: var(--grey); margin-top: 4px; }
.form-error   { font-size: 0.78rem; color: var(--red); margin-top: 4px; }

/* Password strength indicator */
.password-strength {
  height: 4px;
  border-radius: 2px;
  margin-top: 6px;
  background: var(--border);
  overflow: hidden;
}
.pw-weak   { width: 33%;  background: var(--red); }
.pw-medium { width: 66%;  background: var(--gold); }
.pw-strong { width: 100%; background: var(--green); }

/* ── Badges / Status ────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.badge-grey  { background: #f1f3f4; color: var(--grey); }
.badge-blue  { background: var(--blue-light); color: var(--blue); }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-red   { background: var(--red-light); color: var(--red); }
.badge-gold  { background: var(--gold-light); color: #8a6400; }
.badge-teal  { background: var(--teal-light); color: var(--teal-dark); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 20px;
  border-left: 4px solid;
}
.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--green-light); border-color: var(--green); color: #276749; }
.alert-error   { background: var(--red-light);   border-color: var(--red);   color: #9b2c2c; }
.alert-warning { background: var(--gold-light);  border-color: var(--gold);  color: #7a5b0e; }
.alert-info    { background: var(--blue-light);  border-color: var(--blue);  color: #1a4a7a; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--dark);
}
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--light-bg);
}
.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--grey);
  font-size: 0.88rem;
}

/* ── Tables ─────────────────────────────────────────────────── */
.portal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.portal-table thead tr {
  background: var(--light-bg);
}
.portal-table thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--grey);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.portal-table thead th:not(:first-child):not(.no-right) { }
.portal-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.portal-table tbody tr:last-child { border-bottom: none; }
.portal-table tbody tr:hover { background: #fafffe; }
.portal-table tbody td { padding: 11px 16px; vertical-align: middle; }
.table-action {
  color: var(--grey);
  padding: 4px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.table-action:hover {
  color: var(--teal);
  background: var(--teal-light);
  text-decoration: none;
}

/* ── Stat Cards ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat-card-highlight {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(10,123,108,0.1);
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon-teal  { background: var(--teal-light);  color: var(--teal); }
.stat-icon-gold  { background: var(--gold-light);   color: var(--gold); }
.stat-icon-green { background: var(--green-light);  color: var(--green); }
.stat-icon-blue  { background: var(--blue-light);   color: var(--blue); }
.stat-body { flex: 1; min-width: 0; }
.stat-value {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--dark);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-label {
  font-size: 0.78rem;
  color: var(--grey);
  margin-top: 2px;
}
.stat-link {
  color: var(--grey);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
  text-decoration: none;
}
.stat-link:hover { color: var(--teal); background: var(--teal-light); }

/* ── Progress Bar ───────────────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: rgba(0,0,0,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.progress-red  { background: var(--red); }
.progress-gold { background: var(--gold); }

/* ── Two-col grid ───────────────────────────────────────────── */
.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ── Message List ───────────────────────────────────────────── */
.message-list { list-style: none; }
.message-item {
  border-bottom: 1px solid var(--border);
}
.message-item:last-child { border-bottom: none; }
.message-item a {
  display: block;
  padding: 12px 20px;
  transition: background 0.1s;
  text-decoration: none;
  color: inherit;
}
.message-item a:hover { background: var(--light-bg); }
.message-item.unread a { background: var(--teal-light); }
.message-item.unread a:hover { background: #d4eeea; }
.message-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 3px;
}
.message-customer { font-weight: 700; font-size: 0.85rem; }
.message-time     { font-size: 0.75rem; color: var(--grey); }
.message-subject  { font-size: 0.85rem; color: var(--grey); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-item.unread .message-subject { color: var(--dark); font-weight: 500; }

/* ── Link subtle ────────────────────────────────────────────── */
.link-subtle {
  font-size: 0.82rem;
  color: var(--teal);
  font-weight: 600;
}
.link-subtle:hover { text-decoration: underline; }

/* ── Welcome Banner ─────────────────────────────────────────── */
.welcome-banner {
  background: linear-gradient(135deg, var(--teal-deep) 0%, var(--teal) 100%);
  color: var(--white);
  border-radius: var(--radius-md);
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.welcome-text h2 { font-size: 1.2rem; font-weight: 800; color: var(--white); margin-bottom: 4px; }
.welcome-text p  { color: rgba(255,255,255,0.8); font-size: 0.9rem; }
.welcome-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.15);
  color: var(--white);
  padding: 8px 16px;
  border-radius: 50px;
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
  transition: background 0.15s;
}
.welcome-badge:hover { background: rgba(255,255,255,0.25); text-decoration: none; }

/* ── Contact Card ───────────────────────────────────────────── */
.contact-card .card-body { padding: 24px; text-align: center; }
.contact-logo {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--teal);
  margin-bottom: 4px;
}
.contact-logo span { color: var(--gold); }
.contact-tagline { font-size: 0.78rem; color: var(--grey); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 16px; }
.contact-details { font-size: 0.88rem; }
.contact-details > div {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 6px 0; color: var(--grey);
}
.contact-details a { color: var(--teal); }

/* ── App Layout ─────────────────────────────────────────────── */
.app-body { background: var(--light-bg); overflow-x: hidden; }

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--teal-deep);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  z-index: 200;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 8px;
}
.logo-text {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--white);
  letter-spacing: -0.3px;
}
.logo-text span { color: var(--gold); }
.logo-sub {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 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.7);
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: var(--white);
  text-decoration: none;
}
.nav-item.active {
  background: rgba(255,255,255,0.15);
  color: var(--white);
}
.nav-item.active svg { color: var(--teal-mid); }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 4px;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--teal-mid);
  color: var(--white);
  font-weight: 800;
  font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-info { min-width: 0; }
.user-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--white);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-role {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.5);
}
.nav-logout { color: rgba(255,255,255,0.5); }
.nav-logout:hover { color: #fc8181; background: rgba(252,129,129,0.1); }

/* ── Main Area ──────────────────────────────────────────────── */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--grey);
  padding: 6px;
  border-radius: var(--radius-sm);
}
.sidebar-toggle:hover { background: var(--light-bg); color: var(--dark); }
.topbar-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--dark);
  flex: 1;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }

/* ── Content ────────────────────────────────────────────────── */
.content {
  flex: 1;
  padding: 28px;
  max-width: 1200px;
}

/* ── Sidebar Overlay (mobile) ───────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
}

/* ── Auth Layout ────────────────────────────────────────────── */
.auth-body {
  background: linear-gradient(135deg, var(--teal-deep) 0%, var(--teal) 60%, var(--teal-mid) 100%);
  min-height: 100vh;
}
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo-text {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--teal);
  letter-spacing: -0.5px;
}
.auth-logo-text span { color: var(--gold); }
.auth-logo-sub {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--grey);
  margin-top: 2px;
}
.auth-title {
  font-size: 1.3rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 6px;
  color: var(--dark);
}
.auth-subtitle {
  text-align: center;
  color: var(--grey);
  font-size: 0.88rem;
  margin-bottom: 24px;
  line-height: 1.6;
}
.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 18px;
  border-left: 3px solid;
}
.auth-alert svg { flex-shrink: 0; margin-top: 1px; }
.auth-alert-error   { background: var(--red-light);   border-color: var(--red);   color: #9b2c2c; }
.auth-alert-success { background: var(--green-light);  border-color: var(--green); color: #276749; }
.auth-footer-note {
  text-align: center;
  font-size: 0.78rem;
  color: var(--grey);
  margin-top: 20px;
  line-height: 1.6;
}
.auth-back-link {
  text-align: center;
  margin-top: 20px;
  font-size: 0.85rem;
}
.auth-back-link a { color: var(--teal); font-weight: 600; }

/* ── Error Card ─────────────────────────────────────────────── */
.error-card { text-align: center; }
.error-code {
  font-size: 5rem;
  font-weight: 900;
  color: var(--teal-light);
  line-height: 1;
  margin-bottom: 12px;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .two-col-grid { grid-template-columns: 1fr; }
  .stats-grid   { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 260px; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
  .sidebar-overlay.is-open { display: block; }
  .sidebar-toggle { display: flex; }

  .content { padding: 20px 16px; }
  .topbar   { padding: 0 16px; }

  .welcome-banner {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  .welcome-badge { align-self: flex-start; }

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

  .auth-card { padding: 32px 24px; }
}

@media (max-width: 480px) {
  .stat-value { font-size: 1.1rem; }
  .portal-table thead { display: none; }
  .portal-table tbody tr {
    display: block;
    padding: 12px 16px;
  }
  .portal-table tbody td {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border: none;
  }
  .portal-table tbody td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--grey);
    font-size: 0.75rem;
    margin-right: 8px;
  }
}

/* ============================================================
   Phase 2 additions
   ============================================================ */

/* ── Page Toolbar ───────────────────────────────────────────── */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}
.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 320px;
}
.search-input-wrap svg {
  position: absolute;
  left: 10px;
  color: var(--grey);
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.88rem;
  color: var(--dark);
  background: var(--white);
}
.search-input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(10,123,108,0.12);
}

/* ── Detail List ─────────────────────────────────────────────── */
.detail-list {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 16px;
  font-size: 0.88rem;
}
.detail-list dt {
  font-weight: 700;
  color: var(--grey);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-top: 2px;
}
.detail-list dd { color: var(--dark); }

/* ── Notes Box ───────────────────────────────────────────────── */
.notes-box {
  background: var(--gold-light);
  border: 1px solid rgba(200,153,42,0.25);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 0.85rem;
  color: #7a5b0e;
}
.notes-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #a97a0e;
  margin-bottom: 6px;
}

/* ── Form Helpers ─────────────────────────────────────────────── */
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.required { color: var(--red); }
.row-inactive { opacity: 0.5; }

/* ── Builder Layout ──────────────────────────────────────────── */
.builder-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: flex-start;
}
.builder-main { min-width: 0; }
.builder-sidebar { position: sticky; top: 80px; }

/* ── Builder Table ───────────────────────────────────────────── */
.builder-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.builder-table thead tr { background: var(--light-bg); }
.builder-table thead th {
  padding: 8px 10px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--grey);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.builder-table tbody tr { border-bottom: 1px solid var(--border); }
.builder-table tbody td { padding: 8px 10px; vertical-align: top; }
.builder-table tbody tr:hover { background: #fafffe; }

.col-drag    { width: 28px; }
.col-qty     { width: 80px; }
.col-unit    { width: 100px; }
.col-price   { width: 90px; }
.col-total   { width: 100px; }
.col-var     { width: 36px; text-align: center; }
.col-actions { width: 64px; }

/* Drag handle */
.drag-handle {
  cursor: grab;
  color: var(--border);
  display: flex;
  align-items: center;
  padding-top: 10px;
}
.drag-handle:hover { color: var(--grey); }
.row-ghost { opacity: 0.4; background: var(--teal-light) !important; }

/* Item row inputs */
.item-desc, .section-title-input {
  width: 100%;
  padding: 6px 8px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.85rem;
  color: var(--dark);
  background: var(--white);
  margin-bottom: 4px;
}
.item-desc:focus, .section-title-input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(10,123,108,0.1);
}
.item-detail {
  width: 100%;
  padding: 5px 8px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.78rem;
  color: var(--grey);
  resize: none;
  background: var(--white);
}
.item-detail:focus { outline: none; border-color: var(--teal); }

.item-qty, .item-price {
  width: 100%;
  padding: 6px 8px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.85rem;
  text-align: right;
  color: var(--dark);
}
.item-qty:focus, .item-price:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(10,123,108,0.1);
}
.item-unit {
  width: 100%;
  padding: 6px 6px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.82rem;
  color: var(--dark);
  background: var(--white);
  cursor: pointer;
}
.item-total {
  width: 100%;
  padding: 6px 8px;
  border: 1.5px solid transparent;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: right;
  color: var(--teal-dark);
  background: var(--teal-light);
  cursor: default;
}

/* Section row */
.section-row { background: #f5fffe !important; }
.section-title-input {
  font-weight: 800;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--teal-deep);
  background: transparent;
  border-color: transparent;
  margin-bottom: 0;
}
.section-title-input:focus { background: var(--white); border-color: var(--teal); }

/* Row buttons */
.row-delete-btn, .row-picker-btn {
  background: none;
  border: none;
  padding: 4px;
  border-radius: 6px;
  color: var(--grey);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}
.row-picker-btn:hover { color: var(--teal);  background: var(--teal-light); }
.row-delete-btn:hover { color: var(--red);   background: var(--red-light); }

/* Grand Total row */
.builder-total {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 14px 20px;
  background: var(--teal-light);
  border-top: 2px solid var(--teal);
  font-weight: 800;
}
.builder-total-label { color: var(--teal-deep); font-size: 0.9rem; }
.builder-total-value { color: var(--teal-deep); font-size: 1.1rem; }

/* ── Service Picker Modal ─────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.is-open { display: flex; }

.modal-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 800;
}
.modal-close {
  background: none;
  border: none;
  color: var(--grey);
  padding: 4px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
}
.modal-close:hover { background: var(--light-bg); color: var(--dark); }
.modal-search { padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.modal-body { overflow-y: auto; flex: 1; padding-bottom: 8px; }

.picker-category { margin-bottom: 4px; }
.picker-cat-label {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--teal);
  padding: 10px 16px 4px;
}
.picker-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.12s;
  gap: 12px;
}
.picker-item:hover { background: var(--teal-light); }
.picker-item-name { font-weight: 600; font-size: 0.88rem; }
.picker-item-meta { font-size: 0.78rem; color: var(--grey); white-space: nowrap; flex-shrink: 0; }

/* ── Responsive builder ───────────────────────────────────────── */
@media (max-width: 1024px) {
  .builder-layout { grid-template-columns: 1fr; }
  .builder-sidebar { position: static; }
}
@media (max-width: 768px) {
  .form-row-2 { grid-template-columns: 1fr; }
  .col-total, .col-var { display: none; }
}

/* ============================================================
   Phase 3 — Rechnungen, Messaging, Kundenportal
   ============================================================ */

/* ── Invoice status badges ─────────────────────────────────── */
.badge-overdue  { background: #fff5f5; color: #c53030; border: 1px solid #fed7d7; }
.badge-paid     { background: #f0fff4; color: #276749; border: 1px solid #c6f6d5; }
.badge-cancelled{ background: #f7fafc; color: #718096; border: 1px solid #e2e8f0; }
.text-danger    { color: var(--red); }

/* ── Mark-paid button (card) ─────────────────────────────── */
.card.pay-card  { border: 1px solid #c6f6d5; background: #f0fff4; }
.btn-pay        { background: #276749; color: #fff; }
.btn-pay:hover  { background: #22543d; }

/* ── Messaging: Thread List ────────────────────────────────── */
.thread-list    { display: flex; flex-direction: column; }

.thread-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background 0.12s;
}
.thread-item:hover       { background: var(--light-bg); }
.thread-item:last-child  { border-bottom: none; }
.thread-unread           { background: var(--teal-light); }
.thread-unread:hover     { background: #d0ede9; }

.thread-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--teal-deep);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1rem;
  flex-shrink: 0;
}

.thread-body    { flex: 1; min-width: 0; }
.thread-meta    { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.thread-customer{ font-weight: 700; font-size: 0.9rem; }
.thread-time    { font-size: 0.75rem; color: var(--grey); white-space: nowrap; }
.thread-subject { font-size: 0.88rem; font-weight: 600; color: var(--dark); margin-top: 2px; }
.thread-preview { font-size: 0.78rem; color: var(--grey); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.unread-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--teal); flex-shrink: 0;
}
.reply-count {
  background: var(--teal-light); color: var(--teal);
  border-radius: 12px; padding: 1px 8px;
  font-size: 0.75rem; font-weight: 700; white-space: nowrap;
}

/* ── Messaging: Message Bubbles ─────────────────────────────── */
.message-bubble {
  margin-bottom: 16px;
  border-radius: var(--radius);
  padding: 14px 18px;
  max-width: 92%;
}

.message-admin,
.message-from-gleam {
  background: var(--teal-light);
  border-left: 3px solid var(--teal);
  margin-right: auto;
}

.message-customer,
.message-from-customer {
  background: var(--gold-light);
  border-right: 3px solid var(--gold);
  margin-left: auto;
  text-align: right;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.8rem;
  flex-wrap: wrap;
}

.message-from-customer .message-meta {
  justify-content: flex-end;
}

.message-body {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--dark);
  white-space: pre-wrap;
}

/* ── Badge sizes ────────────────────────────────────────────── */
.badge-sm        { font-size: 0.68rem; padding: 2px 7px; }
.badge-teal      { background: var(--teal-light); color: var(--teal); }
.badge-gold      { background: var(--gold-light);  color: #7a5b0e; }

/* ── Customer portal: documents page ───────────────────────── */
.mb-20 { margin-bottom: 20px; }

/* ── Responsive messaging ──────────────────────────────────── */
@media (max-width: 768px) {
  .message-bubble { max-width: 98%; }
  .thread-item    { padding: 12px 14px; gap: 10px; }
}

/* ============================================================
   Phase 4 — BWA, Ausgaben, Security, DSGVO
   ============================================================ */

/* ── §19 Progress Bar ─────────────────────────────────────── */
.progress-track {
  width: 100%;
  height: 12px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease;
}
.progress-ok     { background: var(--teal); }
.progress-warn   { background: var(--gold); }
.progress-danger { background: var(--red); }

/* ── Red stat icon (new in Phase 4) ──────────────────────── */
.stat-icon-red   { background: #fff5f5; color: var(--red); }
