:root {
  color-scheme: light;
  --ink: #101726;
  --muted: #687286;
  --subtle: #98a2b3;
  --paper: #ffffff;
  --canvas: #f4f6fa;
  --line: #e5e9f0;
  --line-strong: #d7dce5;
  --primary: #6657ed;
  --primary-dark: #5142d4;
  --primary-soft: #efedff;
  --teal: #17a58b;
  --teal-soft: #e6f7f3;
  --amber: #d98416;
  --amber-soft: #fff4df;
  --danger: #d5485f;
  --danger-soft: #fff0f2;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 16px 40px rgba(30, 38, 61, .12);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --sidebar: 252px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 480px) minmax(0, 1fr);
  background: var(--paper);
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(32px, 7vw, 88px);
  border-right: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 780;
  letter-spacing: -.03em;
}

.brand-mark {
  position: relative;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--primary);
  border-radius: 12px;
  box-shadow: 0 10px 24px rgba(102, 87, 237, .25);
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px solid rgba(255, 255, 255, .92);
  border-left-color: transparent;
  border-radius: 6px;
  transform: rotate(45deg);
}

.brand-name {
  font-size: 20px;
}

.login-copy {
  margin: 64px 0 34px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.login-copy h1,
.page-title h1 {
  margin: 0;
  font-size: clamp(32px, 4vw, 46px);
  line-height: 1.06;
  letter-spacing: -.045em;
}

.login-copy p,
.page-title p {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 18px;
}

.form-field {
  display: grid;
  gap: 7px;
}

.form-field label {
  color: #30394b;
  font-size: 13px;
  font-weight: 680;
}

.form-field input,
.form-field textarea,
.form-field select,
.search-input {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}

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

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus,
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(102, 87, 237, .12);
}

.input-with-icon {
  position: relative;
}

.input-with-icon .icon {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 18px;
  height: 18px;
  color: var(--subtle);
  transform: translateY(-50%);
}

.input-with-icon input {
  padding-left: 42px;
}

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  color: #344054;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.button:hover {
  border-color: #bcc3cf;
  transform: translateY(-1px);
}

.button:disabled {
  cursor: wait;
  opacity: .62;
  transform: none;
}

.button-primary {
  color: white;
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 9px 20px rgba(102, 87, 237, .2);
}

.button-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.button-danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #ffd4dc;
}

.button-quiet {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.button-full {
  width: 100%;
}

.button .icon {
  width: 18px;
  height: 18px;
}

.login-help {
  margin-top: 24px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.login-visual {
  position: relative;
  min-height: 560px;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 60px;
  color: white;
  background:
    radial-gradient(circle at 70% 20%, rgba(75, 212, 184, .3), transparent 28%),
    radial-gradient(circle at 25% 82%, rgba(126, 109, 255, .35), transparent 30%),
    #111827;
}

.login-grid {
  position: absolute;
  inset: 0;
  opacity: .14;
  background-image:
    linear-gradient(rgba(255,255,255,.14) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.14) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 92%);
}

.visual-card {
  position: relative;
  z-index: 1;
  width: min(620px, 90%);
  padding: clamp(30px, 5vw, 58px);
  background: rgba(255, 255, 255, .09);
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 30px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .25);
  backdrop-filter: blur(20px);
}

.visual-card h2 {
  max-width: 510px;
  margin: 0;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1;
  letter-spacing: -.055em;
}

.visual-card > p {
  max-width: 470px;
  margin: 22px 0 36px;
  color: rgba(255,255,255,.68);
  font-size: 17px;
  line-height: 1.6;
}

.visual-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.visual-stat {
  padding: 18px;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 16px;
}

.visual-stat strong {
  display: block;
  font-size: 22px;
  letter-spacing: -.04em;
}

.visual-stat span {
  display: block;
  margin-top: 4px;
  color: rgba(255,255,255,.56);
  font-size: 12px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 26px 18px 20px;
  color: #e7eaf1;
  background: #111827;
  border-right: 1px solid rgba(255,255,255,.06);
}

.sidebar .brand {
  padding: 0 10px;
  color: white;
}

.sidebar .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
}

.sidebar-label {
  margin: 40px 12px 10px;
  color: #727d92;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 5px;
}

.nav-button {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: #9ba5b8;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 11px;
  text-align: left;
  font-size: 14px;
  font-weight: 620;
}

.nav-button:hover {
  color: white;
  background: rgba(255,255,255,.045);
}

.nav-button.active {
  color: white;
  background: rgba(102, 87, 237, .18);
  border-color: rgba(133, 120, 255, .18);
}

.nav-button.active .icon {
  color: #a99fff;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 10px 0;
  border-top: 1px solid rgba(255,255,255,.08);
}

.user-card {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(145deg, #7869ef, #5142d4);
  border-radius: 11px;
  font-size: 13px;
  font-weight: 800;
}

.user-meta {
  min-width: 0;
}

.user-meta strong,
.user-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta strong {
  color: #f8fafc;
  font-size: 12px;
}

.user-meta span {
  margin-top: 3px;
  color: #7f8a9e;
  font-size: 10px;
  text-transform: capitalize;
}

.sidebar .icon-button {
  color: #818ca1;
}

.main-area {
  grid-column: 2;
  min-width: 0;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(20px, 4vw, 48px);
  background: rgba(244, 246, 250, .9);
  border-bottom: 1px solid rgba(219, 224, 233, .85);
  backdrop-filter: blur(16px);
}

.topbar-start,
.topbar-end {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title {
  color: #424b5c;
  font-size: 14px;
  font-weight: 700;
}

.connection-pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.connection-pill {
  color: #196f61;
  background: var(--teal-soft);
  border: 1px solid #c4ece4;
}

.connection-pill.offline {
  color: #9c5b09;
  background: var(--amber-soft);
  border-color: #ffe0ac;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: currentColor;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(23,165,139,.12);
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  color: #667085;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 25px;
}

.icon-button:hover {
  color: var(--ink);
  background: rgba(16, 23, 38, .05);
}

.mobile-menu-button {
  display: none;
}

.content {
  width: 100%;
  max-width: 1580px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 46px);
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.page-title h1 {
  font-size: clamp(28px, 4vw, 38px);
}

.page-title p {
  margin-top: 8px;
  font-size: 14px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  min-width: 0;
  padding: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.stat-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 10px;
}

.stat-icon.teal {
  color: var(--teal);
  background: var(--teal-soft);
}

.stat-icon.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.stat-value {
  display: block;
  margin-top: 22px;
  font-size: 30px;
  line-height: 1;
  letter-spacing: -.045em;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, .8fr);
  gap: 16px;
  margin-top: 16px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.panel-header {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -.01em;
}

.panel-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-body {
  padding: 20px;
}

.quick-list {
  display: grid;
  gap: 4px;
}

.quick-item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 8px;
  border-bottom: 1px solid #f0f2f6;
}

.quick-item:last-child {
  border-bottom: 0;
}

.product-avatar {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-radius: 11px;
  font-size: 13px;
  font-weight: 780;
}

.quick-copy {
  min-width: 0;
}

.quick-copy strong,
.quick-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-copy strong {
  font-size: 13px;
}

.quick-copy span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.quick-value {
  font-size: 12px;
  font-weight: 750;
}

.progress-stack {
  display: grid;
  gap: 18px;
}

.progress-row {
  display: grid;
  gap: 8px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 12px;
}

.progress-meta strong {
  color: var(--ink);
}

.progress-track {
  height: 8px;
  overflow: hidden;
  background: #eef0f5;
  border-radius: 999px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #9a8fff);
  border-radius: inherit;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.search-wrap {
  position: relative;
  width: min(380px, 100%);
}

.search-wrap .icon {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 17px;
  height: 17px;
  color: var(--subtle);
  transform: translateY(-50%);
}

.search-input {
  min-height: 40px;
  padding: 8px 12px 8px 40px;
  background: #fafbfc;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid #eef0f4;
  white-space: nowrap;
}

.data-table th {
  color: var(--muted);
  background: #fbfcfd;
  font-size: 10px;
  font-weight: 780;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.data-table tbody tr:hover {
  background: #fbfbfe;
}

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

.cell-primary {
  max-width: 300px;
}

.cell-primary strong,
.cell-primary span {
  display: block;
}

.cell-primary strong {
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-primary span {
  max-width: 280px;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
}

.badge-success {
  color: #147561;
  background: var(--teal-soft);
}

.badge-warning {
  color: #945607;
  background: var(--amber-soft);
}

.badge-danger {
  color: #a83246;
  background: var(--danger-soft);
}

.badge-neutral {
  color: #596273;
  background: #f0f2f5;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 4px;
}

.table-actions .icon-button {
  width: 34px;
  height: 34px;
}

.empty-state {
  display: grid;
  place-items: center;
  padding: 56px 24px;
  color: var(--muted);
  text-align: center;
}

.empty-icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 18px;
}

.empty-state h3 {
  margin: 16px 0 6px;
  color: var(--ink);
  font-size: 16px;
}

.empty-state p {
  max-width: 380px;
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
}

.loading-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.skeleton {
  min-height: 110px;
  background: linear-gradient(90deg, #eceff4 25%, #f7f8fa 50%, #eceff4 75%);
  background-size: 200% 100%;
  border-radius: var(--radius);
  animation: pulse 1.4s linear infinite;
}

@keyframes pulse {
  to { background-position: -200% 0; }
}

.modal {
  width: min(680px, calc(100% - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  overflow: visible;
}

.modal::backdrop {
  background: rgba(16, 23, 38, .55);
  backdrop-filter: blur(4px);
}

.modal-frame {
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid rgba(255,255,255,.4);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 26px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-heading h2 {
  margin: 0;
  font-size: 21px;
  letter-spacing: -.025em;
}

.modal-form {
  display: grid;
  gap: 18px;
  padding: 24px 26px 26px;
}

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

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

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding-top: 20px;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.checkbox-field label {
  color: #3d4657;
  font-size: 13px;
  font-weight: 650;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 22px;
  bottom: 22px;
  display: grid;
  gap: 10px;
  pointer-events: none;
}

.toast {
  width: min(390px, calc(100vw - 44px));
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  color: #f8fafc;
  background: #182132;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  animation: toast-in .24s ease-out;
}

.toast.error {
  background: #782f3c;
}

.toast-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.1);
  border-radius: 10px;
  font-weight: 800;
}

.toast strong,
.toast span {
  display: block;
}

.toast strong {
  font-size: 13px;
}

.toast span {
  margin-top: 3px;
  color: rgba(255,255,255,.7);
  font-size: 11px;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
}

.settings-card {
  max-width: 720px;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.info-box {
  padding: 14px 16px;
  color: #4e596b;
  background: #f8f8fe;
  border: 1px solid #e5e2ff;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.6;
}

@media (max-width: 1180px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  :root { --sidebar: 232px; }
  .login-page { grid-template-columns: 1fr; }
  .login-panel { min-height: 100vh; border: 0; }
  .login-visual { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .main-area { grid-column: 1; }
  .sidebar {
    width: min(300px, 86vw);
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 20px 0 60px rgba(0,0,0,.24);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu-button { display: inline-grid; }
  .content { padding: 26px 20px; }
}

@media (max-width: 680px) {
  .topbar { height: 64px; padding: 0 15px; }
  .topbar-title { display: none; }
  .connection-pill { padding: 6px 8px; }
  .page-header { align-items: stretch; flex-direction: column; }
  .header-actions { width: 100%; }
  .header-actions .button { flex: 1; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card { padding: 16px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .search-wrap { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field.full { grid-column: auto; }
  .checkbox-field { padding-top: 0; }
  .modal-heading { padding: 20px; }
  .modal-form { padding: 20px; }
  .settings-row { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
  .login-panel { padding: 30px 22px; }
  .login-copy { margin-top: 46px; }
  .stats-grid { grid-template-columns: 1fr; }
  .content { padding-inline: 14px; }
  .connection-pill span:last-child { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
