:root {
  --ink: #1c2430;
  --muted: #6b7785;
  --line: #e2e8ee;
  --paper: #eef2f5;
  --card: #ffffff;
  --sidebar: #2b323c;
  --sidebar-2: #232a33;
  --sidebar-text: #c5ccd4;
  --sidebar-active: #3d9a7a;
  --sidebar-active-bg: rgba(61, 154, 122, 0.22);
  --accent: #2f8f72;
  --accent-dark: #24785e;
  --warn: #9a6700;
  --err: #a11d2e;
  --ok: #0a7a3e;
  --info: #1a5f9e;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "DM Sans", system-ui, sans-serif;
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
  line-height: 1.45;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- App shell (RexQA-style) ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}

.sidebar-brand {
  padding: 1.15rem 1.1rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo-link { display: block; text-decoration: none; }
.sidebar-logo {
  display: block;
  width: 100%;
  max-width: 168px;
  height: auto;
}

.sidebar-product {
  margin-top: 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  line-height: 1.3;
}

.sidebar-nav {
  padding: 1rem 0.7rem;
  flex: 1;
  overflow-y: auto;
}

.nav-group-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a939e;
  padding: 0.35rem 0.75rem 0.55rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.92rem;
  margin-bottom: 0.25rem;
}
.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
  text-decoration: none;
}
.nav-item.is-active {
  background: var(--sidebar-active-bg);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(61, 154, 122, 0.35);
}
.nav-ico {
  width: 1.15rem;
  text-align: center;
  opacity: 0.9;
  color: var(--sidebar-active);
  font-size: 0.85rem;
}

.sidebar-foot {
  padding: 0.85rem 1.1rem 1.1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: grid;
  gap: 0.35rem;
}
.sidebar-version {
  font-size: 0.72rem;
  color: #8a939e;
  line-height: 1.35;
}
.sidebar-version span {
  display: inline-block;
  min-width: 4.6rem;
  color: #aeb6bf;
  font-weight: 600;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.35rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.nav-toggle {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  width: 2.25rem;
  height: 2.25rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--ink);
}

.topbar-spacer { flex: 1; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-meta { text-align: right; line-height: 1.2; }
.user-name { font-weight: 650; font-size: 0.9rem; }
.user-role { font-size: 0.72rem; color: var(--muted); font-weight: 500; }

.user-avatar {
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 50%;
  background: linear-gradient(145deg, #3d9a7a, #2a6f5a);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.wrap {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.35rem 1.35rem 2.5rem;
}

.auth-body {
  background:
    radial-gradient(900px 420px at 15% -10%, #d5ebe4 0%, transparent 55%),
    radial-gradient(700px 360px at 100% 0%, #e4eaf0 0%, transparent 50%),
    var(--paper);
}
.auth-wrap { padding-top: 4.5rem; }
.wrap-narrow { max-width: 420px; }

.site-foot {
  text-align: center;
  color: var(--muted);
  padding: 0 1rem 1.5rem;
}

h1 {
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  margin: 0 0 0.35rem;
}
.lede { color: var(--muted); margin: 0 0 1.25rem; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem 1.35rem;
  box-shadow: 0 1px 2px rgba(28, 36, 48, 0.04);
}

.filters {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr 0.9fr 0.7fr auto;
  gap: 0.65rem;
  margin-bottom: 1rem;
  align-items: end;
}
@media (max-width: 900px) {
  .filters { grid-template-columns: 1fr 1fr; }
}

.when {
  display: inline-block;
  line-height: 1.35;
  white-space: nowrap;
}

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="date"],
select,
textarea {
  width: 100%;
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; font-family: var(--sans); }
textarea.mono { font-family: var(--mono); font-size: 0.85rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 0.95rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
}
.btn:hover { background: var(--accent-dark); text-decoration: none; color: #fff; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.82rem; }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}
.btn-ghost:hover { color: var(--ink); background: #fff; }
.btn-block { width: 100%; }

.table-wrap { overflow-x: auto; }
table.clients {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.clients th,
table.clients td {
  text-align: left;
  padding: 0.65rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.clients th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
table.clients th.is-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
table.clients th.is-sortable:hover {
  color: var(--ink);
}
table.clients th.sort-asc::after {
  content: " ▲";
  font-size: 0.65em;
  color: var(--accent);
}
table.clients th.sort-desc::after {
  content: " ▼";
  font-size: 0.65em;
  color: var(--accent);
}
table.clients tr:hover td { background: #f7fafb; }
table.clients .col-address {
  min-width: 11rem;
  width: 18%;
}
table.clients .col-hours,
table.clients .hours-cell {
  max-width: 9.5rem;
  width: 9.5rem;
  font-size: 0.78rem;
  line-height: 1.35;
  word-break: break-word;
}
table.clients .col-actions {
  width: 2.5rem;
  text-align: center;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  color: var(--accent);
  text-decoration: none;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover {
  color: var(--accent-dark);
  background: rgba(47, 143, 114, 0.12);
  text-decoration: none;
}
.icon-btn-solid {
  color: #fff;
  background: var(--accent);
}
.icon-btn-solid:hover {
  color: #fff;
  background: var(--accent-dark);
}
button.icon-btn {
  font: inherit;
}
.code {
  font-family: var(--mono);
  font-size: 0.84rem;
  font-weight: 500;
}
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  letter-spacing: 0.02em;
}
.badge-muted { background: #e8eef2; color: #44525c; }
.badge-ok { background: #d8f0e3; color: #0a7a3e; }
.badge-warn { background: #f7e8c3; color: #8a5a00; }
.badge-info { background: #d9e8f7; color: #1a5f9e; }
.badge-gold { background: #f6e2a8; color: #7a5a00; }
.badge-plat { background: #dde3ea; color: #3a4550; }
.badge-silver { background: #e8e8e8; color: #444; }
.exp-ok { background: #d8f0e3; color: #0a7a3e; }
.exp-info { background: #d9e8f7; color: #1a5f9e; }
.exp-warn { background: #f7e8c3; color: #8a5a00; }
.exp-danger { background: #f8d9de; color: #a11d2e; }
.exp-muted { background: #e8eef2; color: #44525c; }

.num { text-align: right; font-variant-numeric: tabular-nums; }
.cost { font-weight: 700; color: var(--ok); }
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 960px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .kpi-row { grid-template-columns: 1fr; }
}

.kpi-card {
  display: block;
  text-align: center;
  text-decoration: none;
  color: #fff;
  border-radius: 8px;
  padding: 1.15rem 0.85rem 1rem;
  box-shadow: 0 2px 8px rgba(20, 28, 36, 0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(20, 28, 36, 0.18);
  text-decoration: none;
  color: #fff;
}
.kpi-ico {
  display: flex;
  justify-content: center;
  margin-bottom: 0.45rem;
  opacity: 0.95;
}
.kpi-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.kpi-label {
  margin-top: 0.35rem;
  font-size: 0.88rem;
  font-weight: 500;
  opacity: 0.95;
}
.kpi-total { background: linear-gradient(135deg, #5b2d8e 0%, #8b5cf6 100%); }
.kpi-gold { background: linear-gradient(135deg, #e6a817 0%, #f59e0b 100%); }
.kpi-plat { background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%); }
.kpi-silver { background: linear-gradient(135deg, #4b5563 0%, #1f2937 100%); }

.chart-panel {
  background: #2b323c;
  border-color: #3a424e;
  color: #fff;
}
.chart-panel .section-title {
  color: #fff;
  margin-bottom: 1rem;
}
.chart-wrap {
  max-width: 820px;
  margin: 0 auto;
  min-height: 320px;
}
.chart-wrap canvas {
  color: #fff;
}

.tech-edit-cell { min-width: 16rem; }
.tech-inline-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  align-items: center;
}
.tech-inline-form input[type="text"] {
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.4rem 0.5rem;
}
.tech-clarity-cell {
  width: 5.5rem;
  white-space: nowrap;
}
.tech-clarity-cell select {
  width: 100%;
  min-width: 4.5rem;
  font-size: 0.85rem;
  padding: 0.4rem 0.35rem;
}
@media (max-width: 1100px) {
  .tech-inline-form { grid-template-columns: 1fr; }
}

.premium-modules-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 1.25rem;
  margin-bottom: 0.5rem;
}
.premium-module-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.35;
  cursor: pointer;
}
.premium-module-item input {
  margin-top: 0.15rem;
  flex-shrink: 0;
}
@media (max-width: 720px) {
  .premium-modules-grid { grid-template-columns: 1fr; }
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-weight: 500;
}
.flash-ok { background: #d8f0e3; color: #0a7a3e; }
.flash-err { background: #f8d9de; color: #a11d2e; }

.auth-card { text-align: left; }
.auth-card .auth-logo {
  display: block;
  width: min(220px, 100%);
  height: auto;
  margin: 0 auto 1rem;
}
.auth-card h1 { margin-bottom: 0.25rem; text-align: center; }
.auth-card .lede { text-align: center; }
.auth-card .stack { display: grid; gap: 0.85rem; margin-top: 1.25rem; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.detail-grid-3 {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
.detail-grid-span-2 { grid-column: 1 / -1; }
@media (max-width: 720px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid-3 { grid-template-columns: 1fr; margin-bottom: 0; }
  .detail-grid-span-2 { grid-column: auto; }
}

/* Add client: form left, Plesk instructions right */
.add-client-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(16rem, 0.85fr);
  gap: 1.25rem;
  align-items: start;
  width: 100%;
}
.add-client-layout > :first-child {
  min-width: 0;
}
@media (max-width: 800px) {
  .add-client-layout {
    grid-template-columns: 1fr;
  }
  .plesk-guide {
    position: static;
  }
}
.add-client-form .form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
.add-client-form label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.plesk-guide {
  position: sticky;
  top: 4.5rem; /* below sticky topbar */
  align-self: start;
}
.plesk-guide ol {
  margin: 0;
  padding-left: 1.2rem;
  line-height: 1.55;
}
.plesk-guide li { margin-bottom: 0.65rem; }
.plesk-guide .dyn {
  font-family: var(--mono, "IBM Plex Mono", ui-monospace, monospace);
  font-size: 0.85em;
  word-break: break-all;
}


.dl {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 0.4rem 0.75rem;
  margin: 0;
  font-size: 0.92rem;
}
.dl dt { color: var(--muted); margin: 0; }
.dl dd { margin: 0; word-break: break-word; }
.legal-dl dd a { color: var(--info); }

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  letter-spacing: -0.01em;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.toolbar-logo {
  flex-shrink: 0;
  margin-left: auto;
}
.client-logo {
  display: block;
  max-height: 72px;
  max-width: 200px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.stack-form { display: grid; gap: 0.85rem; }
.form-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.35rem; }

.safe-box {
  border-left: 3px solid var(--accent);
  padding-left: 0.85rem;
  margin-top: 0.5rem;
}

.info-banner {
  margin: 0 0 0.85rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid #b8d4e8;
  border-radius: 8px;
  background: #e8f4fc;
  color: #1a4a6e;
  font-size: 0.92rem;
  line-height: 1.45;
}
.info-banner a {
  color: var(--info);
  font-weight: 500;
}
.info-banner strong {
  font-weight: 600;
}

.secret {
  font-family: var(--mono);
  font-size: 0.85rem;
  background: #f0f4f7;
  padding: 0.35rem 0.5rem;
  border-radius: 5px;
  display: inline-block;
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 24px rgba(0,0,0,0.25);
  }
  .sidebar.is-open { transform: translateX(0); }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
  body.nav-open::before {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(20, 28, 36, 0.45);
    z-index: 25;
  }
}
