@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Manrope:wght@600;700;800&display=swap');

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-soft: #f8f8fc;
  --ink: #171525;
  --muted: #777487;
  --line: #e8e7ee;
  --primary: #635bff;
  --primary-dark: #4d45db;
  --violet-soft: #eeecff;
  --green: #149c68;
  --green-soft: #e7f7f0;
  --amber: #c67b12;
  --amber-soft: #fff3da;
  --red: #d83a52;
  --red-soft: #fdebef;
  --cyan: #1689a7;
  --cyan-soft: #e6f6fa;
  --shadow: 0 12px 34px rgba(31, 25, 61, .07);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--bg); font: 14px/1.5 Inter, sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3, .brand strong { font-family: Manrope, sans-serif; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 3vw, 40px); line-height: 1.14; letter-spacing: -.04em; }
h2 { margin-bottom: 4px; font-size: 18px; letter-spacing: -.02em; }
h3 { margin-bottom: 6px; }
.muted, small { color: var(--muted); }

.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 24px 18px; background: #171522; color: #f6f5ff; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: white; background: linear-gradient(145deg, #8078ff, #554cf1); box-shadow: 0 8px 24px rgba(99,91,255,.35); font: 800 20px Manrope, sans-serif; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.2; }
.brand small { margin-top: 3px; color: #9e9aae; font-size: 10px; text-transform: uppercase; letter-spacing: .12em; }
.sidebar nav { display: grid; gap: 6px; margin-top: 42px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 11px; color: #aaa6b7; font-weight: 600; transition: .18s ease; }
.sidebar nav a:hover, .sidebar nav a.active { color: white; background: rgba(255,255,255,.08); }
.nav-icon { display: inline-grid; width: 22px; place-items: center; font-size: 18px; }
.sidebar-footer { display: grid; gap: 14px; margin-top: auto; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.09); }
.profile { display: flex; align-items: center; min-width: 0; gap: 10px; }
.profile img, .avatar { width: 35px; height: 35px; border-radius: 50%; object-fit: cover; }
.avatar { display: grid; place-items: center; background: #393547; }
.profile-copy { display: flex; min-width: 0; flex-direction: column; }
.profile-copy strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy small { font-size: 10px; text-transform: uppercase; }
.main { min-width: 0; padding: 38px clamp(24px, 4vw, 58px) 60px; }
.mobile-header { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-head p { margin-bottom: 0; color: var(--muted); }
.eyebrow { display: inline-block; margin-bottom: 9px; color: var(--primary); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 18px; border: 1px solid transparent; border-radius: 11px; font-weight: 700; transition: .15s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--primary); box-shadow: 0 8px 18px rgba(99,91,255,.2); }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { border-color: var(--line); background: white; }
.button.ghost { color: var(--muted); border-color: transparent; background: transparent; }
.sidebar .button.ghost { border-color: rgba(255,255,255,.1); color: #c1bdcd; }
.button.full { width: 100%; }
.button.compact { min-height: 34px; padding: 0 12px; font-size: 12px; }
.icon-button { border: 0; background: transparent; font-size: 22px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.metric-card { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 13px; min-height: 132px; padding: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.metric-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; font-size: 18px; font-weight: 800; }
.metric-icon.violet { color: var(--primary); background: var(--violet-soft); }
.metric-icon.cyan { color: var(--cyan); background: var(--cyan-soft); }
.metric-icon.green { color: var(--green); background: var(--green-soft); }
.metric-icon.amber { color: var(--amber); background: var(--amber-soft); }
.metric-card div { display: flex; flex-direction: column; }
.metric-card div small { font-weight: 600; }
.metric-card div strong { font: 800 29px Manrope, sans-serif; }
.metric-foot { position: absolute; right: 18px; bottom: 16px; color: var(--muted); font-size: 11px; }
.metric-foot.link { color: var(--primary); font-weight: 700; }

.two-column { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr); gap: 18px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 21px 22px; border-bottom: 1px solid var(--line); }
.panel-head p { margin: 0; color: var(--muted); font-size: 12px; }
.panel-head > a { color: var(--primary); font-size: 12px; font-weight: 700; }
.instance-row { display: flex; align-items: center; gap: 12px; padding: 15px 22px; border-bottom: 1px solid var(--line); }
.instance-row:last-child { border-bottom: 0; }
.instance-row:hover { background: var(--surface-soft); }
.bot-avatar, .chat-avatar { display: grid; flex: 0 0 auto; place-items: center; width: 40px; height: 40px; border-radius: 12px; color: #37304e; background: #eeeaf7; font-weight: 800; }
.bot-avatar.production { color: #125c44; background: var(--green-soft); }
.bot-avatar.development { color: #6c4b0b; background: var(--amber-soft); }
.bot-avatar.large { width: 52px; height: 52px; border-radius: 15px; font-size: 16px; }
.instance-copy { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.instance-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; min-height: 25px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 100px; color: #595568; background: #fafafe; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.pill.environment { color: var(--primary); background: var(--violet-soft); border-color: transparent; }
.health { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: capitalize; white-space: nowrap; }
.health i, .status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #aaa; }
.health.healthy { color: var(--green); }.health.healthy i, .status-dot.healthy { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.health.degraded { color: var(--amber); }.health.degraded i { background: var(--amber); }
.health.offline { color: var(--red); }.health.offline i { background: var(--red); }
.activity-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 11px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.activity-row:last-child { border: 0; }
.activity-row > span:nth-child(2) { display: flex; min-width: 0; flex-direction: column; }
.activity-row small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-row time { color: var(--muted); font-size: 10px; }
.activity-icon { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 9px; color: var(--amber); background: var(--amber-soft); font-weight: 800; }
.activity-icon.succeeded { color: var(--green); background: var(--green-soft); }
.empty-state { padding: 35px 22px; color: var(--muted); text-align: center; }

.bot-grid { display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); gap: 16px; }
.bot-card { padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.bot-card-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.bot-card h2 { margin-bottom: 2px; }
.bot-card > p { color: var(--muted); }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; }
.detail-list { margin: 17px 0; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail-list div { display: flex; justify-content: space-between; padding: 5px 0; }
.detail-list dt { color: var(--muted); }.detail-list dd { margin: 0; font-weight: 600; }
.inline-error { margin-bottom: 13px; padding: 10px; overflow: hidden; border-radius: 9px; color: var(--red); background: var(--red-soft); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.split-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.narrow-panel { max-width: 850px; }
.section-divider { position: relative; margin-top: 27px !important; padding-top: 18px; border-top: 1px solid var(--line); }
.section-divider span { font: 700 14px Manrope, sans-serif; }

.select-wrap, .form-grid label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 700; }
input, select { min-height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; outline: none; color: var(--ink); background: white; }
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--violet-soft); }
.table-panel { overflow: hidden; }
.table-tools { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.search { display: flex; align-items: center; width: min(340px, 100%); border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.search span { padding-left: 12px; color: var(--muted); font-size: 18px; }
.search input { width: 100%; border: 0; background: transparent; box-shadow: none; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 12px 17px; color: var(--muted); background: #fbfbfd; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
td { padding: 14px 17px; border-top: 1px solid var(--line); white-space: nowrap; }
tbody tr:hover { background: #fcfcfe; }
.chat-name { display: flex; align-items: center; gap: 10px; }
.chat-name > span:last-child { display: flex; flex-direction: column; }
.chat-avatar { width: 37px; height: 37px; border-radius: 10px; font-size: 11px; }
.chat-avatar.image { object-fit: cover; }
.row-link, .back-link { color: var(--primary); font-weight: 700; }
.inline-form { display: flex; gap: 6px; }

.detail-head { align-items: center; }
.detail-head h1 { margin-top: 8px; }
.back-link { font-size: 12px; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 18px; align-items: start; }
.form-panel { overflow: hidden; }
.form-panel > :not(.panel-head) { margin-right: 22px; margin-left: 22px; }
.form-grid { display: grid; gap: 15px; margin-top: 22px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-group { margin-top: 24px; }
.field-title { display: block; margin-bottom: 10px; font-size: 12px; font-weight: 700; }
.day-picker { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.day-picker input { position: absolute; opacity: 0; pointer-events: none; }
.day-picker span { display: grid; place-items: center; min-height: 40px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted); font-weight: 700; cursor: pointer; }
.day-picker input:checked + span { color: var(--primary); border-color: var(--primary); background: var(--violet-soft); }
.switch-list { border: 1px solid var(--line); border-radius: 13px; overflow: hidden; }
.switch-list label, .enable-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 62px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.switch-list label:last-child { border: 0; }
.switch-list label > span, .enable-row > span { display: flex; flex-direction: column; }
.switch-list label small, .enable-row small { font-weight: 400; }
.switch-list input, .enable-row input { position: absolute; opacity: 0; }
.switch-list i, .enable-row i { position: relative; width: 38px; height: 22px; flex: 0 0 auto; border-radius: 20px; background: #d9d7e0; transition: .16s; }
.switch-list i::after, .enable-row i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: white; box-shadow: 0 2px 6px rgba(0,0,0,.15); transition: .16s; }
.switch-list input:checked + i, .enable-row input:checked + i { background: var(--primary); }
.switch-list input:checked + i::after, .enable-row input:checked + i::after { transform: translateX(16px); }
.switch-list input:disabled + i { opacity: .55; }
.enable-row { margin-top: 24px; border: 1px solid var(--line) !important; border-radius: 13px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 22px 0; }
.editor-aside { display: grid; gap: 18px; }
.preview { overflow: hidden; }
.telegram-preview { padding: 22px; background: #dfe8ef; }
.telegram-bubble { padding: 14px; border-radius: 13px 13px 13px 4px; background: white; box-shadow: 0 3px 10px rgba(40,62,78,.1); font-size: 11px; }
.telegram-bubble p { margin: 4px 0 12px; }
.preview-day { display: flex; flex-direction: column; padding: 7px 0; border-top: 1px solid #eee; }
.preview-day span { color: #676476; }
.preview-buttons { display: flex; gap: 4px; margin-top: 5px; }
.preview-buttons button { flex: 1; min-height: 30px; border: 0; border-radius: 7px; color: #1683bd; background: rgba(255,255,255,.92); }
.action-card { padding: 20px; }
.action-card p { color: var(--muted); font-size: 12px; }
.game-layout { grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); }
.game-row { border-bottom: 1px solid var(--line); }
.game-row:last-child { border-bottom: 0; }
.game-row summary { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 15px 20px; cursor: pointer; list-style: none; }
.game-row summary::-webkit-details-marker { display: none; }
.game-row summary > span:nth-child(2) { display: flex; flex-direction: column; }
.game-row[open] summary { background: var(--surface-soft); }
.result-list { margin: 0; padding: 10px 22px 15px 62px; }
.result-list li { padding: 5px 0; color: var(--muted); }
.result-list li span { display: inline-block; min-width: 150px; color: var(--ink); }
.leaderboard { margin: 0; padding: 0; list-style: none; }
.leaderboard li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.leaderboard li:last-child { border: 0; }
.leaderboard li > span:nth-child(2) { display: flex; flex-direction: column; }
.leaderboard li > b { font: 800 17px Manrope, sans-serif; }
.rank { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 9px; color: var(--primary); background: var(--violet-soft); font-weight: 800; }
.jobs-layout { grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); }

.flash { position: fixed; z-index: 20; top: 24px; right: 28px; padding: 13px 18px; border: 1px solid #c9eadb; border-radius: 11px; color: var(--green); background: white; box-shadow: var(--shadow); transition: .3s ease; }
.flash.leaving { opacity: 0; transform: translateY(-8px); }
.notice { padding: 12px; border-radius: 10px; }.notice.warning { color: var(--amber); background: var(--amber-soft); }

.auth-page { display: grid; grid-template-columns: minmax(420px, .78fr) minmax(480px, 1.22fr); min-height: 100vh; background: white; }
.auth-card { display: flex; width: min(440px, calc(100% - 56px)); margin: auto; flex-direction: column; gap: 18px; }
.auth-brand { margin-bottom: 44px; color: var(--ink); }
.auth-copy h1 { max-width: 440px; font-size: 38px; }
.auth-copy p, .auth-note { color: var(--muted); }
.google-button { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 50px; border: 1px solid var(--line); border-radius: 12px; font-weight: 700; box-shadow: 0 4px 14px rgba(31,25,61,.05); }
.google-button:hover { border-color: #ccc8db; background: #fcfcff; }
.google-button svg { width: 20px; height: 20px; }
.auth-note { font-size: 11px; text-align: center; }
.auth-visual { position: relative; min-height: 100%; overflow: hidden; background: #171522; }
.auth-visual::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 50%, transparent, rgba(12,10,20,.42)); }
.orb { position: absolute; border-radius: 50%; filter: blur(4px); }
.orb-one { width: 520px; height: 520px; top: -180px; right: -80px; background: rgba(99,91,255,.38); }
.orb-two { width: 430px; height: 430px; bottom: -200px; left: -100px; background: rgba(30,180,185,.19); }
.court { position: absolute; z-index: 1; top: 50%; left: 50%; display: grid; width: 520px; height: 330px; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 1fr); border: 2px solid rgba(255,255,255,.16); transform: translate(-50%,-50%) rotate(-6deg); }
.court::before { content: ""; position: absolute; top: 50%; right: 0; left: 0; border-top: 2px solid rgba(255,255,255,.16); }
.court span { border-right: 1px solid rgba(255,255,255,.08); }
.floating-card { position: absolute; z-index: 2; padding: 15px 18px; border: 1px solid rgba(255,255,255,.16); border-radius: 14px; color: white; background: rgba(43,39,59,.75); box-shadow: 0 20px 45px rgba(0,0,0,.25); backdrop-filter: blur(12px); }
.floating-card small { display: block; color: #aaa6b7; }
.fc-one { top: 23%; left: 12%; }.fc-two { top: 48%; right: 10%; }.fc-three { bottom: 17%; left: 24%; }
.fc-two strong { display: block; font: 800 28px Manrope, sans-serif; }
.auth-page.simple { display: grid; place-items: center; grid-template-columns: 1fr; background: var(--bg); }
.auth-card.compact { max-width: 440px; padding: 36px; border: 1px solid var(--line); border-radius: 20px; background: white; box-shadow: var(--shadow); text-align: center; }
.pending-icon { margin: auto; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; background: var(--amber-soft); font-size: 24px; }

@media (max-width: 1180px) {
  .metric-grid, .bot-grid { grid-template-columns: repeat(2, 1fr); }
  .editor-layout { grid-template-columns: minmax(0, 1fr) 320px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 30; width: 248px; transform: translateX(-102%); transition: .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main { padding: 0 18px 40px; }
  .mobile-header { display: flex; align-items: center; gap: 12px; min-height: 62px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
  .two-column, .editor-layout { grid-template-columns: 1fr; }
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-card { padding: 45px 0; }
}
@media (max-width: 580px) {
  .metric-grid, .bot-grid, .form-grid.two { grid-template-columns: 1fr; }
  .page-head { align-items: stretch; flex-direction: column; }
  .day-picker { grid-template-columns: repeat(4, 1fr); }
  .instance-row { flex-wrap: wrap; }
  .instance-row .health { margin-left: 52px; }
}
