:root {
  --ink: #1b2430;
  --muted: #667085;
  --line: #d8dee8;
  --soft: #f5f7fb;
  --panel: #ffffff;
  --brand: #146c63;
  --brand-dark: #0f544e;
  --accent: #b35c2e;
  --danger: #b42318;
  --success: #027a48;
  --warning: #b54708;
  --shadow: 0 16px 45px rgba(27, 36, 48, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
input, select, textarea, button { font: inherit; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  background: #121a24;
  color: #fff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: var(--brand);
}

.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a {
  color: rgba(255,255,255,.76);
  padding: 10px 12px;
  border-radius: 8px;
}
.sidebar nav a.active, .sidebar nav a:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.sidebar-user {
  margin-top: auto;
  display: grid;
  gap: 4px;
  color: rgba(255,255,255,.7);
  font-size: 14px;
}
.sidebar-user strong { color: #fff; }
.sidebar-user a { color: #fff; margin-top: 8px; }

.main {
  margin-left: 248px;
  padding: 32px;
}

.public-main {
  min-height: 100vh;
  padding: 28px;
  display: grid;
  place-items: center;
}

.page-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 34px; line-height: 1.15; margin-bottom: 0; }
h2 { font-size: 18px; margin-bottom: 18px; }
.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 8px;
}

.panel, .card, .invoice-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel { padding: 20px; margin-bottom: 20px; }
.form-section { display: grid; gap: 16px; }
.stack { display: grid; gap: 18px; }

.button, button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 42px;
  cursor: pointer;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.button.primary, button.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.button.primary:hover, button.primary:hover { background: var(--brand-dark); }
.button.small, button.small { min-height: 34px; padding: 6px 10px; font-size: 13px; }

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
  font-size: 14px;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  min-height: 42px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .rich-editor:focus {
  outline: 3px solid rgba(20, 108, 99, .16);
  border-color: var(--brand);
}

.field-grid { display: grid; gap: 14px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-grid.four { grid-template-columns: 120px 120px 1fr auto; align-items: end; }

.invoice-grid { display: grid; gap: 20px; }
.settings-grid {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 20px;
  align-items: start;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.stat span, .client-grid span, .invoice-topline span, .price-summary span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.stat strong { display: block; font-size: 28px; margin-top: 4px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { text-align: left; padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.link-copy {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.link-copy input {
  min-width: 240px;
  background: #f8fafc;
  color: #344054;
  font-size: 12px;
  min-height: 34px;
  padding: 7px 9px;
}
.inline-form { display: inline; }
.inline-form button {
  border: 0;
  background: transparent;
  color: var(--brand);
  padding: 0;
  min-height: 0;
}
.empty { color: var(--muted); text-align: center; padding: 28px; }

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  background: #eef2f6;
  color: #344054;
}
.badge.active, .badge.paid { background: #ecfdf3; color: var(--success); }
.badge.expired, .badge.cancelled { background: #fef3f2; color: var(--danger); }
.badge.pending_payment, .badge.partially_paid { background: #fffaeb; color: var(--warning); }

.filters {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, minmax(140px, 1fr)) auto;
  gap: 12px;
}

.totals-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.totals-strip div {
  padding: 16px;
  display: grid;
  gap: 3px;
  border-right: 1px solid var(--line);
}
.totals-strip div:last-child { border-right: 0; background: #f0faf8; }
.totals-strip span { color: var(--muted); font-size: 13px; font-weight: 700; }
.totals-strip strong { font-size: 20px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar button { min-height: 34px; padding: 6px 10px; }
.rich-editor {
  min-height: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}
.form-actions { display: flex; gap: 12px; align-items: center; }
.muted { color: var(--muted); font-size: 14px; }

.auth-panel, .install-shell {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 40px;
  align-items: center;
}
.auth-panel h1, .install-shell h1 { font-size: 46px; margin-bottom: 12px; }
.form-card { padding: 24px; display: grid; gap: 16px; }
.install-form h2 { margin: 10px 0 0; }

.flash {
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-weight: 700;
  border: 1px solid transparent;
}
.flash.success { background: #ecfdf3; color: var(--success); border-color: #abefc6; }
.flash.danger { background: #fef3f2; color: var(--danger); border-color: #fecdca; }

.admin-edit {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  gap: 12px;
}
.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.permission-grid label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}
.permission-grid input { width: auto; min-height: 0; }

.client-shell {
  width: min(900px, 100%);
  display: grid;
  gap: 16px;
}
.client-header {
  background: #fff;
  border: 1px solid var(--line);
  border-top: 4px solid #00b77a;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.client-heading { flex: 1; }
.client-header h1 { font-size: 30px; }
.superprof-lockup {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #00a66f;
  font-weight: 900;
  letter-spacing: 0;
  white-space: nowrap;
}
.superprof-logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: #00b77a;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  font-family: Georgia, serif;
  font-style: italic;
}
.superprof-logo-text {
  color: #00a66f;
  font-size: 28px;
  line-height: 1;
}
.countdown {
  background: #0d2f29;
  color: #fff;
  border-radius: 8px;
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  box-shadow: 0 14px 34px rgba(13, 47, 41, .18);
}
.countdown span { color: rgba(255,255,255,.76); font-weight: 700; }
.countdown strong { font-size: 24px; }
.invoice-card {
  padding: 22px;
  display: grid;
  gap: 18px;
  box-shadow: 0 12px 32px rgba(27, 36, 48, .06);
}
.invoice-topline, .client-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.client-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.invoice-topline strong, .client-grid strong {
  display: block;
  margin-top: 3px;
}
.price-summary {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: grid;
  gap: 10px;
}
.price-summary div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.grand-total {
  font-size: 24px;
  color: var(--brand);
  font-weight: 900;
}
.payment-box {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.method-pill {
  width: fit-content;
  background: #eef8f6;
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 800;
  margin-bottom: 0;
}
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.panel-title h2 { margin: 0; }
.client-footer-statement {
  margin: 2px 0 0;
  text-align: center;
  color: #0d2f29;
  font-size: 18px;
}

.expired-page {
  min-height: calc(100vh - 56px);
  display: grid;
  place-items: center;
  width: min(680px, 100%);
}
.expired-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 34px;
  text-align: center;
  box-shadow: var(--shadow);
}
.expired-card h1 { color: var(--danger); margin-bottom: 12px; }

@media (max-width: 920px) {
  .sidebar {
    position: static;
    width: auto;
    padding: 16px;
  }
  .sidebar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .main { margin-left: 0; padding: 18px; }
  .stats-grid, .field-grid.three, .client-grid, .settings-grid, .auth-panel, .install-shell, .filters {
    grid-template-columns: 1fr;
  }
  .field-grid.two, .invoice-topline, .field-grid.four { grid-template-columns: 1fr; }
  .permission-grid { grid-template-columns: 1fr; }
  .page-heading, .client-header, .countdown {
    align-items: stretch;
    flex-direction: column;
  }
  .link-copy {
    grid-template-columns: 1fr;
  }
  .superprof-lockup {
    justify-content: flex-start;
  }
  .public-main { padding: 18px; }
}

@media print {
  .countdown { display: none; }
  body { background: #fff; }
  .public-main { padding: 0; }
  .invoice-card { box-shadow: none; }
}
