/* ================================================================
   GSM SERVICE DESK — Application Stylesheet
   Consolidated, deduplicated, and reorganized.
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&display=swap');

/* ================================================================
   1. DESIGN TOKENS
   ================================================================ */
:root {
  /* Core palette */
  --ink:        #171b2d;
  --muted:      #7f879e;
  --line:       #e8eaf0;
  --paper:      #f7f8fb;
  --white:      #fff;

  /* Brand (violet) */
  --violet:     #6257e8;
  --violet-2:   #8177ff;

  /* Semantic colors */
  --green:      #159570;
  --amber:      #be7b22;
  --red:        #c9505c;

  /* Aliases used elsewhere in the sheet */
  --brand:      #6257e8;
  --brand-2:    #8177ff;
  --brand-soft: #eeedff;

  /* Elevation */
  --shadow: 0 20px 50px rgba(25, 32, 61, .06);
}

/* ================================================================
   2. RESET & BASE
   ================================================================ */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; overflow-x: hidden; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 14px Manrope, system-ui, sans-serif;
  overflow-x: hidden;
}

img { max-width: 100%; }
button, input, textarea, select { font: inherit; }
button {
  border: 0;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}
button:active { transform: scale(.97); }

.hidden { display: none !important; }

/* ================================================================
   3. LOGIN SHELL
   ================================================================ */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 20% 15%, #e5e1ff 0, transparent 34%),
    radial-gradient(circle at 90% 90%, #d9f2ec 0, transparent 28%),
    var(--paper);
}
.login-card {
  width: min(420px, calc(100% - 32px));
  padding: 42px;
  background: rgba(255, 255, 255, .9);
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 24px;
  box-shadow: 0 25px 80px rgba(55, 46, 130, .12);
}
.brand-mark {
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 15px;
  background: var(--ink); color: #fff;
  font-size: 24px; font-weight: 800;
  margin-bottom: 30px;
}
.brand-mark.small {
  width: 34px; height: 34px;
  border-radius: 10px;
  font-size: 17px; margin: 0;
}
.eyebrow {
  font: 500 11px 'DM Mono', monospace;
  letter-spacing: .13em;
  color: var(--violet);
  margin: 0 0 9px;
}
.login-card h1 {
  font-size: 30px;
  letter-spacing: -.04em;
  margin: 0 0 10px;
}
.muted { color: var(--muted); line-height: 1.65; }
.error { color: var(--red); min-height: 20px; }
.login-card form { margin-top: 28px; }

/* ================================================================
   4. FORMS
   ================================================================ */
label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin: 17px 0;
  color: #555d74;
}
input, textarea, select {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px #ebe9ff;
}
.optional {
  font-weight: 500;
  color: var(--muted);
  font-size: 11px;
}

/* Buttons */
.primary, .secondary, .ghost {
  padding: 11px 15px;
  border-radius: 9px;
  font-weight: 700;
}
.primary {
  background: var(--violet);
  color: #fff;
  box-shadow: 0 8px 18px #6257e833;
}
.primary:hover { background: #5449dc; }
.secondary {
  background: var(--brand-soft);
  color: var(--violet);
}
.secondary:hover { background: #e2e0ff; }
.ghost { background: transparent; color: var(--ink); }
.wide { width: 100%; margin-top: 12px; }

/* ================================================================
   5. APPLICATION SHELL (sidebar + main)
   ================================================================ */
.app { display: flex; min-height: 100vh; }

aside {
  width: 240px;
  background: var(--ink);
  color: #fff;
  padding: 25px 16px;
  display: flex;
  flex-direction: column;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px 48px;
}
.side-brand b { display: block; font-size: 14px; }
.side-brand span {
  display: block;
  color: #8e95aa;
  font-size: 11px;
  margin-top: 3px;
}

nav { display: grid; gap: 6px; }
nav button, .logout {
  padding: 12px 13px;
  text-align: left;
  border-radius: 9px;
  background: transparent;
  color: #a3a8ba;
  font-weight: 600;
}
nav button span, .logout span { margin-left: 10px; }
nav button.active, nav button:hover { background: #2a2e48; color: #fff; }
.logout { margin-top: auto; }
.logout:hover { background: #2a2e48; color: #fff; }

main {
  flex: 1;
  min-width: 0;
  padding: 36px 5%;
  max-width: 1500px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 38px;
}
header h2 {
  font-size: 31px;
  letter-spacing: -.05em;
  margin: 0;
}
.header-actions { display: flex; align-items: center; gap: 13px; }
.status-dot { color: var(--green); font-size: 12px; font-weight: 700; }
.status-dot:before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 7px;
}

/* ================================================================
   6. CARDS, STATS & PANELS
   ================================================================ */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.stat, .panel {
  background: var(--white);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.stat { padding: 21px 22px; }
.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 16px;
}
.stat strong {
  font-size: 28px;
  letter-spacing: -.05em;
}
.amber { color: var(--amber); }
.green { color: var(--green); }

.grid-2 {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 22px;
}
.panel {
  padding: 23px;
  margin-bottom: 22px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 17px;
}
.panel h3, .modal h3 {
  font-size: 19px;
  letter-spacing: -.03em;
  margin: 0 0 8px;
}
.link {
  background: none;
  color: var(--violet);
  font-size: 12px;
  font-weight: 700;
}
.dark-panel {
  background: var(--ink);
  color: #fff;
  padding: 28px;
  min-height: 240px;
}
.dark-panel .eyebrow { color: #a9a1ff; }
.dark-panel .muted.light { color: #a2a7bb; }
.light-btn {
  background: #3b3f5b;
  color: #fff;
  margin-top: 13px;
}
.steps {
  display: flex;
  justify-content: space-between;
  margin-top: 28px;
  color: #6f7590;
  font: 12px 'DM Mono';
}

/* ================================================================
   7. TABLES
   ================================================================ */
.table-wrap {
  overflow: auto;
  margin: 0 -23px -23px;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}
.table-wrap table { min-width: 700px; }
table {
  border-collapse: collapse;
  width: 100%;
  text-align: left;
  font-size: 12px;
}
th {
  font: 500 10px 'DM Mono';
  letter-spacing: .08em;
  color: #9aa1b2;
  text-transform: uppercase;
  background: #fafbfc;
}
th, td {
  padding: 14px 23px;
  border-bottom: 1px solid #f0f1f5;
  white-space: nowrap;
}
td b { font-weight: 700; }
td small {
  display: block;
  color: #9aa1b2;
  font-size: 10px;
  margin-top: 4px;
}

/* Status pills */
.pill {
  display: inline-block;
  border-radius: 100px;
  padding: 5px 9px;
  font-size: 10px;
  font-weight: 800;
  text-transform: capitalize;
  background: #f1f2f6;
  color: #72788c;
}
.pill.active, .pill.completed, .pill.processing {
  background: #e1f5ed;
  color: var(--green);
}
.pill.pending { background: #fff1d9; color: var(--amber); }
.pill.failed { background: #fee6e8; color: var(--red); }

/* ================================================================
   8. TOOLBAR & SMALL BUTTONS
   ================================================================ */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin: -12px 0 20px;
}
.toolbar > div {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tiny {
  background: var(--brand-soft);
  color: var(--violet);
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
}

/* ================================================================
   9. EMPTY STATES
   ================================================================ */
.empty {
  text-align: center;
  padding: 50px 20px;
  color: var(--muted);
}
.empty-icon {
  font-size: 34px;
  color: #c4c8d6;
  margin-bottom: 10px;
}

/* ================================================================
   10. SETTINGS GRID & INFO PANELS
   ================================================================ */
.settings-grid {
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  gap: 22px;
}
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.info { background: var(--brand-soft); }
.info h3 { margin-bottom: 14px; }
.info p { line-height: 1.7; }
.info code {
  font: 11px 'DM Mono';
  background: #fff;
  padding: 3px 5px;
  border-radius: 4px;
  color: var(--violet);
}

/* ================================================================
   11. TOAST
   ================================================================ */
#toast {
  position: fixed;
  bottom: 25px;
  right: 25px;
  background: var(--ink);
  color: #fff;
  padding: 13px 17px;
  border-radius: 9px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: .2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: none; }

/* ================================================================
   12. MODAL
   ================================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: #171b2d99;
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 5;
  overflow: auto;
}
.modal {
  width: min(680px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  padding: 26px;
  position: relative;
  box-shadow: 0 30px 90px #171b2d44;
}
.close {
  position: absolute;
  right: 18px; top: 14px;
  background: none;
  font-size: 25px;
  color: #9299aa;
}
.modal form { margin-top: 18px; }
.modal .primary { margin-top: 12px; }
.modal .service-description {
  background: #f7f7fb;
  border-radius: 9px;
  padding: 11px;
  margin: 12px 0;
}
.modal .service-description strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
}

/* ================================================================
   13. SERVICE CARDS (client + admin)
   ================================================================ */
.service-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.service-card {
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
  min-height: 180px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.service-card h3 { font-size: 17px; margin: 14px 0 4px; }
.service-card .muted { font-size: 12px; }

.service-cat {
  font: 500 10px 'DM Mono';
  letter-spacing: .1em;
  color: var(--violet);
  text-transform: uppercase;
}
.service-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 15px;
}
.service-foot strong {
  font-size: 22px;
  letter-spacing: -.04em;
}

.service-description {
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.service-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 12px;
  color: #687186;
  font: 10px 'DM Mono';
  line-height: 1.45;
}
.service-meta span:first-child {
  color: var(--violet);
  font-weight: 700;
}
.description { min-height: 48px; }

.meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 12px;
  color: #687186;
  font: 10px 'DM Mono';
  line-height: 1.45;
}
.meta span:first-child {
  color: var(--brand);
  font-weight: 800;
}

/* ================================================================
   14. WELCOME & BALANCE HEADER
   ================================================================ */
.welcome { margin-bottom: 24px; }
.welcome h3 {
  font-size: 25px;
  letter-spacing: -.04em;
  margin: 0 0 5px;
}
.balance-head {
  font-size: 12px;
  font-weight: 800;
  color: var(--violet);
  background: var(--brand-soft);
  padding: 10px 12px;
  border-radius: 8px;
}

/* ================================================================
   15. FLOW BOARD (dashboard diagram)
   ================================================================ */
.flow-board {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 22px;
  overflow: hidden;
}
.flow-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid #f0f1f5;
  padding-bottom: 18px;
}
.flow-head h3 { margin: 0 0 6px; font-size: 19px; }
.live-badge {
  background: #171a25;
  color: #fff;
  border-radius: 999px;
  padding: 10px 15px;
  font-size: 11px;
  font-weight: 800;
}
.flow-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 22px;
  align-items: center;
  padding: 36px 8px 12px;
  position: relative;
}
.flow-grid:before {
  content: '';
  height: 2px;
  background: #dddafa;
  position: absolute;
  left: 10%; right: 10%;
  top: calc(50% - 1px);
  z-index: 0;
}
.flow-node {
  position: relative;
  z-index: 1;
  background: #fff;
  border: 1px solid #e6e7ee;
  border-radius: 14px;
  padding: 17px 14px;
  min-height: 112px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  box-shadow: 0 8px 20px #2528440d;
}
.flow-node b { font-size: 18px; }
.flow-node strong { font-size: 12px; }
.flow-node small { color: #9ca2b0; font-size: 10px; }
.flow-node span {
  align-self: flex-start;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 800;
  background: #e4f7ee;
  color: #168d67;
}
.flow-node.violet { border-color: #a08bff; }
.flow-node.violet span { background: var(--brand-soft); color: var(--violet); }
.flow-node.dark { background: #252a42; color: #fff; border-color: #252a42; }
.flow-node.dark span { background: #274d42; color: #64d2a5; }
.flow-node.blue { border-color: #9d9af4; }
.flow-node.orange span { background: #fff1d9; color: var(--amber); }

/* ================================================================
   16. PROVIDER PANEL (admin list + banner)
   ================================================================ */
.provider-tabs {
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid #eef0f5;
  padding: 0 0 15px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 11px;
}
.provider-tab {
  border: 0;
  background: none;
  color: var(--violet);
  font-weight: 900;
  padding: 0;
}
.provider-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #eef5ff;
  border: 1px solid #dceaff;
  padding: 14px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  box-shadow: 0 5px 16px #4f65a811;
}
.provider-banner b, .provider-banner span { display: block; }
.provider-banner span {
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}
.provider-badge, .provider-type {
  display: inline-block !important;
  background: #e2f7ed;
  color: #168d67 !important;
  border-radius: 99px;
  padding: 5px 9px;
  font-weight: 800;
  font-size: 10px !important;
  margin-top: 0 !important;
}
.provider-type { background: #edf0ff; color: var(--violet) !important; }
.provider-delete { color: #b83f4a !important; }
.provider-quick { background: #edf0ff; color: var(--violet) !important; }

/* ================================================================
   17. SYNC MODAL (provider synchronization)
   ================================================================ */
.sync-backdrop { align-items: center; }
.sync-modal { width: min(760px, 100%); padding: 28px; }
.sync-title, .sync-footer, .sync-tabs, .sync-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.sync-title h3 { margin: 5px 0 0; }
.sync-lock {
  background: #fff1d9;
  color: #9b6715;
  border-radius: 99px;
  padding: 7px 10px;
  font-size: 10px;
  font-weight: 800;
}
.sync-lock.complete { background: #e1f5ed; color: #168d67; }
.sync-tabs {
  justify-content: flex-start;
  border-bottom: 1px solid #eef0f5;
  padding: 16px 0;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 11px;
}
.sync-tabs b {
  color: var(--violet);
  border-bottom: 2px solid var(--violet);
  padding-bottom: 17px;
  margin-bottom: -17px;
}
.sync-provider {
  padding: 14px 16px;
  background: #f7f7fb;
  border-radius: 10px;
}
.sync-provider b, .sync-provider span { display: block; }
.sync-provider span {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.sync-summary {
  justify-content: flex-start;
  border-bottom: 1px solid #eef0f5;
  padding: 16px 0;
}
.sync-summary div { min-width: 150px; }
.sync-summary span, .sync-summary b { display: block; font-size: 10px; }
.sync-summary span { color: var(--muted); margin-bottom: 5px; }
.sync-box {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 28px 0 20px;
}
.sync-box b { font-size: 15px; }
.sync-box p {
  color: var(--muted);
  font-size: 11px;
  margin: 6px 0 0;
  line-height: 1.5;
}
.sync-spinner {
  width: 28px; height: 28px;
  border: 3px solid #dce4f2;
  border-top-color: var(--violet);
  border-radius: 50%;
  animation: syncspin .8s linear infinite;
  flex: 0 0 auto;
}
.sync-spinner.done   { border-color: #22a477; animation: none; }
.sync-spinner.failed { border-color: #c84f5b; animation: none; }
.sync-progress {
  height: 7px;
  background: #eef0f6;
  border-radius: 99px;
  overflow: hidden;
}
.sync-progress span {
  display: block;
  width: 68%;
  height: 100%;
  background: linear-gradient(90deg, var(--violet), #8b7cff);
  border-radius: 99px;
  animation: syncpulse 1.4s ease-in-out infinite;
}
.sync-progress span.failed {
  background: #c84f5b;
  animation: none;
  width: 100%;
}
.sync-footer {
  margin-top: 22px;
  font-size: 10px;
  color: var(--muted);
}
.sync-footer button:disabled {
  opacity: .45;
  cursor: not-allowed;
}
@keyframes syncspin  { to { transform: rotate(360deg); } }
@keyframes syncpulse { 0%, 100% { width: 15%; } 50% { width: 88%; } }

/* ================================================================
   18. ADMIN SIDEBAR SEARCH & SUBMENUS
   ================================================================ */
.admin-search {
  margin: 10px 10px 14px;
  padding: 9px 10px;
  background: #f5f7fb;
  border: 1px solid #e7eaf2;
  border-radius: 8px;
  color: #9aa4b4;
  display: flex;
  gap: 7px;
  align-items: center;
}
.admin-search input {
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
  font-size: 11px;
  color: var(--ink);
  margin-top: 0;
}
.nav-parent { position: relative; }
.nav-parent b { margin-left: auto; font-size: 11px; }
.nav-submenu { display: none; padding: 0 0 5px 26px; }
.nav-submenu.open { display: block; }
.nav-submenu button {
  font-size: 11px !important;
  color: #7b8495 !important;
  padding: 7px 10px !important;
  border-left: 1px solid #e4e8f0 !important;
  border-radius: 0 !important;
}
.nav-submenu button:hover {
  color: var(--violet) !important;
  background: #f6f7fb !important;
}

/* ================================================================
   19. SERVICE ADMIN TABLE
   ================================================================ */
.service-admin-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 15px;
  padding: 2px 0 18px;
}
.service-admin-head h3 { margin: 5px 0; }
.service-search {
  width: 220px;
  border: 1px solid #e4e7ef;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11px;
}
.service-table { min-width: 920px; }
.service-table small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 3px;
}
.service-table .pill { white-space: nowrap; }
.service-table th { white-space: nowrap; }
.service-table td { vertical-align: middle; }
.service-table .service-cat { display: inline-block; }
.service-table input[type=checkbox] { accent-color: var(--violet); }
.delete-service, .group-delete { color: #b83f4a !important; }

/* ================================================================
   20. GROUP MANAGER
   ================================================================ */
.group-manager { display: grid; gap: 8px; }
.group-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  border: 1px solid #edf0f5;
  border-radius: 9px;
  padding: 9px;
}
.group-logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: #eef1f6;
  display: grid; place-items: center;
  font-weight: 900;
  color: var(--violet);
  overflow: hidden;
}
.group-logo img { width: 100%; height: 100%; object-fit: cover; }
.group-row small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 3px;
}
.group-actions { display: flex; gap: 5px; }

/* ================================================================
   21. LOGO THUMBNAILS
   ================================================================ */
.public-group-logo, .client-group-logo {
  width: 38px; height: 38px;
  border-radius: 9px;
  background: #eef1f6;
  color: var(--violet);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 900;
  overflow: hidden;
  margin-bottom: 8px;
}
.public-group-logo img, .client-group-logo img {
  width: 100%; height: 100%; object-fit: cover;
}
.service-icon img {
  width: 100%; height: 100%; object-fit: cover;
}

/* ================================================================
   22. NAV ICONS
   ================================================================ */
.nav-icon {
  display: inline-flex;
  width: 18px; height: 18px;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px;
  color: currentColor;
  opacity: .9;
}
.nav-icon svg { width: 17px; height: 17px; }
.app aside nav button:hover .nav-icon,
.app aside nav button.active .nav-icon {
  color: #b9ed46;
  opacity: 1;
}

/* ================================================================
   23. RESPONSIVE — Tablet (<=1050px)
   ================================================================ */
@media (max-width: 1050px) {
  aside { width: 220px; }
  main { padding: 28px 3%; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .service-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .service-admin-head { flex-direction: column; }
  .service-search { width: 100%; max-width: 340px; }
}

/* ================================================================
   24. RESPONSIVE — Mobile (<=900px / <=800px)
   ================================================================ */
@media (max-width: 900px) {
  aside { width: 74px; padding: 22px 10px; }
  .side-brand { padding: 0 10px 42px; }
  .side-brand > div:last-child,
  nav button span,
  .logout span { display: none; }
  nav button, .logout { text-align: center; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .settings-grid { grid-template-columns: 1fr; }
  main { padding: 26px 4%; }
  .service-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow-grid { grid-template-columns: repeat(3, 1fr); }
  .flow-grid:before { display: none; }
}

@media (max-width: 800px) {
  .app { display: block; min-height: 100vh; }
  aside {
    width: 100%;
    padding: 14px 14px 10px;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 8px 22px rgba(24, 27, 45, .12);
  }
  .side-brand { padding: 0 4px 13px; }
  .admin-search { margin: 0 0 10px; }
  .app aside nav {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    overflow-x: auto;
    overflow-y: visible;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }
  .app aside nav > button {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 10px 11px;
    font-size: 11px;
  }
  .app aside nav > button span { margin-left: 6px; }
  .nav-submenu {
    flex: 0 0 100%;
    order: 10;
    display: none;
    padding: 4px 0 0;
    gap: 4px;
    overflow-x: auto;
  }
  .nav-submenu.open { display: flex; }
  .nav-submenu button { flex: 0 0 auto !important; }
  .logout {
    position: absolute;
    right: 14px; top: 14px;
    margin: 0 !important;
    padding: 8px !important;
  }
  .logout span { display: none; }
  main { padding: 23px 16px 36px; max-width: none; }
  header {
    align-items: flex-start;
    flex-direction: column;
    gap: 13px;
    margin-bottom: 24px;
  }
  header h2 { font-size: 26px; }
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
  .stats { gap: 10px; }
  .stat { padding: 17px; }
  .stat strong { font-size: 23px; }
  .panel { padding: 17px; margin-bottom: 16px; }
  .table-wrap { margin: 0 -17px -17px; }
  .toolbar { align-items: flex-start; }
  .toolbar > div { width: 100%; }
  .toolbar > div button { flex: 1; }
  .service-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
  .service-card { padding: 15px; }
  .service-card h3 { font-size: 14px; }
  .split { grid-template-columns: 1fr; }
  .modal-backdrop { align-items: flex-start; padding: 10px; }
  .modal { padding: 20px; border-radius: 16px; }
  .sync-modal { padding: 20px; }
  .sync-tabs {
    overflow-x: auto;
    justify-content: flex-start;
    white-space: nowrap;
  }
  .sync-summary { flex-wrap: wrap; }
  .sync-summary div { min-width: 44%; }
  .group-row { grid-template-columns: 38px 1fr; }
  .group-actions { grid-column: 2; }
  .group-actions button { flex: 1; }
  .service-admin-head { padding-bottom: 12px; }
  .flow-head { gap: 12px; flex-direction: column; }
  .flow-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 20px 0 0;
  }
  .flow-node { min-height: 105px; padding: 12px; }
}

/* ================================================================
   25. RESPONSIVE — Small phones (<=600px / <=520px)
   ================================================================ */
@media (max-width: 600px) {
  header {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 27px;
  }
  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
  .stats { gap: 9px; }
  .stat { padding: 15px; }
  .stat strong { font-size: 22px; }
  .toolbar { align-items: flex-start; gap: 12px; }
  .toolbar div:last-child { flex-direction: column; }
  .toolbar .primary, .toolbar .secondary { padding: 9px; font-size: 11px; }
  th, td { padding: 12px 13px; }
  .table-wrap { margin: 0 -13px -13px; }
  .panel { padding: 13px; }
  .split { grid-template-columns: 1fr; }
  .panel-head { padding: 10px 0 15px; }
  .service-grid { grid-template-columns: 1fr; }
  .balance-head { font-size: 11px; }
}

@media (max-width: 520px) {
  .login-card { padding: 28px 21px; border-radius: 18px; }
  .brand-mark { margin-bottom: 22px; }
  .login-card h1 { font-size: 25px; }
  .app aside { padding: 12px 10px 8px; }
  .side-brand b { font-size: 13px; }
  .app aside nav > button { padding: 9px; font-size: 10px; }
  .admin-search { font-size: 12px; }
  .admin-search input { font-size: 12px; }
  main { padding: 20px 11px 30px; }
  header h2 { font-size: 23px; }
  .header-actions {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
  .header-actions .secondary { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 14px 12px; }
  .stat span { font-size: 10px; margin-bottom: 10px; }
  .stat strong { font-size: 20px; }
  .service-grid { grid-template-columns: 1fr; }
  .service-card h3 { font-size: 15px; }
  .panel { padding: 14px; border-radius: 11px; }
  .table-wrap { margin: 0 -14px -14px; }
  .toolbar > div { display: grid; grid-template-columns: 1fr 1fr; }
  .toolbar > div button:last-child { grid-column: 1 / -1; }
  .service-search { max-width: none; }
  .modal-backdrop { padding: 6px; }
  .modal { padding: 17px; }
  .modal h3 { font-size: 17px; }
  .sync-title { align-items: flex-start; flex-direction: column; }
  .sync-footer { align-items: flex-start; flex-direction: column; }
  .sync-footer button { width: 100%; }
  .sync-summary div { min-width: 100%; }
  .form-actions,
  .split .primary,
  .split .secondary { width: 100%; }
}

/* ================================================================
   26. ACCESSIBILITY — Reduced motion
   ================================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}