:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --line: #d9e0e7;
  --text: #17202a;
  --muted: #657282;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  width: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  color: var(--text);
  background: var(--bg);
  font: 14px/1.45 Arial, Helvetica, sans-serif;
  overflow-x: hidden;
  width: 100%;
}

.login-body {
  display: block;
  background: #eef2f6;
}

.login-shell {
  align-items: center;
  display: flex;
  min-height: 100vh;
  justify-content: center;
  max-width: none;
  padding: 24px;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 420px;
  padding: 26px;
  width: 100%;
}

.login-brand {
  align-items: center;
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.login-brand img {
  background: #ffffff;
  border-radius: 50%;
  height: 54px;
  object-fit: cover;
  width: 54px;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

aside {
  background: #1f2933;
  color: #ffffff;
  min-width: 0;
  padding: 24px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 28px;
}

.brand img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 50%;
  background: #ffffff;
  display: block;
}

.brand span {
  color: #ffffff;
  line-height: 1.1;
}

nav {
  display: grid;
  gap: 5px;
}

nav a {
  color: #d9e2ec;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 6px;
}

.nav-section {
  border: 0;
}

.nav-section summary {
  color: #9fb0c1;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  list-style: none;
  margin: 13px 12px 3px;
  padding: 4px 0;
  text-transform: uppercase;
}

.nav-section summary::-webkit-details-marker {
  display: none;
}

.nav-section summary::after {
  content: "+";
  float: right;
  font-size: 13px;
  line-height: 1;
}

.nav-section[open] summary::after {
  content: "-";
}

.nav-section-links {
  display: grid;
  gap: 5px;
}

.nav-section:not([open]) .nav-section-links {
  display: none;
}

nav a.active,
nav a:hover {
  background: #334150;
  color: #ffffff;
}

.app-version {
  border-top: 1px solid #334150;
  color: #9fb0c1;
  display: grid;
  font-size: 11px;
  gap: 3px;
  margin-top: 22px;
  padding: 14px 12px 0;
}

main {
  padding: 28px;
  max-width: 1180px;
  min-width: 0;
  width: 100%;
}

header {
  margin-bottom: 20px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
  margin: 28px 0 12px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.quickfilters {
  margin-bottom: 10px;
}

.action-bar {
  align-items: center;
}

.action-bar form {
  margin: 0;
}

.automation-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -6px 0 18px;
}

.automation-hints span {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 999px;
  color: #92400e;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 9px;
}

.automation-note,
.automation-box {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  margin: 0;
  padding: 10px 12px;
}

.automation-box {
  display: grid;
  gap: 6px;
  margin: 12px 0;
}

.automation-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.automation-box ul {
  color: var(--text);
  margin: 0;
  padding-left: 18px;
}

.filter-bar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 18px;
  padding: 14px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  text-align: center;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button.small {
  min-height: 32px;
  padding: 6px 10px;
  white-space: nowrap;
}

.button.danger {
  border-color: #fecaca;
  color: var(--danger);
}

.button.danger:hover {
  background: #fef3f2;
}

.support-button {
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.management-overview {
  margin-bottom: 18px;
  padding: 18px;
  background: linear-gradient(135deg, #f8fbff 0%, #ffffff 70%);
  border: 1px solid #bfd7f3;
  border-radius: 6px;
}

.management-overview .section-title-row {
  margin-bottom: 14px;
}

.management-overview .section-title-row p {
  margin: 4px 0 0;
  color: var(--muted);
}

.management-stats {
  margin-bottom: 12px;
}

.management-stats .stat {
  background: #fff;
}

.work-areas {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-bottom: 18px;
}

.intake-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 18px;
  padding: 16px;
}

.intake-panel p {
  color: var(--muted);
  margin: 5px 0 0;
}

.intake-form {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.intake-form label.wide,
.intake-form .form-actions {
  grid-column: 1 / -1;
}

.intake-form .intake-drop {
  padding: 14px;
}

.warning-pill {
  align-items: center;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 999px;
  color: #991b1b;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  gap: 7px;
  min-height: 30px;
  padding: 5px 10px;
  text-decoration: none;
  white-space: nowrap;
}

.warning-pill span {
  align-items: center;
  background: #dc2626;
  border-radius: 999px;
  color: #ffffff;
  display: inline-flex;
  height: 18px;
  justify-content: center;
  width: 18px;
}

.work-area {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 12px;
  padding: 16px;
}

.work-area h2 {
  font-size: 17px;
  margin: 0;
}

.work-area p {
  color: var(--muted);
  margin: 0;
  min-height: 42px;
}

.work-area div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.work-area a {
  align-items: center;
  background: #eef5f4;
  border: 1px solid #c7d8d5;
  border-radius: 6px;
  color: var(--accent-dark);
  display: inline-flex;
  font-weight: 700;
  min-height: 32px;
  padding: 6px 10px;
  text-decoration: none;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
}

.stat span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat strong {
  font-size: 30px;
}

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  max-width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

.compact-table table,
.support-table table {
  min-width: 760px;
}

.support-layout {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
}

.support-form {
  align-self: start;
}

.support-side {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.system-strip {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 14px;
}

.ticket-update-form {
  display: grid;
  gap: 8px;
  min-width: 220px;
}

.ticket-update-form label.wide,
.ticket-update-form .form-actions {
  grid-column: auto;
}

.support-table td {
  vertical-align: top;
}

.support-table p {
  margin: 6px 0 0;
}

.detail-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  margin-bottom: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 0;
  padding: 16px;
}

.panel h2 {
  margin-top: 0;
}

.customer-head {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 18px;
  min-width: 0;
  padding: 16px;
}

.customer-head h2 {
  margin: 4px 0 0;
}

.kv {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 4px;
  padding: 9px 0;
}

.kv span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.kv strong {
  font-weight: 600;
}

.status-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.status-badge,
.ampel {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
  white-space: nowrap;
}

.status-badge {
  background: #e0f2fe;
  color: #075985;
}

.status-badge.ok,
.ampel.gruen {
  background: #dcfce7;
  color: #166534;
}

.status-badge.warn,
.ampel.gelb {
  background: #fef3c7;
  color: #92400e;
}

.status-badge.danger,
.ampel.rot {
  background: #fee2e2;
  color: #991b1b;
}

.warning-text {
  color: var(--danger);
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.empty,
.muted {
  color: var(--muted);
}

.list-hint {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  margin: 0 0 12px;
  padding: 10px 12px;
}

.inactive-customer-section {
  margin-top: 16px;
}

.inactive-customer-section summary {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
  padding: 11px 12px;
}

.inactive-customer-section[open] summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.inactive-table-wrap {
  border-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.customer-invoice-section {
  margin-top: 14px;
}

.customer-invoice-section summary {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  font-weight: 700;
  gap: 10px;
  justify-content: space-between;
  padding: 11px 12px;
}

.customer-invoice-section summary small {
  color: var(--muted);
  font-weight: 600;
}

.customer-invoice-section[open] summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.customer-invoice-section .table-wrap {
  border-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.inactive-row {
  color: var(--muted);
}

.inactive-row .entity-title,
.inactive-row .object-chip {
  color: var(--muted);
}

.entity-title {
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.entity-title:hover {
  color: var(--accent-dark);
}

.meta-line {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.object-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 220px;
}

.object-chip {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  min-height: 26px;
  padding: 4px 9px;
  text-decoration: none;
}

.object-chip:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.icon-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.icon-button {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  justify-content: center;
  min-height: 30px;
  min-width: 34px;
  padding: 5px 7px;
  text-decoration: none;
}

.icon-button:hover {
  background: #eef5f4;
  border-color: var(--accent);
}

.icon-button.pending {
  background: #f8fafc;
  border-color: var(--line);
  color: var(--muted);
}

.icon-button.sent {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.count-badge {
  align-items: center;
  background: #dcfce7;
  border: 1px solid #86efac;
  border-radius: 999px;
  color: #166534;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  height: 22px;
  justify-content: center;
  min-width: 22px;
  padding: 0 7px;
}

.count-badge.pending {
  background: #f1f5f9;
  border-color: var(--line);
  color: var(--muted);
}

.count-badge.sent {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.action-history {
  margin-top: 8px;
}

.action-history summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.action-history ul {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 6px;
  list-style: none;
  margin: 8px 0 0;
  min-width: 230px;
  padding: 8px;
}

.action-history li {
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.action-history li span {
  color: var(--muted);
}

.action-history li strong {
  font-weight: 700;
  text-align: right;
}

.status-badge.neutral {
  background: #f1f5f9;
  color: var(--muted);
}

.calendar-stats {
  margin-bottom: 18px;
}

.calendar-filter {
  align-items: end;
}

.calendar-legend {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 14px;
}

.calendar-legend span {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
  padding: 6px 10px;
}

.calendar-exports {
  align-items: center;
}

.calendar-exports strong {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.priority-dot {
  border-radius: 999px;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.priority-badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  padding: 5px 7px;
  text-transform: uppercase;
  white-space: nowrap;
}

.priority-badge.priority-dringend,
.priority-dot.priority-dringend {
  background: #fee2e2;
  color: #991b1b;
}

.priority-badge.priority-hoch,
.priority-dot.priority-hoch {
  background: #ffedd5;
  color: #9a3412;
}

.priority-badge.priority-normal,
.priority-dot.priority-normal {
  background: #dbeafe;
  color: #1d4ed8;
}

.priority-badge.priority-niedrig,
.priority-dot.priority-niedrig {
  background: #dcfce7;
  color: #166534;
}

.calendar-shell {
  margin-bottom: 18px;
}

.calendar-title {
  margin-bottom: 10px;
}

.calendar-title h2 {
  margin: 0;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.calendar-weekdays span {
  padding: 0 4px;
}

.calendar-day {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 158px;
  padding: 8px;
}

.calendar-day-empty {
  background: transparent;
  border-color: transparent;
}

.calendar-day.today {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.calendar-day.overdue {
  border-color: #fecaca;
}

.calendar-day-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
}

.calendar-day-head strong {
  font-size: 16px;
}

.calendar-day-head span,
.calendar-more {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.calendar-list {
  display: grid;
  gap: 8px;
}

.calendar-item {
  border-left: 4px solid #93c5fd;
  border-radius: 6px;
  display: grid;
  gap: 5px;
  padding: 7px 8px;
}

.calendar-item.priority-dringend {
  border-left-color: #dc2626;
}

.calendar-item.priority-hoch {
  border-left-color: #f97316;
}

.calendar-item.priority-normal {
  border-left-color: #2563eb;
}

.calendar-item.priority-niedrig {
  border-left-color: #16a34a;
}

.calendar-item-head {
  align-items: flex-start;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.calendar-item-head strong {
  font-size: 13px;
  line-height: 1.25;
}

.calendar-item-sub,
.calendar-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 6px 10px;
}

.calendar-meta a {
  color: var(--accent-dark);
  font-weight: 700;
}

.week-planner {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 18px;
  padding: 16px;
}

.section-title-row {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title-row h2 {
  margin: 0;
}

.section-title-row span {
  color: var(--muted);
  font-weight: 700;
}

.week-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(7, minmax(220px, 1fr));
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

.week-day {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 220px;
  padding: 10px;
}

.week-day-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 9px;
}

.week-day-head span {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  min-width: 24px;
  padding: 2px 7px;
  text-align: center;
}

.week-day-list {
  display: grid;
  gap: 8px;
}

.week-task {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid #2563eb;
  border-radius: 6px;
  display: grid;
  padding: 9px;
}

.week-task[open] {
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}

.week-task-summary {
  cursor: pointer;
  display: grid;
  gap: 8px;
  list-style: none;
}

.week-task-summary::-webkit-details-marker {
  display: none;
}

.week-task.priority-dringend {
  border-left-color: #dc2626;
}

.week-task.priority-hoch {
  border-left-color: #f97316;
}

.week-task.priority-normal {
  border-left-color: #2563eb;
}

.week-task.priority-niedrig {
  border-left-color: #16a34a;
}

.week-task-title {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

.week-task-title strong {
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: break-word;
}

.week-task-open {
  justify-self: start;
  pointer-events: none;
}

.week-task[open] .week-task-open {
  display: none;
}

.week-plan-form {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  min-width: 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.week-plan-form label {
  gap: 3px;
}

.week-plan-form label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.week-plan-form input,
.week-plan-form select {
  min-height: 32px;
  padding: 5px 7px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 18px;
}

.form-section {
  border-bottom: 1px solid var(--line);
  grid-column: 1 / -1;
  margin: 4px 0 2px;
  padding-bottom: 8px;
}

.drop-zone {
  border: 2px dashed #9fb0c0;
  border-radius: 6px;
  background: #f8fafc;
  padding: 18px;
}

.drop-zone input {
  border: 0;
  background: transparent;
  padding-left: 0;
}

label {
  display: grid;
  gap: 6px;
}

.checkbox-field {
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: 38px;
}

.checkbox-field input {
  min-height: 0;
  width: auto;
}

.switch-field {
  gap: 8px;
}

.switch-control {
  align-items: center;
  display: flex;
  gap: 10px;
  min-height: 38px;
}

.switch-control input[type="checkbox"],
.switch-control input[type="hidden"] {
  height: 1px;
  min-height: 0;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.switch-track {
  background: #cbd5e1;
  border: 1px solid #94a3b8;
  border-radius: 999px;
  display: inline-flex;
  flex: 0 0 auto;
  height: 28px;
  position: relative;
  transition: background 0.18s ease, border-color 0.18s ease;
  width: 52px;
}

.switch-track::after {
  background: #ffffff;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.24);
  content: "";
  height: 22px;
  left: 2px;
  position: absolute;
  top: 2px;
  transition: transform 0.18s ease;
  width: 22px;
}

.switch-control input[type="checkbox"]:checked ~ .switch-track {
  background: var(--accent);
  border-color: var(--accent-dark);
}

.switch-control input[type="checkbox"]:checked ~ .switch-track::after {
  transform: translateX(24px);
}

.switch-control input[type="checkbox"]:focus-visible ~ .switch-track {
  outline: 2px solid #93c5fd;
  outline-offset: 2px;
}

.switch-text {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 700;
  gap: 1px;
}

.switch-control input[type="checkbox"]:checked ~ .switch-text span:first-child,
.switch-control input[type="checkbox"]:not(:checked) ~ .switch-text span:last-child {
  color: var(--text);
}

label.wide,
.form-actions {
  grid-column: 1 / -1;
}

label span {
  color: var(--muted);
  font-weight: 600;
}

input,
select,
textarea {
  max-width: 100%;
  width: 100%;
  min-height: 38px;
  border: 1px solid #c8d2dc;
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  background: #ffffff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 8px;
}

.notice {
  padding: 12px 14px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 6px;
}

.notice.error {
  background: #fef3f2;
  border-color: #fecdca;
  color: var(--danger);
}

.notice.success {
  background: #ecfdf3;
  border-color: #bbf7d0;
  color: #166534;
}

.accounting-intro {
  align-items: center;
  background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 72%);
  border-color: #a7d9ce;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.accounting-intro h2,
.accounting-statement h3,
.accounting-summary h3 {
  margin: 4px 0 8px;
}

.accounting-intro p,
.accounting-locked p {
  color: var(--muted);
  margin: 0;
  max-width: 760px;
}

.eyebrow {
  color: var(--accent-dark);
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.accounting-setup {
  margin-bottom: 18px;
}

.accounting-setup details > summary,
.accounting-report > summary,
.journal-action > summary {
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 800;
  padding: 8px 0;
}

.accounting-setup-form {
  border: 0;
  margin-top: 8px;
  padding: 8px 0 0;
}

.accounting-filter {
  align-items: end;
}

.section-title-row p {
  margin: 4px 0 0;
}

.section-title-row .status-badge.ok {
  color: #166534;
}

.section-title-row .status-badge.warn {
  color: #92400e;
}

.section-title-row .status-badge.danger {
  color: #991b1b;
}

.source-badge {
  background: #f1f5f9;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted) !important;
  display: inline-flex;
  font-size: 11px;
  padding: 5px 9px;
  white-space: nowrap;
}

.source-badge.ledger {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #166534 !important;
}

.accounting-summary-groups {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.accounting-summary {
  border-left: 5px solid #94a3b8;
  border-radius: 6px;
  padding-left: 14px;
}

.accounting-summary.income-summary {
  border-left-color: #16a34a;
}

.accounting-summary.expense-summary {
  border-left-color: #ea580c;
}

.accounting-summary.cash-summary {
  border-left-color: #2563eb;
}

.accounting-summary .stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.accounting-summary .stat strong,
.accounting-ledger-stats .stat strong {
  font-size: clamp(20px, 2.2vw, 27px);
}

.accounting-locked {
  border-style: dashed;
  margin: 18px 0;
}

.accounting-source-sync {
  margin: 22px 0;
}

.source-sync-stats {
  margin-bottom: 14px;
}

.source-sync-stats .stat strong {
  font-size: 24px;
}

.source-sync-table td {
  vertical-align: top;
}

.source-book-form {
  margin: 0;
}

.accounting-ledger-stats {
  margin-bottom: 16px;
}

.accounting-report-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 16px;
}

.accounting-statement {
  overflow: hidden;
}

.accounting-statement table {
  min-width: 430px;
}

.accounting-report {
  margin: 12px 0;
}

.accounting-report > summary {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
}

.accounting-report[open] > summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.accounting-report[open] > .table-wrap {
  border-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.accounting-table table {
  min-width: 980px;
}

.accounting-workflow {
  align-items: start;
  margin-top: 18px;
}

.accounting-posting .form-grid,
.accounting-period-lock .form-grid {
  border: 0;
  padding: 0;
}

.accounting-preview {
  border: 2px solid #fbbf24;
  margin-top: 18px;
}

.accounting-preview table {
  min-width: 520px;
}

.preview-actions {
  align-items: center;
}

.preview-actions form {
  margin: 0;
}

.journal-action {
  margin-top: 8px;
}

.journal-action > summary {
  color: var(--danger);
  font-size: 12px;
}

.compact-action-form {
  display: grid;
  gap: 8px;
  margin-top: 6px;
  min-width: 220px;
}

.compact-action-form label span {
  font-size: 11px;
}

.compact-action-form input {
  min-height: 32px;
  padding: 5px 7px;
}

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
  }

  aside {
    position: relative;
    padding: 16px;
  }

  .brand {
    margin-bottom: 14px;
    min-height: 44px;
  }

  .brand img {
    height: 42px;
    width: 42px;
  }

  nav {
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  }

  .nav-section {
    grid-column: 1 / -1;
  }

  .nav-section summary {
    margin: 10px 6px 0;
  }

  .nav-section-links {
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  }

  nav a {
    text-align: center;
    padding: 8px 6px;
  }

  main {
    padding: 18px;
    max-width: none;
  }

  .stats,
  .support-layout,
  .form-grid,
  .intake-form {
    grid-template-columns: 1fr;
  }

  .calendar-weekdays {
    display: none;
  }

  .calendar-grid {
    grid-template-columns: 1fr;
  }

  .calendar-day-empty {
    display: none;
  }

  .accounting-report-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 13px;
  }

  .login-shell {
    align-items: stretch;
    padding: 12px;
  }

  .login-panel {
    align-self: center;
    padding: 18px;
  }

  aside {
    padding: 12px;
  }

  .brand {
    font-size: 17px;
    gap: 9px;
  }

  nav {
    gap: 6px;
    grid-template-columns: 1fr;
  }

  .nav-section summary {
    background: #293643;
    border-radius: 6px;
    margin: 6px 0 0;
    padding: 9px 10px;
  }

  .nav-section-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding-top: 6px;
  }

  nav a {
    min-height: 38px;
    padding: 8px;
  }

  main {
    padding: 12px;
  }

  header {
    margin-bottom: 14px;
  }

  h1 {
    font-size: 22px;
    line-height: 1.2;
  }

  h2 {
    font-size: 17px;
    margin: 20px 0 10px;
  }

  .toolbar,
  .action-bar,
  .calendar-legend,
  .calendar-exports,
  .work-area div,
  .icon-actions {
    gap: 7px;
  }

  .button {
    min-height: 40px;
    width: 100%;
  }

  .button.small,
  .icon-button,
  .work-area a {
    flex: 1 1 auto;
    min-height: 36px;
    white-space: normal;
  }

  .filter-bar,
  .form-grid,
  .intake-panel,
  .panel,
  .stat,
  .week-planner,
  .work-area {
    padding: 12px;
  }

  .filter-bar,
  .work-areas,
  .stats {
    gap: 10px;
    grid-template-columns: 1fr;
  }

  .detail-grid {
    gap: 12px;
    grid-template-columns: minmax(0, 1fr);
  }

  .customer-head,
  .section-title-row,
  .week-task-title,
  .calendar-item-head {
    align-items: stretch;
    flex-direction: column;
  }

  .accounting-intro {
    align-items: stretch;
    flex-direction: column;
  }

  .accounting-summary .stats {
    grid-template-columns: 1fr;
  }

  .customer-head {
    gap: 10px;
    padding: 12px;
  }

  .object-chips {
    min-width: 0;
  }

  th,
  td {
    padding: 9px 10px;
  }

  table {
    font-size: 13px;
    min-width: 620px;
  }

  .calendar-day {
    min-height: 0;
  }

  .week-grid {
    grid-template-columns: 1fr;
    overflow-x: visible;
  }

  .week-day {
    min-height: 0;
  }

  .form-actions {
    justify-content: stretch;
  }
}

@media (max-width: 380px) {
  .nav-section-links {
    grid-template-columns: 1fr;
  }

  main {
    padding: 10px;
  }

  .filter-bar,
  .form-grid,
  .intake-panel,
  .panel,
  .stat,
  .week-planner,
  .work-area,
  .customer-head {
    padding: 10px;
  }
}
