:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e8eef7;
  --muted: #8b9cb3;
  --accent: #3d9eff;
  --accent-dim: rgba(61, 158, 255, 0.15);
  --danger: #f07178;
  --ok: #7fd962;
  --radius: 12px;
  --font: "Plus Jakarta Sans", system-ui, sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, #1e3a5f 0%, transparent 55%),
    radial-gradient(900px 500px at 90% 0%, #2d1f4e 0%, transparent 50%), var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(15, 20, 25, 0.65);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-header .sub {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-pill {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.35rem 0.75rem;
  background: var(--surface);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.panel {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.clockify-selection-total {
  margin: 0.75rem 0 0.5rem;
  font-weight: 600;
  color: var(--text);
}

.clockify-bill-row {
  margin: 0.5rem 0 1rem;
}

.clockify-preview-table {
  width: 100%;
  font-size: 0.9rem;
}

.modal-footer--stack {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.clockify-col-cb {
  width: 3.25rem;
  text-align: center;
  vertical-align: middle;
}

.clockify-all-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  margin: 0;
  color: var(--muted);
}

.clockify-entries-table .clockify-col-cb input[type="checkbox"] {
  margin: 0;
}

.clockify-clients-hint {
  margin: 0 0 0.35rem 0;
}

.clockify-clients-select {
  width: 100%;
  max-width: 28rem;
  min-height: 7rem;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface2);
  color: var(--text);
  font: inherit;
}

.clockify-rates-wrap {
  margin-bottom: 0.5rem;
}

.clockify-rates-actions {
  margin-bottom: 1.25rem;
}

.clockify-default-rate-row {
  margin-bottom: 1rem;
}

.clockify-default-rate-row input[type="number"] {
  width: 100%;
  max-width: 14rem;
}

.clockify-subhead {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted, inherit);
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

/* Login */
#login-view .panel {
  max-width: 420px;
  margin: 4rem auto;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface2);
  color: var(--text);
  font: inherit;
}

input:focus {
  outline: 2px solid var(--accent-dim);
  border-color: var(--accent);
}

input[type="search"].dash-table-search {
  width: 100%;
  max-width: 24rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--surface2);
  color: var(--text);
  font: inherit;
}

.dash-table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.65rem;
}

.dash-search-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
  min-width: min(24rem, 100%);
}

.dash-search-hint {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

.dash-table-count {
  flex-shrink: 0;
  align-self: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  border: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #4dabff 0%, #3d9eff 100%);
  color: #061018;
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.22);
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: rgba(240, 113, 120, 0.12);
  border: 1px solid rgba(240, 113, 120, 0.35);
  color: #ffb4b8;
}

.alert-info {
  background: var(--accent-dim);
  border: 1px solid rgba(61, 158, 255, 0.35);
  color: #b8d9ff;
}

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 7.75rem;
  display: flex;
  flex-direction: column;
}

.stat-card .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.stat-card .value {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.stat-card .hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

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

th,
td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
  background: rgba(0, 0, 0, 0.25);
}

th.th-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th.th-sortable:hover {
  color: #c5d4e6;
}

th.th-sortable .sort-ind {
  display: inline-block;
  min-width: 0.85rem;
  margin-left: 0.2rem;
  font-size: 0.65rem;
  opacity: 0.35;
  vertical-align: middle;
}

th.th-sortable.is-sorted .sort-ind {
  opacity: 1;
}

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

tbody tr:hover td {
  background: rgba(61, 158, 255, 0.06);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-open {
  background: rgba(127, 217, 98, 0.18);
  color: #b8f0a3;
}

.badge-overdue {
  background: rgba(240, 113, 120, 0.2);
  color: #ffb4b8;
}

.badge-draft {
  background: rgba(139, 156, 179, 0.2);
  color: var(--muted);
}

.meta-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.mail-google-help-list {
  margin: 0.35rem 0 1rem;
  padding-left: 1.25rem;
  list-style-type: disc;
}

.mail-google-help-list li {
  margin-bottom: 0.45rem;
}

.mail-google-help-list li:last-child {
  margin-bottom: 0;
}

.loading {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.footer-note {
  margin-top: 2rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.nav-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.nav-tab {
  padding: 0.45rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.nav-tab:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.nav-tab.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(61, 158, 255, 0.45);
}

.mail-default-transport-wrap {
  max-width: 28rem;
  margin-bottom: 1rem;
}

.pw-change-form {
  max-width: 28rem;
}

.instance-row-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}

.instance-mail-label {
  align-self: flex-start;
}

.instance-row-actions select.inst-mail-transport {
  min-width: 10.5rem;
}

.form-row.align-end {
  align-items: flex-end;
}

.instance-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.instance-row:last-child {
  border-bottom: none;
}

.instance-meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.instance-meta code {
  font-size: 0.8rem;
  color: var(--accent);
}

.small {
  font-size: 0.85rem;
}

.instance-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 0;
  margin-top: 1.25rem;
}

.instance-mini-card {
  background: var(--surface2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.instance-mini-card--error {
  border-color: rgba(240, 113, 120, 0.45);
  background: rgba(240, 113, 120, 0.06);
}

.instance-mini-card--selectable {
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease, outline-color 0.15s ease;
}

.instance-mini-card--selectable:hover {
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
  border-color: rgba(61, 158, 255, 0.35);
}

.instance-mini-card--selected {
  outline: 2px solid rgba(61, 158, 255, 0.85);
  outline-offset: 2px;
}

.dash-instanz-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-bottom: 1rem;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius);
  background: rgba(61, 158, 255, 0.08);
  border: 1px solid rgba(61, 158, 255, 0.22);
  font-size: 0.9rem;
}

.dash-instanz-filter-bar.hidden {
  display: none;
}

.instance-mini-card h3 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.mini-metric {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.82rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.mini-metric:last-child {
  border-bottom: none;
}

.mini-metric .lbl {
  color: var(--muted);
}

.mini-metric .val {
  font-weight: 700;
  text-align: right;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  align-items: start;
}

.chart-box {
  /* Angelehnt an .instance-mini-card / .stat-card */
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 300px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}

.chart-box canvas {
  max-height: 220px;
  max-width: 280px;
  margin: 0.25rem auto 0;
  display: block;
  align-self: center;
}

.chart-ph {
  margin: 0;
  padding: 1.5rem 1rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.88rem;
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.chart-box canvas.is-hidden {
  display: none !important;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 10, 18, 0.72);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2rem 1rem;
  overflow-y: auto;
}

.modal-overlay.hidden {
  display: none;
}

.modal-panel {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.modal-body {
  padding: 1rem 1.25rem 1.25rem;
  font-size: 0.9rem;
  max-height: min(70vh, 520px);
  overflow-y: auto;
}

.modal-body h4 {
  margin: 1rem 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-body h4:first-child {
  margin-top: 0;
}

.modal-body ul {
  margin: 0 0 0.75rem;
  padding-left: 1.2rem;
}

.modal-body li {
  margin-bottom: 0.35rem;
}

.relations-empty {
  color: var(--muted);
  font-size: 0.88rem;
}

.modal-panel--wide {
  max-width: 640px;
}

.modal-footer {
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.form-row-check {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: center;
}

.form-row-check label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  vertical-align: top;
}

.admin-cb-row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
  cursor: pointer;
}

.admin-user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  justify-content: flex-end;
}

.admin-cb-row input {
  margin-top: 0.2rem;
}

/* Dashboard: Netto/Brutto in Tabellen- und Stat-Zellen */
.amount-split {
  line-height: 1.35;
  white-space: nowrap;
}

.amount-split .muted.small,
.amount-split span.muted {
  display: inline-block;
  min-width: 2.5rem;
}
