:root {
  --bg: #f4f8fb;
  --panel: #ffffff;
  --panel-2: #eef6fb;
  --text: #102033;
  --muted: #52677b;
  --line: rgba(9, 31, 52, .13);
  --fox-bg: #07111f;
  --fox-bg-strong: #030915;
  --fox-surface: #0f1d2d;
  --fox-surface-2: #12263a;
  --blue: #00aff2;
  --blue-strong: #3894ff;
  --cyan: #46d4fe;
  --teal: #00aff2;
  --teal-2: #e5f7ff;
  --amber: #b7791f;
  --amber-2: #fff4dc;
  --red: #b42318;
  --red-2: #fde7e4;
  --blue-2: #e6eef8;
  --green: #25d990;
  --green-2: #e7fff5;
  --shadow: 0 16px 42px rgba(7, 17, 31, .1);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.boot, .loader {
  padding: 32px;
  color: var(--muted);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(0, 175, 242, .12), transparent 40%),
    var(--bg);
}

.login-panel {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-lockup, .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 150px;
  max-width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.login-logo {
  width: 190px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--fox-bg);
}

.brand {
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
}

.brand .brand-logo {
  width: 158px;
  margin-left: -2px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--text);
  color: white;
  font-weight: 800;
}

.brand-lockup h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.brand-lockup p, .page-head p, .drawer-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

.form-grid {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input, select, textarea, .control {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

textarea { resize: vertical; }

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 175, 242, .14);
}

.primary, .secondary, .ghost, .icon-btn {
  min-height: 38px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 750;
  white-space: nowrap;
}

.primary {
  background: linear-gradient(135deg, var(--blue), var(--blue-strong));
  color: white;
  padding: 0 15px;
  box-shadow: 0 10px 22px rgba(0, 175, 242, .22);
}

.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0 13px;
}

.secondary.danger {
  color: var(--red);
  border-color: #efb2ad;
}

.ghost {
  background: transparent;
  color: var(--muted);
  padding: 0 8px;
}

.icon-btn {
  width: 36px;
  min-height: 36px;
  padding: 0;
  background: var(--panel-2);
  color: var(--text);
  font-size: 22px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, var(--fox-bg), var(--fox-bg-strong));
  color: #f6fbff;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}

.brand strong {
  display: block;
  font-size: 15px;
}

.brand span {
  display: block;
  color: #adc0cf;
  font-size: 12px;
  margin-top: 2px;
}

.sidebar nav {
  display: grid;
  gap: 4px;
}

.nav-item {
  min-height: 40px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 7px;
  background: transparent;
  color: #adc0cf;
  padding: 0 10px;
  text-align: left;
  font-weight: 700;
}

.nav-item.active, .nav-item:hover {
  background: var(--fox-surface-2);
  color: #fff;
}

.logout { margin-top: auto; }

.main {
  min-width: 0;
}

.topbar {
  height: 70px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 248, .88);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.searchbox {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 560px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  padding: 0 11px;
  color: var(--muted);
}

.searchbox input {
  border: 0;
  box-shadow: none;
  padding-left: 0;
}

.user-pill {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 9px 13px;
  font-weight: 750;
}

.content {
  padding: 26px 24px 46px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.page-head h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

.toolbar {
  display: flex;
  gap: 9px;
  min-width: min(460px, 100%);
}

.kpi-grid, .stat-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: grid;
  gap: 8px;
}

.kpi span, .kpi small {
  color: var(--muted);
  font-weight: 700;
}

.kpi strong {
  font-size: 28px;
  line-height: 1;
}

.kpi.good { border-top: 3px solid var(--green); }
.kpi.warn { border-top: 3px solid var(--amber); }
.kpi.bad { border-top: 3px solid var(--red); }
.kpi.info { border-top: 3px solid var(--blue); }

.dashboard-grid, .settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, .8fr);
  gap: 14px;
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(22, 32, 34, .02);
  padding: 16px;
  min-width: 0;
}

.panel.wide {
  grid-column: span 1;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head.compact {
  margin-top: 8px;
  margin-bottom: 8px;
  align-items: baseline;
}

.panel-head h3, .panel-head h4, .drawer h4 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

th {
  text-align: left;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  padding: 0 12px 10px;
}

td {
  border-bottom: 1px solid #edf2f3;
  padding: 12px;
  vertical-align: middle;
}

tr[data-customer-id] {
  cursor: pointer;
}

tr[data-customer-id]:hover {
  background: #f8fbfb;
}

td strong {
  display: block;
  font-weight: 800;
}

td span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
  background: var(--panel-2);
  color: var(--muted);
}

.badge.good { background: var(--green-2); color: #08764c; }
.badge.warn { background: var(--amber-2); color: var(--amber); }
.badge.bad { background: var(--red-2); color: var(--red); }
.badge.info { background: var(--blue-2); color: var(--blue); }
.badge.soft { background: #f0f2f2; color: #6d777a; }

.task-list {
  display: grid;
  gap: 9px;
}

.task-row, .sync-list article, .task-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.task-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px;
  border-left: 4px solid var(--line);
}

.task-row.urgent, .task-card.urgent { border-left-color: var(--red); }
.task-row.high, .task-card.high { border-left-color: var(--amber); }
.task-row.normal, .task-card.normal { border-left-color: var(--blue); }

.task-row span {
  display: block;
  color: var(--muted);
  margin-top: 3px;
  font-size: 12px;
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 2fr 38px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 700;
}

.bar-row div {
  height: 8px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}

.bar-row i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
}

.sync-list {
  display: grid;
  gap: 9px;
}

.sync-list article {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 9px;
  padding: 11px;
}

.sync-list span:last-child {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(17, 25, 27, .34);
  display: flex;
  justify-content: flex-end;
}

.drawer {
  width: min(940px, 100%);
  height: 100vh;
  overflow: auto;
  background: var(--bg);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.drawer-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  background: rgba(245, 247, 248, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.drawer-head h3 {
  margin: 0;
  font-size: 24px;
}

.drawer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.drawer-grid section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.drawer-grid .span {
  grid-column: 1 / -1;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.button-row.compact .ghost {
  min-height: 30px;
  border: 1px solid var(--line);
}

.ghost.danger {
  color: var(--red);
}

.task-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.task-column {
  display: grid;
  align-content: start;
  gap: 10px;
}

.task-column h3 {
  margin: 0;
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.task-column h3 span {
  color: var(--muted);
}

.task-card {
  padding: 13px;
  display: grid;
  gap: 9px;
  border-left: 4px solid var(--line);
}

.task-card-head {
  display: flex;
  gap: 6px;
}

.task-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(3, 9, 21, .52);
}

.modal {
  width: min(720px, 100%);
  max-height: min(820px, calc(100vh - 44px));
  overflow: auto;
  background: var(--bg);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(3, 9, 21, .32);
}

.task-editor-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.rich-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.rich-toolbar {
  display: flex;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.rich-toolbar button {
  width: 34px;
  min-height: 34px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}

.rich-body {
  min-height: 170px;
  padding: 13px;
  line-height: 1.55;
  outline: none;
  color: var(--text);
}

.rich-body:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
}

.rich-body a {
  color: var(--blue-strong);
}

.operation-modal {
  width: min(760px, 100%);
}

.domain-modal {
  width: min(860px, 100%);
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.integration-grid section {
  display: grid;
  align-content: start;
  gap: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  background: #fff;
}

.integration-grid h4, .price-list h4 {
  margin: 0;
}

.checkline {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.checkline input {
  width: auto;
}

.hint {
  color: var(--muted);
  line-height: 1.45;
}

.lexware-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.lexware-grid article, .lexware-mini span {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.lexware-grid article {
  display: grid;
  gap: 6px;
  padding: 12px;
}

.lexware-grid span, .lexware-grid small {
  color: var(--muted);
}

.lexware-grid strong {
  font-size: 18px;
  line-height: 1.15;
}

.lexware-mini {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.lexware-mini span {
  padding: 8px;
  color: var(--muted);
  font-weight: 750;
}

.lexware-table {
  margin-bottom: 10px;
}

.lexware-table table {
  min-width: 760px;
}

.price-list {
  margin-top: 14px;
}

#priceRows {
  display: grid;
  gap: 8px;
}

.price-row {
  display: grid;
  grid-template-columns: 150px minmax(80px, .75fr) repeat(3, minmax(90px, 1fr));
  gap: 8px;
}

.meter {
  height: 9px;
  min-width: 90px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.settings-grid .wide {
  grid-column: 1 / -1;
}

.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.plan-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  display: grid;
  gap: 7px;
}

.plan-card span, .plan-card small, .kv dt {
  color: var(--muted);
}

.plan-card small {
  line-height: 1.55;
}

.kv {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
  margin: 0;
}

.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.empty.small {
  padding: 13px;
}

.alert {
  margin-top: 16px;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-weight: 700;
}

.alert.bad {
  color: var(--red);
  background: var(--red-2);
}

.alert.warn {
  color: var(--amber);
  background: var(--amber-2);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  min-width: 260px;
  max-width: min(440px, calc(100vw - 44px));
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius);
  padding: 13px 14px;
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow);
  transition: .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.bad { background: var(--red); }
.toast.warn { background: var(--amber); }
.toast.good { background: var(--teal); }

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.skeleton-grid div {
  height: 160px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #edf2f3, #fff, #edf2f3);
  background-size: 220% 100%;
  animation: pulse 1.1s linear infinite;
}

@keyframes pulse {
  from { background-position: 0 0; }
  to { background-position: -220% 0; }
}

@media (max-width: 1020px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    max-width: 100vw;
  }
  .sidebar nav {
    display: flex;
    overflow-x: auto;
    max-width: 100%;
  }
  .nav-item {
    width: auto;
  }
  .dashboard-grid, .settings-grid, .task-board, .kpi-grid, .stat-strip, .integration-grid, .lexware-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .drawer-grid, .mini-grid {
    grid-template-columns: 1fr;
  }
  .topbar, .page-head {
    align-items: stretch;
    flex-direction: column;
  }
  .price-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 18px 14px 34px;
    min-width: 0;
  }
  .topbar {
    padding: 12px 14px;
    height: auto;
  }
  .sidebar {
    padding: 12px;
  }
  .toolbar {
    min-width: 0;
    flex-direction: column;
  }
  .price-row {
    grid-template-columns: 1fr;
  }
  .page-head h2 {
    font-size: 24px;
  }
}
