/* LinePro console base layout. Kept local and embedded in linepro-server. */
:root {
  --bg: #f8fafc;
  --shell: #0f172a;
  --shell-2: #1e293b;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #cbd5e1;
  --line-soft: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --faint: #94a3b8;
  --indigo: #4f46e5;
  --indigo-strong: #4338ca;
  --blue: #4f46e5;
  --amber: #92400e;
  --red: #b91c1c;
  --green-soft: #ecfdf5;
  --blue-soft: #eef2ff;
  --amber-soft: #fffbeb;
  --red-soft: #fef2f2;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

button {
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  color: var(--text);
  padding: 0 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s ease, background .15s ease, color .15s ease, transform .12s ease;
}

button:hover {
  border-color: #c7d2fe;
  background: #f8fafc;
  color: #3730a3;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
  transform: none;
}

button.primary {
  border-color: var(--indigo);
  background: var(--indigo);
  color: white;
}

button.blue {
  border-color: var(--indigo);
  background: var(--indigo);
  color: white;
}

button.ghost {
  background: transparent;
  color: var(--muted);
}

button.small {
  height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

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

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(79, 70, 229, .10), rgba(14, 165, 233, .08)),
    var(--bg);
}

.auth-card {
  width: min(440px, 100%);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.auth-card .brand {
  height: auto;
  margin: 0;
  padding: 18px;
  border-bottom: 1px solid var(--line-soft);
  background: #f8fafc;
  color: var(--text);
}

.auth-card .brand strong {
  color: var(--text);
}

.auth-card form {
  grid-template-columns: 1fr;
  padding: 18px;
}

.auth-hint {
  padding: 0 18px 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.user-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 0 10px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

aside {
  background: linear-gradient(180deg, var(--shell), var(--shell-2));
  color: #d8dee9;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 14px;
}

.mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-lg);
  background: #eef2ff;
  color: var(--indigo);
  font-weight: 800;
}

.brand strong {
  display: block;
  line-height: 1.1;
  color: #fff;
  font-size: 15px;
}

.brand span {
  display: block;
  margin-top: 3px;
  color: #98a2b3;
  font-size: 12px;
}

nav {
  display: grid;
  gap: 6px;
}

nav button {
  width: 100%;
  height: 40px;
  justify-content: flex-start;
  border: 1px solid transparent;
  background: transparent;
  color: #cbd5e1;
  border-radius: var(--radius-xl);
  padding: 0 11px;
  text-align: left;
}

nav button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

nav button.active {
  background: #eef2ff;
  color: #3730a3;
  border-color: #c7d2fe;
  font-weight: 700;
}

.nav-icon {
  width: 20px;
  color: inherit;
  text-align: center;
  font-size: 13px;
  opacity: .9;
}

.aside-foot {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-xl);
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  line-height: 1.5;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
}

header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  z-index: 4;
  backdrop-filter: blur(10px);
}

.header-title {
  min-width: 0;
}

.header-title h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.header-title span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 78vw;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

main {
  padding: 22px;
  min-width: 0;
  max-width: 1500px;
  width: 100%;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

.section-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.metric {
  min-height: 106px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xl);
  background: var(--panel);
  padding: 15px;
  box-shadow: var(--shadow);
}

.metric .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 16px;
  font-size: 31px;
  line-height: 1;
}

.metric .trend {
  margin-top: 10px;
  color: var(--faint);
  font-size: 12px;
}

.panel {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 16px;
}

.panel-title {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  background: #f8fafc;
}

.panel-title h3 {
  margin: 0;
  font-size: 14px;
  line-height: 1.2;
}

.panel-title span {
  color: var(--muted);
  font-size: 12px;
}

form {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  padding: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  min-width: 0;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: #fff;
  color: var(--text);
  outline: none;
}

input, select {
  height: 36px;
  padding: 0 10px;
}

textarea {
  min-height: 72px;
  resize: vertical;
  padding: 9px 10px;
  line-height: 1.45;
}

input:focus, select:focus, textarea:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, .22);
}

.wide {
  grid-column: span 2;
}

.actions {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}

.checkline {
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.checkline input {
  width: 16px;
  height: 16px;
  box-shadow: none;
}

.entry-controls {
  display: grid;
  grid-template-columns: minmax(76px, .7fr) minmax(110px, 1fr);
  gap: 7px;
}

.entry-controls.shadowsocks-controls {
  grid-template-columns: minmax(76px, .6fr) minmax(105px, .7fr) minmax(210px, 1.4fr) minmax(92px, .6fr);
}

.table-wrap {
  overflow-x: auto;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
  padding: 14px;
}

.data-card {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xl);
  background: #fff;
  padding: 13px;
}

.data-card:hover {
  border-color: #c7d2fe;
  background: #f8fafc;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.card-title {
  min-width: 0;
}

.card-title strong {
  display: block;
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card-title span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

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

.card-field {
  min-width: 0;
  border-top: 1px solid var(--line-soft);
  padding-top: 8px;
}

.card-field span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.card-field strong {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.card-wide {
  grid-column: 1 / -1;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid var(--line-soft);
}

.card-empty {
  grid-column: 1 / -1;
  min-height: 88px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius-xl);
  background: #f8fafc;
}

.pager {
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 12px;
  background: #f8fafc;
}

.pager-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
  background: var(--panel);
}

th, td {
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  padding: 11px 13px;
  font-size: 13px;
  vertical-align: top;
}

th {
  color: #334155;
  font-weight: 700;
  background: #f8fafc;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #f8fafc;
}

code {
  display: inline-block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  color: #334155;
}

pre {
  margin: 0;
  max-width: 760px;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: #0f172a;
  color: #dbeafe;
  padding: 10px;
  font-size: 12px;
  line-height: 1.45;
}

.muted {
  color: var(--muted);
}

.mono-line {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge.portal, .badge.success, .badge.online, .badge.issued, .badge.enabled {
  background: var(--green-soft);
  color: #047857;
  border-color: #bbf7d0;
}

.badge.bridge, .badge.running, .badge.pending {
  background: var(--blue-soft);
  color: #4338ca;
  border-color: #c7d2fe;
}

.badge.failed, .badge.offline {
  background: var(--red-soft);
  color: var(--red);
  border-color: #fecaca;
}

.badge.warning, .badge.issuing {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: #fde68a;
}

.row-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.empty {
  height: 88px;
  color: var(--muted);
  text-align: center;
}

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

.guide-body {
  padding: 14px;
}

.guide-note {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

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

.guide-table {
  min-width: 0;
  overflow: hidden;
}

.guide-table table {
  min-width: 0;
}

.guide-table th,
.guide-table td {
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
}

.guide-table th {
  color: #475467;
  background: #f8fafc;
}

.guide-table strong {
  color: var(--text);
}

.guide-callout {
  display: grid;
  gap: 10px;
  align-content: start;
  border-top: 1px solid var(--line-soft);
  margin-top: 14px;
  padding-top: 12px;
}

.guide-callout h4 {
  margin: 0;
  font-size: 13px;
}

.guide-callout p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.guide-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

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

.flow-card,
.check-card,
.trouble-grid article {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xl);
  background: #fff;
  padding: 14px;
}

.flow-card {
  position: relative;
  display: grid;
  gap: 8px;
  align-content: start;
}

.flow-step {
  width: 34px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  font-size: 12px;
  font-weight: 800;
}

.flow-card h4,
.trouble-grid h4 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
}

.flow-card p,
.flow-card ul,
.trouble-grid p,
.check-card span {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.flow-card ul {
  padding-left: 17px;
}

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

.check-card {
  display: grid;
  gap: 6px;
}

.check-card strong {
  color: var(--text);
  font-size: 13px;
}

.trouble-grid article {
  display: grid;
  gap: 7px;
  background: #f8fafc;
}

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

.command-card {
  min-width: 0;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xl);
  background: #fff;
  padding: 14px;
}

.command-card h4 {
  margin: 0;
  color: var(--text);
  font-size: 13px;
}

.command-card pre {
  max-width: none;
  max-height: 240px;
  font-size: 11px;
  line-height: 1.55;
}

.system-diagram {
  display: grid;
  gap: 14px;
}

.diagram-lane {
  display: grid;
  grid-template-columns: 92px minmax(170px, 1fr) auto minmax(170px, 1fr) auto minmax(170px, 1fr) auto minmax(170px, 1fr);
  align-items: stretch;
  gap: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xl);
  background: #f8fafc;
  padding: 12px;
}

.diagram-lane-title {
  display: grid;
  place-items: center;
  border-radius: var(--radius-xl);
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.diagram-node {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 7px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xl);
  background: #fff;
  padding: 13px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.diagram-node svg {
  width: 20px;
  height: 20px;
  color: var(--indigo);
}

.diagram-node strong {
  color: var(--text);
  font-size: 13px;
}

.diagram-node em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.diagram-arrow {
  min-width: 54px;
  display: grid;
  place-items: center;
  color: #4338ca;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.diagram-arrow::after {
  content: ">";
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #eef2ff;
  margin-left: 6px;
}

.config-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.config-card {
  min-width: 0;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xl);
  background: #fff;
  padding: 14px;
}

.config-card h4,
.traffic-route h4 {
  margin: 0;
  color: var(--text);
  font-size: 14px;
}

.config-card p,
.config-card span,
.traffic-route p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.config-card span {
  border-top: 1px solid var(--line-soft);
  padding-top: 8px;
  color: #475569;
  font-weight: 700;
}

.traffic-map {
  display: grid;
  gap: 12px;
}

.traffic-route {
  min-width: 0;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-xl);
  background: #fff;
  padding: 14px;
}

.traffic-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  align-items: center;
  gap: 8px;
}

.traffic-steps span {
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-xl);
  background: #f8fafc;
  color: #334155;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.traffic-steps i {
  position: relative;
  display: none;
}

.traffic-steps span:not(:last-child) {
  position: relative;
}

.traffic-steps span:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -9px;
  z-index: 1;
  width: 10px;
  height: 2px;
  background: #c7d2fe;
}

.traffic-steps span:not(:first-child)::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -9px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid #c7d2fe;
  transform: translateY(-45%);
}

@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  aside {
    height: auto;
    position: static;
    padding: 12px;
  }
  .brand {
    margin-bottom: 10px;
    padding-bottom: 12px;
  }
  nav {
    display: flex;
    overflow-x: auto;
  }
  nav button {
    min-width: 124px;
  }
  .aside-foot {
    display: none;
  }
  .stats, form, .split, .guide-grid, .flow-grid, .check-grid, .trouble-grid, .command-grid, .config-map {
    grid-template-columns: 1fr;
  }
  .diagram-lane {
    grid-template-columns: 1fr;
  }
  .diagram-lane-title {
    min-height: 42px;
  }
  .diagram-arrow {
    min-height: 28px;
  }
  .diagram-arrow::after {
    content: "v";
    margin: 6px 0 0;
  }
  .traffic-steps {
    grid-template-columns: 1fr;
  }
  .traffic-steps span:not(:last-child)::after {
    top: auto;
    right: 50%;
    bottom: -9px;
    width: 2px;
    height: 10px;
    transform: translateX(50%);
  }
  .traffic-steps span:not(:first-child)::before {
    top: -9px;
    left: 50%;
    border-top: 7px solid #c7d2fe;
    border-right: 5px solid transparent;
    border-bottom: 0;
    border-left: 5px solid transparent;
    transform: translateX(-50%);
  }
  .cards-grid, .card-fields {
    grid-template-columns: 1fr;
  }
  .wide {
    grid-column: span 1;
  }
  header {
    position: static;
    height: auto;
    min-height: 64px;
    align-items: flex-start;
    padding: 14px;
  }
  main {
    padding: 14px;
  }
}
