/* aaPHMS UI */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f1f5f9; --card: #fff; --border: #e2e8f0; --text: #1e293b; --muted: #64748b;
  --primary: #0284c7; --primary-dark: #0369a1; --danger: #dc2626; --success: #16a34a;
  --warning: #d97706; --info: #0891b2; --secondary: #64748b;
  --sidebar: #0f172a; --sidebar-text: #cbd5e1;
}
body { font-family: -apple-system, 'Segoe UI', Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin-bottom: 16px; }
h2 { font-size: 18px; margin-bottom: 12px; }
h3 { font-size: 15px; margin-bottom: 10px; }
.muted { color: var(--muted); }

/* Admin layout */
.admin-body { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: var(--sidebar); color: var(--sidebar-text); flex-shrink: 0; }
.sidebar .brand { font-size: 19px; font-weight: 700; color: #fff; padding: 18px 20px; border-bottom: 1px solid #1e293b; }
.sidebar .brand span { color: #38bdf8; }
.sidebar .brand small { font-size: 10px; color: var(--muted); font-weight: 400; }
.sidebar nav { padding: 10px 0 30px; }
.sidebar nav a { display: block; color: var(--sidebar-text); padding: 8px 20px; font-size: 13.5px; }
.sidebar nav a:hover { background: #1e293b; text-decoration: none; color: #fff; }
.sidebar nav a.active { background: #1e293b; color: #38bdf8; border-left: 3px solid #38bdf8; padding-left: 17px; }
.nav-head { padding: 14px 20px 4px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: #475569; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: var(--card); border-bottom: 1px solid var(--border); padding: 10px 24px; display: flex; justify-content: space-between; align-items: center; }
.topbar-right { display: flex; gap: 16px; align-items: center; font-size: 13px; }
.content { padding: 24px; flex: 1; }

/* Client layout */
.client-topbar { background: #0f172a; }
.client-topbar-inner { max-width: 1100px; margin: 0 auto; padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; }
.client-topbar .brand { font-size: 20px; font-weight: 700; color: #fff; display: flex; align-items: center; gap: 10px; }
.client-topbar .brand span { color: #38bdf8; }
.client-topbar .brand img { max-height: 32px; max-width: 160px; width: auto; height: auto; display: block; object-fit: contain; }
.client-nav { display: flex; gap: 18px; align-items: center; }
.client-nav a { color: #cbd5e1; font-size: 14px; }
.client-nav a:hover { color: #fff; text-decoration: none; }
.nav-toggle { display: none; background: none; border: 1px solid #334155; color: #cbd5e1; font-size: 20px; padding: 4px 12px; border-radius: 8px; cursor: pointer; }
.client-content { max-width: 1100px; margin: 24px auto; padding: 0 20px; min-height: 60vh; width: 100%; }
.client-footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px; }
.auth-wrap { max-width: 420px; margin: 8vh auto; padding: 0 20px; }

/* Components */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.row { display: flex; flex-wrap: wrap; gap: 20px; }
.col { flex: 1; min-width: 220px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; flex: 1; min-width: 160px; }
.stat-card .num { font-size: 26px; font-weight: 700; }
.stat-card .lbl { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--border); }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:hover td { background: #f8fafc; }

.btn { display: inline-block; background: #e2e8f0; color: var(--text); border: 0; padding: 9px 16px; border-radius: 7px; font-size: 13.5px; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(.95); text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { display: block; width: 100%; text-align: center; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.form-control, select.form-control, textarea.form-control { width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 7px; font-size: 14px; background: #fff; color: var(--text); font-family: inherit; }
.form-control:focus { outline: none; border-color: var(--primary); }
.form-inline { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #cffafe; color: #0e7490; }
.badge-secondary { background: #e2e8f0; color: #475569; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #dcfce7; color: #15803d; }
.alert-danger { background: #fee2e2; color: #b91c1c; }
.alert-warning { background: #fef3c7; color: #b45309; }
.alert-info { background: #cffafe; color: #0e7490; }

.pagination { margin-top: 16px; }
.pagination a { display: inline-block; padding: 6px 11px; border: 1px solid var(--border); border-radius: 6px; margin-right: 4px; background: #fff; }
.pagination a.current { background: var(--primary); color: #fff; border-color: var(--primary); }

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-head h1 { margin-bottom: 0; }
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.progress { background: #e2e8f0; border-radius: 6px; height: 8px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-2 { margin-top: 12px; } .mb-2 { margin-bottom: 12px; }
.w-50 { width: 50%; }
.ticket-msg { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 14px; }
.ticket-msg .head { padding: 8px 14px; background: #f8fafc; border-bottom: 1px solid var(--border); font-size: 12.5px; display: flex; justify-content: space-between; }
.ticket-msg .body { padding: 14px; white-space: pre-wrap; }
.ticket-msg.staff .head { background: #eff6ff; }

.bulk-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.bulk-bar select { width: auto; min-width: 180px; }

@media (max-width: 860px) {
  .admin-body { flex-direction: column; }
  .sidebar { width: 100%; }
  .sidebar .brand { padding: 12px 16px; }
  .sidebar nav { display: flex; overflow-x: auto; padding: 4px 8px; -webkit-overflow-scrolling: touch; }
  .sidebar nav a { white-space: nowrap; }
  .sidebar nav a.active { border-left: 0; border-bottom: 2px solid #38bdf8; padding-left: 20px; }
  .nav-head { display: none; }
  .topbar { padding: 10px 12px; }
  .content { padding: 12px; }
  .card { overflow-x: auto; padding: 14px; }
  .table { min-width: 640px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .filters { flex-wrap: wrap; }
  .form-inline { flex-direction: column; align-items: stretch; }
  .form-inline .form-group { margin-bottom: 10px; }
  .row { gap: 12px; }
  .col { min-width: 100%; }
  .stat-card { min-width: 100%; }
  .w-50 { width: 100%; }
  .client-topbar-inner { flex-direction: row; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 12px; }
  .nav-toggle { display: block; }
  .client-nav { display: none; width: 100%; flex-direction: column; align-items: stretch; gap: 0; padding-top: 8px; border-top: 1px solid #1e293b; margin-top: 8px; }
  .client-nav.open { display: flex; }
  .client-nav a { display: block; padding: 12px 8px; border-bottom: 1px solid #1e293b; font-size: 15px; }
  .client-nav a.btn { margin: 10px 0; text-align: center; border-bottom: 0; }
  .client-content { margin: 12px auto; padding: 0 12px; }
  .client-nav a:last-child { border-bottom: 0; }
}

/* ============================================================
   Client area — modern theme (scoped to .client-body only,
   admin pages are unaffected)
   ============================================================ */
.client-body { font-size: 15px; line-height: 1.55; }
.client-body h1 { font-size: 24px; letter-spacing: -.02em; }
.client-body h2 { letter-spacing: -.01em; }

/* Cards */
.client-body .card {
  border-radius: 14px;
  border-color: #e5eaf1;
  padding: 22px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
}
.client-body .card h3 { font-size: 16px; }

/* Buttons */
.client-body .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 10px; padding: 10px 18px; font-size: 14px; font-weight: 500;
  transition: filter .15s ease, box-shadow .15s ease, transform .1s ease, background .15s ease;
}
.client-body .btn:hover { text-decoration: none; }
.client-body .btn:active { transform: translateY(1px); }
.client-body .btn-primary {
  background: linear-gradient(180deg, #0ea5e9, #0284c7);
  box-shadow: 0 1px 2px rgba(2, 132, 199, .35);
}
.client-body .btn-primary:hover { background: linear-gradient(180deg, #0284c7, #0369a1); filter: none; }
.client-body .btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.client-body .btn-block { display: flex; width: 100%; }
.client-body .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Forms */
.client-body .form-control,
.client-body select.form-control,
.client-body textarea.form-control {
  border-radius: 10px; padding: 10px 14px; font-size: 15px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.client-body .form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(2, 132, 199, .15); }
.client-body .form-group label { font-size: 13.5px; }

/* Status badges */
.client-body .badge { font-size: 12px; padding: 4px 11px; }
.client-body .badge::before {
  content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: .65; margin-right: 6px; vertical-align: 1.5px;
}

/* Tables */
.client-body .table th { padding: 10px 14px; }
.client-body .table td { padding: 13px 14px; }

/* Dashboard stat tiles */
.client-body .stat-tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.client-body a.stat-tile {
  display: block; background: var(--card); border: 1px solid var(--border);
  border-left: 4px solid var(--primary); border-radius: 12px; padding: 18px 20px;
  color: var(--text); text-decoration: none; box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
  transition: transform .15s ease, box-shadow .15s ease;
}
.client-body a.stat-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(15, 23, 42, .12); text-decoration: none; }
.client-body .stat-tile .num { font-size: 32px; font-weight: 700; line-height: 1.1; }
.client-body .stat-tile .lbl { color: var(--muted); font-size: 13px; font-weight: 500; margin-top: 4px; }
.client-body .stat-tile.tile-blue  { border-left-color: #0284c7; background: #f0f9ff; }
.client-body .stat-tile.tile-blue .num  { color: #0369a1; }
.client-body .stat-tile.tile-green { border-left-color: #16a34a; background: #f0fdf4; }
.client-body .stat-tile.tile-green .num { color: #15803d; }
.client-body .stat-tile.tile-amber { border-left-color: #d97706; background: #fffbeb; }
.client-body .stat-tile.tile-amber .num { color: #b45309; }
.client-body .stat-tile.tile-cyan  { border-left-color: #0891b2; background: #ecfeff; }
.client-body .stat-tile.tile-cyan .num  { color: #0e7490; }

/* Quick actions row */
.client-body .quick-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }

/* Empty states */
.client-body .empty-state { text-align: center; padding: 40px 20px; }
.client-body .empty-state .icon { font-size: 42px; line-height: 1; margin-bottom: 12px; }
.client-body .empty-state h3 { margin-bottom: 6px; }
.client-body .empty-state p { color: var(--muted); margin-bottom: 18px; }

/* Cart step indicator */
.client-body .cart-steps {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 20px; font-size: 13.5px;
}
.client-body .cart-steps .step { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.client-body .cart-steps .step .n {
  width: 26px; height: 26px; border-radius: 50%; background: #e2e8f0; color: #475569;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12.5px; flex-shrink: 0;
}
.client-body .cart-steps .step.active { color: var(--text); font-weight: 600; }
.client-body .cart-steps .step.active .n { background: var(--primary); color: #fff; }
.client-body .cart-steps .step.done .n { background: #dcfce7; color: #15803d; }
.client-body .cart-steps .sep { color: #cbd5e1; }

/* Cart product (plan) cards */
.client-body .plan-card {
  text-align: center; display: flex; flex-direction: column; height: 100%;
  transition: transform .15s ease, box-shadow .15s ease;
}
.client-body .plan-card:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(15, 23, 42, .12); }
.client-body .plan-features { list-style: none; padding: 0; margin: 12px 0; }
.client-body .plan-features li { padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.client-body .plan-features li:last-child { border-bottom: 0; }
.client-body .plan-price { font-size: 28px; font-weight: 700; color: var(--primary); margin: 10px 0 4px; }
.client-body .plan-price small { font-size: 14px; font-weight: 400; color: var(--muted); }
.client-body .plan-card .btn { margin-top: auto; }

/* Client mobile: stacked tables, comfortable touch targets.
   "screen" keeps invoice print output unaffected. */
@media screen and (max-width: 700px) {
  .client-body h1 { font-size: 21px; }

  /* Forms: full width, 16px prevents iOS zoom */
  .client-body .form-control,
  .client-body select.form-control,
  .client-body textarea.form-control { width: 100%; font-size: 16px; }

  /* Touch targets */
  .client-body .btn:not(.btn-sm) { min-height: 44px; }
  .client-body .btn-sm { min-height: 38px; }

  /* Primary actions in cards go full width */
  .client-body .card .btn:not(.btn-sm),
  .client-body .no-print .btn { display: flex; width: 100%; margin-bottom: 8px; }
  .client-body .quick-actions .btn { flex: 1 1 100%; }

  /* Client tables never require horizontal scrolling */
  .client-body .table { min-width: 0; }

  /* Stacked-card tables */
  .client-body .table-stack { display: block; min-width: 0; }
  .client-body .table-stack thead { display: none; }
  .client-body .table-stack tbody,
  .client-body .table-stack tr,
  .client-body .table-stack td { display: block; width: 100%; }
  .client-body .table-stack tr {
    border: 1px solid var(--border); border-radius: 12px;
    padding: 4px 14px; margin-bottom: 12px; background: #fff;
  }
  .client-body .table-stack tr:hover td { background: transparent; }
  .client-body .table-stack td {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 0; border-bottom: 1px solid #f1f5f9;
  }
  .client-body .table-stack td:last-child { border-bottom: 0; }
  .client-body .table-stack td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 45%; max-width: 45%;
    color: var(--muted); font-size: 11.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .4px;
  }
  .client-body .table-stack td:not([data-label]) > * { flex: 1; }
  .client-body .table-stack td:not([data-label]) .btn { display: flex; width: 100%; }
}
