:root {
  --teal: #0f6f83;
  --teal-dark: #0a5262;
  --teal-soft: #e8f6f8;
  --blue: #1769c2;
  --indigo: #4056d6;
  --green: #12805c;
  --amber: #b96b00;
  --red: #d83333;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #6f7b8e;
  --line: #dfe6ef;
  --sidebar: #ffffff;
  --sidebar-width: 240px;
  --topbar-height: 64px;
  --shadow: 0 10px 30px rgba(31, 45, 61, 0.12);
}

* { box-sizing: border-box; }

html { min-height: 100%; }
html, body { width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

body.menu-open { overflow: hidden; }
a { color: var(--blue); text-decoration: none; }

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

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  color: #ffffff;
  background: linear-gradient(90deg, var(--teal-dark), var(--teal));
  box-shadow: 0 4px 18px rgba(9, 54, 66, 0.22);
}

.topbar-left,
.top-actions,
.top-brand {
  display: flex;
  align-items: center;
}

.topbar-left { gap: 14px; min-width: 0; }
.top-actions { gap: 16px; }

.top-brand {
  gap: 10px;
  min-width: 0;
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
}

.top-brand strong {
  font-size: 21px;
  white-space: nowrap;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: 42px;
  color: #fff;
  font-weight: 900;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

.logo-mark img {
  width: auto;
  max-width: 150px;
  max-height: 42px;
  display: block;
  object-fit: contain;
}

.top-link,
.language-mark {
  color: #fff;
  font-weight: 700;
}

.language-mark {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.admin-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 999px;
  color: #e9fbff;
  background: rgba(255, 255, 255, 0.14);
  font-weight: 800;
}

.menu-btn {
  display: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  padding: 9px;
}

.menu-btn span {
  display: block;
  height: 2px;
  margin: 5px 0;
  background: #fff;
  border-radius: 99px;
}

.app-sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  z-index: 30;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  box-shadow: 4px 0 18px rgba(23, 32, 51, 0.07);
}

.sidebar-hero {
  min-height: 88px;
  padding: 18px 20px;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background:
    linear-gradient(135deg, rgba(13, 80, 96, 0.82), rgba(23, 105, 194, 0.58)),
    linear-gradient(45deg, #193142, #0f6f83);
}

.sidebar-hero strong {
  font-size: 16px;
  letter-spacing: 0;
}

.sidebar-hero span {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
}

.side-nav {
  display: grid;
  padding: 18px 0;
}

.side-link {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  min-height: 48px;
  padding: 6px 18px;
  color: #222b38;
  border-bottom: 1px solid #eef2f6;
  font-weight: 600;
  transition: background 160ms ease, color 160ms ease, padding-left 160ms ease;
}

.side-link:hover,
.side-link.active {
  color: var(--teal-dark);
  background: #f2fbfd;
  padding-left: 22px;
}

.side-link.active {
  box-shadow: inset 4px 0 0 var(--teal);
}

.side-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef3f8;
  color: #6c7788;
  flex: 0 0 28px;
}

.side-icon svg {
  width: 17px;
  height: 17px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.side-link.active .side-icon,
.side-link:hover .side-icon {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--indigo));
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  background: #fafcff;
}

.sidebar-footer span,
.sidebar-footer strong {
  display: block;
}

.sidebar-footer span { color: var(--muted); font-size: 12px; }
.sidebar-footer strong { color: var(--ink); margin-top: 3px; font-size: 13px; }

.app-main {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  display: flex;
  flex-direction: column;
  padding-bottom: 58px;
}

.content-area {
  width: 100%;
  padding: 22px 28px;
  flex: 1;
}

.page-title {
  margin-bottom: 18px;
  padding: 18px 20px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.96), rgba(232, 246, 248, 0.96)),
    #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.page-title h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: 0; }
.page-title p { margin: 0; color: var(--muted); font-size: 14px; }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px 13px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  font-weight: 800;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.12);
}

.btn.primary { background: linear-gradient(135deg, var(--teal), var(--teal-dark)); border-color: var(--teal); color: #fff; }
.btn.blue { background: linear-gradient(135deg, var(--blue), var(--indigo)); border-color: var(--blue); color: #fff; }
.btn.danger { color: #fff; background: linear-gradient(135deg, var(--red), #a91f1f); border-color: var(--red); }

.grid { display: grid; gap: 18px; }
.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 18px; }
.two { grid-template-columns: minmax(0, 1fr) minmax(340px, 430px); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
  max-width: 100%;
  overflow-x: auto;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 18px;
  letter-spacing: 0;
}

.login-card { max-width: 460px; margin: 20px auto 0; }

.stat {
  position: relative;
  overflow: hidden;
  min-height: 112px;
}

.stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--teal), var(--blue), #ff4747);
}

.stat strong { display: block; font-size: 32px; margin-top: 6px; }
.stat span, .muted { color: var(--muted); }

.alert {
  padding: 13px 15px;
  border-radius: 8px;
  border: 1px solid #f3d08a;
  background: linear-gradient(135deg, #fff8e6, #fffdf5);
  color: #7a4b00;
  margin-bottom: 16px;
  box-shadow: 0 12px 24px rgba(245, 158, 11, 0.12);
}

table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: #57657a; font-size: 13px; background: #f8fbff; text-transform: uppercase; letter-spacing: 0; }
tr:last-child td { border-bottom: 0; }

.badge {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  background: #eef2ff;
  color: #3730a3;
}

.badge.successful, .badge.online, .badge.active { background: #ddf7eb; color: var(--green); }
.badge.failed, .badge.timeout, .badge.disabled { background: #ffe8ea; color: var(--red); }
.badge.processing, .badge.queued, .badge.pending { background: #e7f0ff; color: #1d4ed8; }

label { display: block; font-weight: 800; margin: 12px 0 6px; }

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 10px;
  min-height: 44px;
  font: inherit;
  background: #fff;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus {
  outline: 3px solid rgba(15, 111, 131, 0.14);
  border-color: rgba(15, 111, 131, 0.6);
}

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
code { background: #eef2f7; padding: 2px 5px; border-radius: 4px; word-break: break-word; }

.site-footer {
  position: fixed;
  left: var(--sidebar-width);
  right: 0;
  bottom: 0;
  z-index: 35;
  padding: 14px 28px 22px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.mobile-backdrop {
  position: fixed;
  inset: var(--topbar-height) 0 0;
  background: rgba(10, 19, 31, 0.48);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 25;
}

.is-loading { cursor: progress; }
.is-loading .btn[type="submit"] { opacity: 0.7; pointer-events: none; }

@media (max-width: 1060px) {
  :root { --sidebar-width: 260px; }
  .menu-btn { display: inline-block; }
  .app-sidebar {
    transform: translateX(-105%);
    transition: transform 190ms ease;
  }
  body.menu-open .app-sidebar { transform: translateX(0); }
  body.menu-open .mobile-backdrop { opacity: 1; pointer-events: auto; }
  .app-main { margin-left: 0; }
  .site-footer { left: 0; }
}

@media (max-width: 900px) {
  .topbar { height: 58px; padding: 0 12px; }
  :root { --topbar-height: 58px; }
  .top-brand strong { font-size: 16px; }
  .brand-mark { width: 44px; height: 34px; font-size: 11px; }
  .admin-chip { display: none; }
  .content-area { padding: 14px 10px; }
  .page-title { padding: 14px; margin-bottom: 12px; }
  .page-title h1 { font-size: 20px; }
  .page-title p { font-size: 13px; }
  .stats, .two { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 14px; }
  table { font-size: 14px; }
  table { min-width: 0; }
  th, td { padding: 10px 7px; }
  .site-footer {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 6px 10px;
    gap: 6px;
    font-size: 11px;
  }
  .site-footer span + span { display: none; }
  .app-main { padding-bottom: 42px; }
}

@media (max-width: 560px) {
  .top-actions { gap: 8px; }
  .language-mark { display: none; }
  .top-brand strong {
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .actions .btn,
  .actions form,
  .actions button { width: 100%; }
  .card { border-radius: 7px; }
}

body {
  background:
    linear-gradient(135deg, rgba(15, 111, 131, 0.94), rgba(10, 82, 98, 0.9)),
    linear-gradient(45deg, #eef8ff, #fff7e6);
}

.app-sidebar,
.mobile-backdrop,
.sidebar-footer {
  display: none;
}

.app-main {
  margin-left: 0;
}

.topbar {
  background: transparent;
  box-shadow: none;
}

.content-area {
  max-width: 540px;
  min-height: calc(100vh - var(--topbar-height));
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.page-title {
  color: #fff;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.page-title p {
  color: rgba(255, 255, 255, 0.82);
}

.login-card {
  width: 100%;
  margin: 18px 0 0;
  border: 0;
}

.site-footer {
  color: rgba(255, 255, 255, 0.82);
  background: transparent;
  border-top: 0;
  left: 0;
}

/* contained-mobile-table-scroll */
img, svg, video, canvas {
  max-width: 100%;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 900px) {
  html,
  body,
  .app-shell,
  .app-main,
  .content-area {
    max-width: 100%;
    overflow-x: hidden;
  }

  .topbar {
    max-width: 100vw;
  }

  .top-brand {
    min-width: 0;
    flex: 1;
  }

  .top-brand strong {
    max-width: 58vw;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-mark,
  .logo-mark img {
    max-height: 34px;
  }

  .card {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }

  .card table {
    width: max-content;
    min-width: 680px;
    border-collapse: collapse;
  }

  .card table thead {
    display: table-header-group;
  }

  .card table tbody {
    display: table-row-group;
  }

  .card table tr {
    display: table-row;
    box-shadow: none;
  }

  .card table th,
  .card table td {
    display: table-cell;
    width: auto;
    white-space: nowrap;
  }

  .card table code {
    white-space: nowrap;
  }

  .card::-webkit-scrollbar,
  .table-scroll::-webkit-scrollbar {
    height: 6px;
  }

  .card::-webkit-scrollbar-thumb,
  .table-scroll::-webkit-scrollbar-thumb {
    background: rgba(111, 123, 142, 0.32);
    border-radius: 999px;
  }

  .icon-actions {
    flex-wrap: nowrap;
    justify-content: flex-start;
  }

  .icon-btn {
    width: 42px;
    height: 42px;
  }
}
.preview-logo img { max-height: 42px; width: auto; object-fit: contain; }

/* native-app-polish */
body {
  background:
    linear-gradient(180deg, #eef7fb 0%, #f7fbff 42%, #f4f7fb 100%);
}

.topbar {
  background: linear-gradient(90deg, #0a6172, #0f7688);
  box-shadow: 0 6px 18px rgba(6, 63, 78, 0.28);
}

.top-actions {
  gap: 10px;
  position: relative;
}

.top-link,
.language-mark,
.admin-chip {
  display: none !important;
}

.top-icon-btn {
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.top-icon-btn:hover,
.top-icon-btn.is-active {
  background: rgba(255, 255, 255, 0.14);
}

.top-icon-btn svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dots-btn {
  flex-direction: column;
  gap: 4px;
}

.dots-btn span {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
  display: block;
}

.account-menu-wrap {
  position: relative;
}

.account-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 220px;
  padding: 8px;
  border: 1px solid rgba(223, 230, 239, 0.95);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 50px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 70;
}

.account-menu.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.account-menu strong,
.account-menu a {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 11px;
  border-radius: 7px;
  color: var(--ink);
  font-weight: 850;
}

.account-menu strong {
  color: #0a6172;
  background: #edf9fb;
  margin-bottom: 5px;
}

.account-menu a:hover {
  background: #f4f8fb;
  color: #0a6172;
}

.account-menu .danger-link {
  color: #d83333;
}

.card,
.native-panel {
  overflow: hidden;
}

.native-table-scroll,
.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.native-table-scroll table,
.table-scroll table {
  width: max-content;
  min-width: 760px;
}

.native-table-scroll::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar {
  height: 6px;
}

.native-table-scroll::-webkit-scrollbar-thumb,
.table-scroll::-webkit-scrollbar-thumb {
  background: rgba(15, 118, 136, 0.32);
  border-radius: 999px;
}

.native-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 24px;
  border-radius: 8px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.98), rgba(37, 99, 235, 0.94)),
    radial-gradient(circle at 85% 15%, rgba(255, 255, 255, 0.2), transparent 28%);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.16);
}

.native-hero h2 {
  margin: 14px 0 8px;
  color: #fff;
  font-size: 34px;
  line-height: 1.08;
}

.native-hero p {
  margin: 0;
  max-width: 720px;
  color: #dbeafe;
  font-weight: 700;
}

.native-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 15px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  color: #e9fffb;
  font-size: 13px;
  font-weight: 950;
  text-transform: uppercase;
}

.native-hero-icon {
  width: 74px;
  height: 74px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  font-size: 34px;
  font-weight: 950;
}

.native-panel {
  border: 1px solid rgba(223, 230, 239, 0.96);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 20px 44px rgba(15, 23, 42, 0.11);
}

.native-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: #f8fbff;
}

.native-panel-head h2 {
  margin: 0 0 4px;
  font-size: 24px;
}

.native-search {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 220px) auto auto;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.native-data-table th,
.native-data-table td {
  white-space: nowrap;
}

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

@media (max-width: 900px) {
  .topbar {
    height: 64px;
    padding: 0 10px;
  }

  :root { --topbar-height: 64px; }

  .top-brand strong {
    max-width: 56vw;
    font-size: 17px;
  }

  .menu-btn,
  .top-icon-btn {
    width: 46px;
    height: 46px;
  }

  .content-area {
    padding: 14px 10px;
  }

  .page-title {
    margin-bottom: 14px;
  }

  .native-hero {
    grid-template-columns: 1fr;
    padding: 22px 18px;
  }

  .native-hero h2 {
    font-size: 30px;
  }

  .native-hero-icon {
    width: 100%;
    height: 64px;
  }

  .native-panel-head,
  .native-search {
    padding: 18px 16px;
  }

  .native-search {
    grid-template-columns: 1fr;
  }

  .native-search .btn,
  .native-search button,
  .native-search select,
  .native-search input {
    width: 100%;
  }

  .native-table-scroll table,
  .table-scroll table {
    min-width: 860px;
  }
}
