* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-family);
  background: var(--page-bg);
  color: var(--text-primary);
}

a {
  text-decoration: none;
  color: inherit;
}

.icon-svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ---------- Login ---------- */

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--page-bg);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.login-title {
  margin: 0 0 6px;
  font-size: 20px;
}

.login-subtitle {
  margin: 0 0 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.login-card .form-field {
  margin-bottom: 16px;
}

.login-submit {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

/* ---------- Shell layout ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease;
  overflow: hidden;
}

:root[data-sidebar="collapsed"] .sidebar {
  width: 72px;
}

:root[data-sidebar="collapsed"] .nav-link span,
:root[data-sidebar="collapsed"] .nav-toggle span,
:root[data-sidebar="collapsed"] .submenu,
:root[data-sidebar="collapsed"] .logo-text,
:root[data-sidebar="collapsed"] .nav-toggle-btn {
  display: none;
}

:root[data-sidebar="collapsed"] .sidebar-logo,
:root[data-sidebar="collapsed"] .nav-row {
  justify-content: center;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 20px;
  flex-shrink: 0;
}

.logo-mark {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.sidebar-logo-full {
  max-height: 56px;
  max-width: 100%;
  width: auto;
  object-fit: contain;
}

.logo-text {
  font-weight: 700;
  font-size: 20px;
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 140%);
  border-radius: 26px 26px 0 0;
  padding: 22px 14px;
  overflow-y: auto;
}

.sidebar-nav > ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.18);
  margin: 12px 10px;
}

.nav-item {
  margin-bottom: 3px;
  border-radius: var(--radius-sm);
}

.nav-link,
.nav-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: none;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  border-radius: var(--radius-sm);
  text-align: left;
}

.nav-row {
  display: flex;
  align-items: center;
}

.nav-row .nav-link {
  flex: 1;
}

.nav-toggle-btn {
  border: none;
  background: none;
  cursor: pointer;
  padding: 8px;
  color: rgba(255, 255, 255, 0.6);
  display: flex;
}

.nav-link:hover,
.nav-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.nav-item.active > .nav-link,
.nav-link.active {
  background: #fff;
  color: var(--primary-dark);
  font-weight: 600;
  box-shadow: 0 4px 10px -4px rgba(0, 0, 0, 0.3);
}

.nav-item.active-parent > .nav-toggle,
.nav-item.active-parent > .nav-row .nav-link {
  color: #fff;
  font-weight: 600;
}

.chevron {
  margin-left: auto;
  display: flex;
  transition: transform 0.15s ease;
}

.nav-item.open > .nav-toggle .chevron,
.nav-item.open > .nav-row .nav-toggle-btn {
  transform: rotate(180deg);
}

.submenu {
  list-style: none;
  margin: 6px 0 6px 40px;
  padding: 0 0 0 18px;
  border-left: 2px solid rgba(255, 255, 255, 0.25);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.nav-item.open > .submenu {
  max-height: 400px;
}

.submenu li {
  margin-bottom: 2px;
}

.submenu li a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.72);
  border-radius: 8px;
}

.submenu li a::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  flex-shrink: 0;
  transition: background 0.15s ease;
}

.submenu li a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.submenu li a:hover::before {
  background: #fff;
}

.submenu li a.active {
  color: var(--primary-dark);
  font-weight: 600;
  background: #fff;
}

.submenu li a.active::before {
  background: var(--primary-dark);
}

.nav-item.nested {
  margin-top: 2px;
}

.nested-toggle {
  padding-left: 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.72);
}

.nested .submenu {
  margin-left: 18px;
}

/* ---------- Main / topbar ---------- */

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
}

.topbar-start {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--page-bg);
  border-radius: 10px;
  padding: 8px 14px;
  width: 320px;
  color: var(--text-muted);
}

.search-box input {
  border: none;
  background: none;
  outline: none;
  font: inherit;
  color: var(--text-primary);
  width: 100%;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.theme-swatches {
  display: flex;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
}

.swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.swatch-purple {
  background: #7c5cfc;
}

.swatch-orange {
  background: #ff8a3d;
}

.swatch.is-active {
  border-color: var(--text-primary);
}

.icon-btn {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  display: flex;
  align-items: center;
}

.theme-toggle-btn .icon-sun,
.theme-toggle-btn .icon-moon {
  display: flex;
}

.theme-toggle-btn .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle-btn .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle-btn .icon-moon {
  display: flex;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
}

/* ---------- Content ---------- */

.content {
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}

.page-header h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.page-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13.5px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--page-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

/* ---------- Dashboard overview ---------- */

.hero-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
  align-items: stretch;
}

.hero-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: 0 12px 28px -12px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-side-stats {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero-side-stats .card {
  padding: 16px 20px;
}

.hero-side-stats .split-card {
  flex: 1;
  justify-content: center;
}

.hero-side-stats .panel-title {
  font-size: 14px;
}

.hero-side-stats .split-row {
  margin-top: 6px;
}

.hero-side-stats .kpi-value {
  font-size: 19px;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.hero-label {
  opacity: 0.85;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  margin: 0 0 4px;
}

.hero-value {
  font-size: 27px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
}

.hero-top-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.hero-badge {
  background: rgba(255, 255, 255, 0.18);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hero-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a7f3d0;
}

.hero-badge.is-quiet::before {
  background: rgba(255, 255, 255, 0.55);
}

.hero-actions {
  display: flex;
  gap: 10px;
}

.hero-action-btn {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease;
}

.hero-action-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}

.hero-sub {
  margin-top: 3px;
  font-size: 12px;
  opacity: 0.85;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.hero-stat {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 9px 8px;
  min-width: 0;
}

.hero-stat-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease;
}

.hero-stat-link:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.hero-stat-icon {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 5px;
}

.hero-stat-icon .icon-svg {
  width: 11px;
  height: 11px;
}

.hero-stat-label {
  font-size: 11.5px;
  opacity: 0.85;
  line-height: 1.25;
  white-space: nowrap;
}

.hero-stat-value {
  font-size: 17px;
  font-weight: 700;
  margin-top: 2px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.kpi-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-label {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  margin: 2px 0 0;
}

.split-card {
  display: flex;
  flex-direction: column;
}

.split-row {
  display: flex;
  align-items: center;
  margin-top: 10px;
}

.split-stat {
  flex: 1;
  text-align: center;
}

.split-divider {
  width: 1px;
  align-self: stretch;
  background: var(--border-color);
  margin: 0 16px;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.panel-title {
  margin: 0 0 4px;
  font-size: 16px;
}

.panel-subtitle {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- Activity / expiry list panels ---------- */

.list-panel {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list-panel-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-color);
}

.list-panel-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.list-panel-item:first-child {
  padding-top: 0;
}

.list-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.list-icon .icon-svg {
  width: 17px;
  height: 17px;
}

.list-icon.is-warning {
  background: #fef3c7;
  color: #b45309;
}

.list-body {
  flex: 1;
  min-width: 0;
}

.list-title {
  font-size: 13.5px;
  font-weight: 500;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-subtitle {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.list-title a {
  color: inherit;
  text-decoration: none;
}

.list-title a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.list-meta {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.list-meta.is-warning {
  color: #b45309;
  font-weight: 500;
}

/* ---------- Tables / empty states ---------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.row-actions {
  display: flex;
  gap: 14px;
}

.row-actions a {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
}

.row-actions a.text-danger {
  color: #dc2626;
}

.empty-state {
  text-align: center;
}

.empty-body {
  padding: 36px 16px;
}

.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.empty-icon .icon-svg {
  width: 24px;
  height: 24px;
}

.empty-state h3 {
  margin: 0 0 6px;
}

.empty-state p {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- Forms ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-columns {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}

.form-column {
  flex: 1;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.user-type-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.radio-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.radio-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-primary);
  cursor: pointer;
}

.radio-pill input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.form-field input,
.form-field select,
.form-field textarea {
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font: inherit;
  color: var(--text-primary);
  background: var(--page-bg);
}

.form-field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  background: none;
  align-self: flex-start;
}

.days-input {
  width: 70px;
}

.form-field textarea {
  resize: vertical;
  min-height: 90px;
}

.form-actions {
  margin-top: 22px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.form-note {
  color: var(--text-muted);
  font-size: 13px;
}

.field-error {
  color: #dc2626;
  font-size: 12.5px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.status-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--success-bg);
  color: var(--success);
}

.status-pill.pending {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.status-pill.active {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.status-pill.suspended {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
}

.status-pill.terminated {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

.status-pill.info {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.client-header-card {
  margin-bottom: 20px;
}

.client-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.client-avatar-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar-lg {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.client-avatar-block h2 {
  margin: 0 0 4px;
  font-size: 18px;
}

.client-avatar-block p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13.5px;
}

.client-header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.client-badges {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.detail-list {
  margin: 0;
}

.detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
}

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

.detail-row dt {
  margin: 0;
  color: var(--text-muted);
  font-weight: 500;
}

.detail-row dd {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  text-align: right;
}

.link-action {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary-dark);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
}

.link-action.text-danger-link {
  color: #dc2626;
}

.inline-form {
  display: inline-flex;
  align-items: center;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: #9ca3af;
}

.status-dot.online {
  background: #10b981;
}

.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: 10px;
  padding: 10px 16px;
  margin-bottom: 16px;
}

.bulk-toolbar[hidden] {
  display: none;
}

.bulk-toolbar span {
  font-weight: 600;
  color: var(--primary-dark);
  margin-right: auto;
}

.data-table th input[type="checkbox"],
.data-table td input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.messages {
  margin-bottom: 16px;
}

.message-banner {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 8px;
}

.message-banner.success {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.message-banner.error {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}

.message-banner.warning {
  background: rgba(245, 158, 11, 0.15);
  color: #d97706;
}

.message-banner.info {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.option-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.option-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--page-bg);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary);
}

.option-pill .icon-svg {
  width: 16px;
  height: 16px;
}

.option-pill.is-active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.option-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
}

.logo-preview-img {
  display: none;
  max-width: 140px;
  max-height: 80px;
  margin-top: 8px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  object-fit: contain;
  background: var(--page-bg);
}

@media (max-width: 900px) {
  .hero-stats,
  .hero-row,
  .panel-grid,
  .form-grid,
  .settings-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
}
