:root {
  --bg: #f4f7f6;
  --panel: #fff;
  --ink: #17211e;
  --muted: #6c7975;
  --line: #e2e9e6;
  --green: #08a86b;
  --green-dark: #078557;
  --green-soft: #e7f8f1;
  --blue: #3478f6;
  --purple: #8254dd;
  --orange: #e58a22;
  --danger: #c43d4c;
  --shadow: 0 10px 32px rgba(26, 53, 44, .07);
  --radius: 14px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--bg); font-size: 14px; }
a { color: inherit; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 24px 18px;
  display: flex; flex-direction: column; color: #dce9e4;
  background: #132a24;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 28px; text-decoration: none; }
.brand-mark {
  width: 39px; height: 39px; flex: 0 0 39px; display: grid; place-items: center;
  border-radius: 11px; color: white; background: var(--green); font-size: 13px; font-weight: 800;
  box-shadow: 0 8px 18px rgba(8, 168, 107, .3);
}
.brand strong, .login-brand strong { display: block; color: #fff; letter-spacing: .02em; font-size: 15px; }
.brand small, .login-brand small { display: block; margin-top: 3px; color: #8eaaa0; font-size: 11px; }
.nav { display: grid; gap: 6px; }
.nav-item {
  display: flex; gap: 12px; align-items: center; min-height: 44px; padding: 0 13px;
  border-radius: 10px; text-decoration: none; color: #a9bdb6; font-weight: 600;
}
.nav-item:hover { color: white; background: rgba(255,255,255,.055); }
.nav-item.active { color: #fff; background: rgba(8,168,107,.2); box-shadow: inset 3px 0 var(--green); }
.nav-icon { width: 20px; color: #7dd5b3; font-size: 19px; text-align: center; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.09); padding: 18px 7px 0; }
.admin-chip { display: flex; align-items: center; gap: 10px; min-width: 0; margin-bottom: 14px; }
.admin-chip span:last-child { min-width: 0; }
.admin-chip strong { display: block; max-width: 145px; overflow: hidden; text-overflow: ellipsis; }
.admin-chip small { color: #8eaaa0; display: block; margin-top: 2px; font-size: 11px; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #073424; background: #80e0bd; font-weight: 800; }
.logout-button { width: 100%; padding: 9px; color: #b9cac4; border: 1px solid rgba(255,255,255,.12); border-radius: 9px; background: transparent; cursor: pointer; }
.logout-button:hover { color: white; border-color: rgba(255,255,255,.3); }

.main { min-width: 0; }
.topbar { min-height: 108px; padding: 25px clamp(22px, 4vw, 54px) 20px; display: flex; align-items: flex-end; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.88); }
.eyebrow { margin: 0 0 6px; color: var(--green-dark); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.topbar h1 { margin: 0; font-size: 25px; letter-spacing: -.02em; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 11px; border: 1px solid #ccecdf; border-radius: 999px; color: #477267; background: #f4fcf8; font-size: 12px; font-weight: 600; }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(8,168,107,.13); }
.content { max-width: 1600px; padding: 30px clamp(22px, 4vw, 54px) 55px; margin: auto; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(170px, 1fr)); gap: 16px; margin-bottom: 22px; }
.metric-card { position: relative; overflow: hidden; min-height: 148px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.metric-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: currentColor; }
.metric-card::after { content: ""; position: absolute; width: 92px; height: 92px; right: -34px; top: -38px; border-radius: 50%; background: currentColor; opacity: .075; }
.metric-card.accent-green { color: var(--green); }
.metric-card.accent-blue { color: var(--blue); }
.metric-card.accent-purple { color: var(--purple); }
.metric-card.accent-orange { color: var(--orange); }
.metric-label { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-card strong { display: block; margin: 12px 0 7px; color: var(--ink); font-size: 31px; line-height: 1; }
.metric-card small { color: var(--muted); }

.panel, .account-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.panel-head { padding: 21px 23px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 17px; }
.panel-head .muted { margin: 5px 0 0; }
.panel-head-wrap { gap: 18px; flex-wrap: wrap; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 12px 18px; color: #72807b; background: #f8faf9; border-bottom: 1px solid var(--line); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
td { padding: 14px 18px; border-bottom: 1px solid #edf1ef; color: #52605c; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdfc; }
.primary-text { display: block; color: var(--ink); font-weight: 650; }
.subline { display: block; max-width: 350px; margin-top: 4px; color: #87928f; font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
.uuid-cell { min-width: 270px; color: #3d4c47; font-size: 12px; }
.message-cell { max-width: 360px; white-space: normal; }
.nowrap { white-space: nowrap; }
.align-right { text-align: right; }
.count { color: var(--ink); font-size: 16px; }
.empty { padding: 50px 20px; color: var(--muted); text-align: center; }
.table-link, .text-button { color: var(--green-dark); font-weight: 700; text-decoration: none; }
.table-link:hover, .text-button:hover { text-decoration: underline; }

.badge { display: inline-block; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.badge.success { color: #08754e; background: #e2f7ee; }
.badge.danger { color: #a82c3a; background: #fdebed; }
.badge.neutral { color: #5d6b67; background: #eef2f0; }
.primary-button, .secondary-button, .search-form button, .text-button { transition: background-color .15s, border-color .15s, transform .15s; }
.primary-button { display: inline-flex; width: 100%; min-height: 45px; align-items: center; justify-content: center; padding: 0 17px; border: 0; border-radius: 9px; color: white; background: var(--green); font-weight: 750; text-decoration: none; cursor: pointer; }
.primary-button:hover { background: var(--green-dark); }
.primary-button:disabled { opacity: .48; cursor: not-allowed; }
.primary-button.compact { width: auto; min-height: 39px; }
.secondary-button { display: inline-flex; min-height: 37px; padding: 0 13px; align-items: center; border: 1px solid #cad8d3; border-radius: 8px; color: #38564c; background: white; font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.secondary-button:hover { border-color: var(--green); color: var(--green-dark); }
.danger-button { padding: 7px 10px; border: 1px solid #e4aeb5; border-radius: 7px; color: var(--danger); background: #fff7f8; font-size: 12px; font-weight: 700; cursor: pointer; }
.danger-button:hover { color: white; border-color: var(--danger); background: var(--danger); }
.toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.search-form { display: flex; min-width: min(380px, 70vw); }
.search-form input { min-width: 0; flex: 1; padding: 9px 11px; border: 1px solid #cad8d3; border-right: 0; border-radius: 8px 0 0 8px; outline: none; color: var(--ink); background: white; }
.search-form input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(8,168,107,.1); }
.search-form button { padding: 0 15px; border: 1px solid var(--green); border-radius: 0 8px 8px 0; color: white; background: var(--green); font-weight: 700; cursor: pointer; }

.pagination { padding: 16px 20px; display: flex; justify-content: flex-end; align-items: center; gap: 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.pagination a, .pagination .disabled { padding: 7px 10px; border: 1px solid #d6dfdc; border-radius: 7px; text-decoration: none; }
.pagination a:hover { color: var(--green-dark); border-color: var(--green); }
.pagination .disabled { opacity: .45; }
.breadcrumb { display: flex; gap: 9px; margin: -7px 0 17px; color: var(--muted); font-size: 12px; }
.breadcrumb a { color: var(--green-dark); text-decoration: none; }
.account-card { display: grid; grid-template-columns: auto minmax(170px, 1fr) minmax(420px, 2fr) auto; gap: 22px; align-items: center; margin-bottom: 22px; padding: 23px; }
.account-avatar { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 16px; color: #08734e; background: var(--green-soft); font-size: 22px; font-weight: 800; }
.account-title h2 { margin: 0 0 5px; font-size: 19px; }
.account-title > span { color: var(--muted); font-size: 11px; }
.account-meta { display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)); gap: 11px 22px; margin: 0; }
.account-meta div { min-width: 0; }
.account-meta dt { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .06em; }
.account-meta dd { margin: 4px 0 0; color: #3c4a46; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.login-page { min-height: 100vh; padding: 30px; display: grid; place-items: center; background: radial-gradient(circle at 20% 20%, #dcf7eb 0, transparent 28%), radial-gradient(circle at 88% 82%, #dcece8 0, transparent 29%), #eef4f1; }
.login-panel { width: min(430px, 100%); padding: 37px; border: 1px solid rgba(205,220,214,.9); border-radius: 20px; background: rgba(255,255,255,.97); box-shadow: 0 26px 70px rgba(30,65,53,.14); }
.login-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 31px; }
.login-brand strong { color: var(--ink); }
.brand-mark-lg { width: 45px; height: 45px; }
.login-panel h1 { margin: 0 0 8px; font-size: 27px; letter-spacing: -.025em; }
.muted { color: var(--muted); }
.login-panel > .muted { margin: 0 0 25px; line-height: 1.7; }
.login-form { display: grid; gap: 17px; }
.field label { display: block; margin-bottom: 7px; color: #3c4a46; font-size: 12px; font-weight: 750; }
.field input { width: 100%; padding: 12px; border: 1px solid #cad7d2; border-radius: 9px; outline: none; background: white; }
.field input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(8,168,107,.1); }
.field-error { display: block; margin-top: 5px; color: var(--danger); }
.admin-layout { display: grid; grid-template-columns: minmax(280px, 390px) minmax(540px, 1fr); gap: 22px; align-items: start; }
.admin-form-panel { overflow: hidden; }
.stack-form { display: grid; gap: 17px; padding: 22px; }
.policy-note { display: grid; gap: 6px; margin: 0 22px 22px; padding: 14px; border: 1px solid #ccecdf; border-radius: 10px; color: #477267; background: #f4fcf8; font-size: 12px; line-height: 1.6; }
.policy-note strong { color: var(--green-dark); }
.activity-grid { grid-template-columns: repeat(3, minmax(200px, 1fr)); }
.activity-panel { overflow: hidden; }
.activity-actions { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px; }
.activity-meta { display: flex; gap: 34px; margin: 0; flex-wrap: wrap; }
.activity-meta dt { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .06em; }
.activity-meta dd { margin: 5px 0 0; color: var(--ink); }
.activity-button { min-height: 39px; }
.security-note { margin: 20px 0 0; color: #899590; font-size: 10px; text-align: center; }
.robot-create { display: flex; align-items: flex-end; gap: 12px; margin: 18px 0 22px; flex-wrap: wrap; }
.robot-create label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.robot-create input { min-height: 39px; padding: 8px 11px; border: 1px solid #cad8d3; border-radius: 8px; background: white; outline: none; }
.robot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 520px)); gap: 18px; align-items: start; }
.robot-card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.robot-card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 19px 20px; border-bottom: 1px solid var(--line); background: linear-gradient(135deg, #fff, #f7fcfa); }
.robot-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.robot-title h2 { margin: 0 0 3px; font-size: 17px; }
.robot-title small { display: block; overflow-wrap: anywhere; color: var(--muted); font-size: 11px; }
.robot-number { width: 39px; height: 39px; flex: 0 0 39px; display: grid; place-items: center; border-radius: 11px; color: #08734e; background: var(--green-soft); font-weight: 850; }
.robot-card-body { padding: 20px; }
.robot-meta { display: grid; grid-template-columns: 1fr; gap: 13px; margin: 0 0 18px; }
.robot-meta div { min-width: 0; padding: 11px 12px; border: 1px solid #edf2f0; border-radius: 9px; background: #fafcfb; }
.robot-meta dt { margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .06em; }
.robot-meta dd { margin: 0; overflow: hidden; color: #34433e; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.robot-section { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line); }
.robot-section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.robot-section-title strong { font-size: 13px; }
.robot-section-title small { color: var(--muted); font-size: 10px; text-align: right; }
.robot-field { display: grid; gap: 7px; color: #52605c; font-size: 11px; font-weight: 700; }
.robot-field select { width: 100%; min-width: 0; min-height: 41px; padding: 0 35px 0 11px; border: 1px solid #cad8d3; border-radius: 9px; color: var(--ink); background: white; outline: none; }
.robot-field select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(8,168,107,.1); }
.robot-actions { display: flex; gap: 9px; margin-top: 10px; flex-wrap: wrap; }
.robot-actions .primary-button { width: auto; min-width: 0; flex: 1; }
.robot-hint { min-height: 17px; margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.inline-form { margin-top: 10px; }
.robot-account-section .primary-button { width: 100%; }
.robot-qr { display: block; max-width: 100%; height: auto; margin: 12px auto 0; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.robot-qr[hidden] { display: none; }
.robot-card-foot { display: flex; justify-content: space-between; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: #fafcfb; }
.robot-card-foot form { margin: 0; }
.robot-empty { max-width: 520px; padding: 48px 24px; border: 1px dashed #cbd9d4; border-radius: 16px; color: var(--muted); background: rgba(255,255,255,.55); text-align: center; }
.robot-empty span { width: 46px; height: 46px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 13px; color: var(--green-dark); background: var(--green-soft); font-weight: 850; }
.robot-empty h2 { margin: 0 0 6px; color: var(--ink); font-size: 16px; }
.robot-empty p { margin: 0; font-size: 12px; }
.alert { margin: 0 0 18px; padding: 11px 13px; border: 1px solid; border-radius: 9px; font-size: 12px; }
.alert-danger { color: #9e2937; border-color: #facdd2; background: #fff1f2; }
.alert-warning { color: #8a5a14; border-color: #f0d79e; background: #fff9e9; }
.alert-success { color: #08704b; border-color: #bfe6d5; background: #ecfaf4; }
.error-panel { padding: 70px 30px; border: 1px solid var(--line); border-radius: var(--radius); background: white; text-align: center; box-shadow: var(--shadow); }
.error-panel.standalone { width: min(580px, 100%); }
.error-code { display: block; color: var(--green); font-size: 56px; font-weight: 850; line-height: 1; }
.error-panel h1, .error-panel h2 { margin: 16px 0 8px; }
.error-panel .primary-button { margin-top: 18px; }
.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; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(170px, 1fr)); }
  .account-card { grid-template-columns: auto 1fr auto; }
  .account-meta { grid-column: 1 / -1; grid-row: 2; }
  .admin-layout { grid-template-columns: 1fr; }
  .activity-grid { grid-template-columns: 1fr; }
  .activity-actions { align-items: stretch; flex-direction: column; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: auto; height: auto; padding: 13px 15px; flex-direction: row; align-items: center; gap: 15px; overflow-x: auto; }
  .brand { padding: 0; }
  .brand > span:last-child, .sidebar-foot { display: none; }
  .nav { display: flex; gap: 4px; }
  .nav-item { min-height: 40px; padding: 0 10px; white-space: nowrap; }
  .nav-icon { display: none; }
  .topbar { min-height: 88px; padding: 18px 17px; }
  .status-pill { display: none; }
  .content { padding: 19px 13px 40px; }
  .metric-grid { gap: 10px; }
  .metric-card { min-height: 125px; padding: 17px; }
  .metric-card strong { font-size: 26px; }
  .panel-head { padding: 17px; }
  th, td { padding: 12px 14px; }
  .toolbar, .search-form { width: 100%; min-width: 0; }
  .account-card { grid-template-columns: auto 1fr; gap: 15px; padding: 18px; }
  .account-card > .primary-button { grid-column: 1 / -1; }
  .account-meta { grid-template-columns: 1fr; }
  .robot-grid { grid-template-columns: minmax(0, 1fr); }
  .robot-card-head { padding: 16px; }
  .robot-card-body { padding: 16px; }
  .robot-section-title { display: block; }
  .robot-section-title small { margin-top: 3px; text-align: left; }
  .robot-card-foot { padding: 13px 16px; }
}

@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr; }
  .login-page { padding: 14px; }
  .login-panel { padding: 27px 21px; }
  .topbar h1 { font-size: 21px; }
}
