:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --accent-2: #7c3aed;
  --accent-2-soft: #ede9fe;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.sidebar {
  width: 230px;
  background: var(--accent);
  color: #ffffff;
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
}

.brand-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #9ca3af;
}

.brand-title {
  margin: 4px 0 2px;
  font-size: 18px;
}

.brand-sub {
  margin: 0;
  font-size: 12px;
  color: #9ca3af;
}

.nav {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 6px;
  color: inherit;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.14);
}

.nav-item--active {
  background: #ffffff;
  color: var(--accent);
}


body.sidebar-collapsed .sidebar {
  display: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-bottom: 12px;
}

.sidebar-toggle {
  border-color: rgba(37, 99, 235, 0.35);
}

.main {
  flex: 1;
  padding: 24px 32px 32px;
}

.panel {
  max-width: 1400px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 20px 22px 22px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

.panel--wide {
  max-width: none;
}

.panel-head h2 {
  margin: 6px 0 4px;
  font-size: 22px;
}

.panel-title--center {
  text-align: center;
}

.breadcrumb {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: #9ca3af;
}

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

.grid-two {
  display: block;
}

.card {
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 18px 18px 20px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.list-count {
  font-size: 12px;
  color: var(--muted);
}

.form-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 18px;
}

@media (max-width: 1100px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="datetime-local"],
.form-group select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 13px;
}

.form-group--checkbox label {
  font-weight: 400;
}

.form-group--full {
  grid-column: 1 / -1;
}

.form-actions {
  grid-column: 1 / -1;
  margin-top: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

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

.btn--danger {
  background: var(--danger);
  color: #ffffff;
}

.btn--secondary {
  background: #f9fafb;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn--ghost {
  background: transparent;
  border: 1px solid var(--border);
  padding-inline: 8px;
}

.btn--small {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
}

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

.btn--ghost.btn--danger {
  border-color: rgba(220, 38, 38, 0.35);
  color: var(--danger);
}

.btn--ghost.btn--danger:hover {
  background: #fee2e2;
}

.input {
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12px;
  background: #ffffff;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.alert {
  margin-top: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 13px;
}

.alert--error {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.alert--success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.phone-fields {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0;
}

.phone-item {
  display: flex;
  gap: 4px;
}

.phone-item input {
  flex: 1;
}

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

@media (max-width: 900px) {
  .preview-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.preview-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.preview {
  min-height: 110px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #020617;
  color: #e5e7eb;
  border: 1px solid #111827;
  font-size: 12px;
  overflow: auto;
  white-space: pre-wrap;
}

/* A4-like provision form */
.a4-shell {
  display: flex;
  justify-content: center;
  padding: 10px 0 2px;
}

.a4-sheet {
  width: 100%;
  max-width: 210mm;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  padding: 18mm 16mm;
}

.a4-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.8);
}

.a4-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.01em;
}

.a4-meta {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.a4-badge {
  align-self: flex-start;
  padding: 6px 10px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-soft), var(--accent-2-soft));
  color: #0f172a;
  border: 1px solid rgba(37, 99, 235, 0.16);
  font-size: 12px;
  font-weight: 600;
}

.a4-form {
  margin-top: 14px;
}

.a4-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(229, 231, 235, 0.85);
}

.a4-section:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

.a4-section-title {
  margin: 0 0 18px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #4b5563;
  text-align: center;
}

.a4-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
  margin-top: 2px;
}

@media (max-width: 820px) {
  .a4-sheet {
    padding: 18px 16px;
    border-radius: 10px;
  }
  .a4-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.a4-row label {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

.a4-row--full {
  grid-column: 1 / -1;
}

.a4-row input,
.a4-row select {
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid rgba(229, 231, 235, 0.95);
  font-size: 13px;
  font-weight: 600;
  background: #ffffff;
  line-height: 1.2;
  min-height: 40px;
}

.a4-row input::placeholder {
  color: #9ca3af;
}

.a4-row input:focus,
.a4-row select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  outline-offset: 1px;
  border-color: rgba(37, 99, 235, 0.55);
}

.a4-row input[type="datetime-local"] {
  font-variant-numeric: tabular-nums;
}

.phone-item .btn--ghost {
  min-height: 40px;
  border-radius: 8px;
}

.a4-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.a4-sep {
  border: none;
  height: 1px;
  margin: 14px 0;
  background: linear-gradient(
    90deg,
    rgba(229, 231, 235, 0),
    rgba(229, 231, 235, 1),
    rgba(229, 231, 235, 0)
  );
}

.table-wrap {
  margin-top: 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;

  -webkit-overflow-scrolling: touch;
}

.table-tools--spaced {
  margin-bottom: 14px;
}

.table-wrap table {
  width: 100%;
  min-width: 1200px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.table-wrap th,
.table-wrap td {
  padding: 6px 8px;
  border-bottom: 1px solid #e5e7eb;
  border-right: 1px solid #d1d5db;
  vertical-align: top;
}

.table-wrap td:last-child,
.table-wrap th:last-child {
  border-right: none;
}

.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.table-wrap th {
  background: #f9fafb;
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #374151;
}

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

.table-wrap tbody tr:nth-child(2n) td {
  background: #fcfcfd;
}

.table-wrap tbody tr:hover td {
  background: #f8fafc;
}

.table-wrap td.client-index {
  color: var(--accent);
  font-weight: 700;
}

.table-wrap input[type="datetime-local"] {
  width: 190px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12px;
}

.table-tools {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin: 10px 0 6px;
}

.table-tools__left {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.table-tools--centered {
  flex-direction: column;
  align-items: center;
}

.table-tools--centered .table-tools__left {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 12px 18px;
  width: 100%;
  max-width: 1100px;
}

.table-tools--centered .tool-field {
  min-width: 0;
}

.table-tools--centered .tool-field--left {
  justify-self: end;
}

.table-tools--centered .tool-field--search {
  justify-self: center;
}

.table-tools--centered .tool-field--right {
  justify-self: start;
}

.table-tools--centered .tool-field label {
  width: 100%;
  text-align: center;
}

.table-tools--centered #users-search,
.table-tools--centered #subs-search,
.table-tools--centered #db-search,
.table-tools--centered #modules-search {
  width: 520px;
  max-width: 100%;
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 14px;
  border-color: rgba(37, 99, 235, 0.55);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.table-tools--centered #users-search:focus,
.table-tools--centered #subs-search:focus,
.table-tools--centered #db-search:focus,
.table-tools--centered #modules-search:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  outline-offset: 1px;
  border-color: rgba(37, 99, 235, 0.75);
}

.tool-field {
  min-width: 200px;
}

.tool-field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.tool-field input,
.tool-field select {
  width: 100%;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  background: #ffffff;
}

.pill {
  display: inline-block;
  padding: 2px 6px;
  margin: 1px 2px 1px 0;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
}

.pill--purple {
  background: var(--accent-2-soft);
  color: #5b21b6;
}

.pill--green {
  background: #dcfce7;
  color: #166534;
}

.pill--amber {
  background: #ffedd5;
  color: #9a3412;
}

.empty {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.bundle-select {
  min-width: 140px;
  padding: 4px 6px;
  font-size: 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.bundle-progress {
  margin-top: 4px;
  width: 130px;
  height: 6px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
  display: none;
}

.bundle-progress__bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.4s ease;
}

@keyframes apps-indeterminate {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}

.apps-progress {
  width: 420px;
  max-width: 100%;
  height: 8px;
}

.apps-progress .bundle-progress__bar {
  width: 30%;
  animation: apps-indeterminate 1.1s infinite ease-in-out;
  will-change: transform;
}

.bundle-progress--success .bundle-progress__bar {
  background: var(--success);
}

.bundle-progress--error .bundle-progress__bar {
  background: var(--danger);
}

.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
}

.info-tip__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: default;
  user-select: none;
}

.info-tip__text {
  display: none;
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  max-width: 70vw;
  padding: 8px 10px;
  border-radius: 10px;
  background: #111827;
  color: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
  font-size: 12px;
  line-height: 1.35;
  z-index: 50;
}

.info-tip:hover .info-tip__text {
  display: block;
}

.limit-input {
  width: 110px;
}

@media print {
  body { background: #ffffff; }
  .sidebar { display: none; }
  .main { padding: 0; }
  .panel { border: none; box-shadow: none; padding: 0; }
  .a4-sheet { box-shadow: none; border-radius: 0; border: none; padding: 0; max-width: none; }
}
