@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --primary: #1ead7e;
  --primary-dark: #15845f;
  --primary-soft: #e5f7f0;
  --sidebar: #202e3a;
  --sidebar-deep: #182530;
  --body: #f2f4f6;
  --surface: #fff;
  --surface-soft: #f8f9fa;
  --border: #e3e7eb;
  --text: #202e3a;
  --muted: #6f7f7a;
  --danger: #cc4050;
  --warning: #b7791f;
  --shadow: 0 1px 2px rgba(22, 35, 29, .08);
}

* { box-sizing: border-box; }
html { font-family: Inter, system-ui, sans-serif; color: var(--text); background: var(--body); }
body { margin: 0; min-height: 100vh; font-size: 14px; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; z-index: 40; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; color: #d5dde3; background: var(--sidebar); }
.brand { height: 68px; display: flex; align-items: center; gap: 11px; padding: 0 22px; background: var(--sidebar-deep); }
.brand img { width: 132px; filter: brightness(0) invert(1); }
.brand span { padding-left: 11px; border-left: 1px solid rgba(255,255,255,.2); color: #fff; font-size: 12px; font-weight: 600; }
.nav-label { padding: 23px 22px 8px; color: #82919b; font-size: 9px; font-weight: 700; letter-spacing: .12em; }
.sidebar nav { display: grid; gap: 3px; padding: 0 10px; }
.nav-link { min-height: 42px; display: flex; align-items: center; gap: 12px; padding: 0 13px; border-left: 3px solid transparent; border-radius: 4px; color: #bac5cc; font-size: 13px; font-weight: 500; }
.nav-link i { width: 18px; color: #81919b; text-align: center; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.nav-link.active { color: #fff; border-left-color: var(--primary); background: rgba(30,173,126,.13); }
.nav-link.active i { color: #4fd4a6; }
.sidebar-user { margin-top: auto; display: grid; grid-template-columns: 36px 1fr 32px; align-items: center; gap: 10px; padding: 16px 14px; border-top: 1px solid rgba(255,255,255,.09); background: var(--sidebar-deep); }
.sidebar-user strong, .sidebar-user small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user strong { color: #fff; font-size: 12px; }
.sidebar-user small { margin-top: 3px; color: #8da0ab; font-size: 10px; }
.sidebar-user form { margin: 0; }
.content-shell { min-width: 0; background: var(--body); }
.main-content { min-height: 100vh; padding: 26px 20px 54px; }
.mobile-menu { display: none; }
.sidebar-backdrop { display: none; }

.avatar { width: 38px; height: 38px; display: inline-grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: #fff; background: var(--primary); font-size: 13px; font-weight: 700; }
.avatar.small { width: 30px; height: 30px; font-size: 11px; }
.eyebrow { display: block; margin-bottom: 7px; color: var(--primary-dark); font-size: 9px; font-weight: 700; letter-spacing: .11em; }
.page-head { min-height: 64px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: clamp(25px, 2.5vw, 31px); line-height: 1.1; font-weight: 650; letter-spacing: -.035em; }
.page-head p { max-width: 680px; margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

.btn, .icon-btn, .link-button { border: 0; cursor: pointer; }
.btn { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 14px; border: 1px solid #d5dbe0; border-radius: 5px; color: #34434e; background: #fff; font-size: 12px; font-weight: 600; box-shadow: 0 1px 1px rgba(0,0,0,.02); }
.btn:hover { border-color: #b9c2ca; background: #f9fafb; }
.btn-primary { color: #fff; border-color: var(--primary); background: var(--primary); }
.btn-primary:hover { color: #fff; border-color: var(--primary-dark); background: var(--primary-dark); }
.btn-block { width: 100%; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 1px solid var(--border); border-radius: 4px; color: #53616b; background: var(--surface-soft); }
.icon-btn:hover { color: var(--text); background: #eef1f3; }
.icon-btn.dark { color: #9aabb4; border-color: rgba(255,255,255,.08); background: rgba(255,255,255,.04); }
.icon-btn.danger { color: var(--danger); border-color: #f0d5d9; background: #fff2f4; }

.notice { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; padding: 11px 14px; border: 1px solid #bfe8d9; border-radius: 5px; color: #126b4c; background: #eaf8f3; font-size: 12px; font-weight: 500; }
.notice.error { color: #8c2936; border-color: #f0cbd1; background: #fff0f2; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { position: relative; min-height: 138px; padding: 18px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.kpi > i { position: absolute; top: 17px; right: 17px; width: 32px; height: 32px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 5px; }
.kpi span, .kpi small { display: block; color: var(--muted); }
.kpi span { font-size: 11px; font-weight: 600; }
.kpi strong { display: block; margin: 20px 0 4px; font-size: 28px; line-height: 1; letter-spacing: -.04em; }
.kpi small { font-size: 10px; }
.kpi.success { background: #f5fcf9; }

.panel { margin-bottom: 16px; background: var(--surface); box-shadow: var(--shadow); }
.panel-head { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 16px; border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 650; }
.panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.panel-body { padding: 18px; }
.table-wrap { max-width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 11px 15px; color: #52616c; background: var(--surface-soft); font-size: 11px; font-weight: 650; text-align: left; white-space: nowrap; }
td { padding: 13px 15px; border-top: 1px solid var(--border); color: #485860; font-size: 12px; vertical-align: middle; }
tbody tr:hover { background: #fafbfb; }
td strong { color: var(--text); font-weight: 600; }
.row-actions { width: 1%; min-width: 80px; white-space: nowrap; }
.empty-cell { padding: 48px 16px; color: var(--muted); text-align: center; }
.truncate-cell { max-width: 440px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-cell { display: flex; align-items: center; gap: 10px; }

.badge { min-height: 23px; display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 4px; color: #53616a; background: #e9edef; font-size: 10px; font-weight: 650; white-space: nowrap; }
.badge.success { color: #0e6748; background: #dff5ed; }
.badge.danger { color: #8c2936; background: #fae3e6; }
.badge.warning { color: #86570f; background: #fff1cd; }
.badge.primary { color: #126b4c; background: var(--primary-soft); }

.agent-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.agent-card { min-height: 310px; display: flex; flex-direction: column; padding: 18px; border-top: 3px solid var(--primary); background: var(--surface); box-shadow: var(--shadow); }
.agent-card-top { display: flex; align-items: center; justify-content: space-between; }
.agent-icon { width: 38px; height: 38px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); border-radius: 5px; }
.agent-card h2 { margin: 19px 0 8px; font-size: 18px; letter-spacing: -.025em; }
.agent-card > p { min-height: 42px; margin: 0 0 14px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.chip-row { min-height: 25px; display: flex; flex-wrap: wrap; gap: 5px; }
.chip { padding: 4px 7px; border: 1px solid var(--border); border-radius: 3px; color: #61706b; background: #f8faf9; font-size: 9px; text-transform: capitalize; }
.agent-meta { display: grid; gap: 6px; margin: 16px 0; padding-top: 13px; border-top: 1px solid var(--border); color: var(--muted); font-size: 10px; }
.agent-meta span { display: flex; align-items: center; gap: 7px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-actions { display: flex; gap: 7px; margin-top: auto; }
.empty-state { grid-column: 1 / -1; min-height: 300px; display: grid; place-items: center; align-content: center; padding: 40px; color: var(--muted); background: #fff; text-align: center; }
.empty-state > i { margin-bottom: 14px; color: var(--primary); font-size: 30px; }
.empty-state h2, .empty-state p { margin: 4px 0; }

.form-stack { display: grid; gap: 0; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
label > span { display: block; margin-bottom: 7px; color: #4a5963; font-size: 11px; font-weight: 600; }
label > span small { color: var(--muted); font-weight: 400; }
.input { width: 100%; min-height: 39px; padding: 8px 11px; border: 1px solid #cfd6dc; border-radius: 4px; outline: 0; color: var(--text); background: #fff; font-size: 12px; }
.input:focus { border-color: #57bd9a; box-shadow: 0 0 0 3px rgba(30,173,126,.12); }
textarea.input { resize: vertical; line-height: 1.55; }
.code-input { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 0 0; }
.check-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.check-card { min-height: 92px; display: grid; grid-template-columns: 16px 30px 1fr; align-items: center; gap: 9px; padding: 12px; border: 1px solid var(--border); border-radius: 4px; cursor: pointer; }
.check-card:has(input:checked) { border-color: #8fd7bd; background: #f3fbf8; }
.check-card > i { color: var(--primary); font-size: 17px; }
.check-card strong, .check-card small { display: block; }
.check-card strong { color: var(--text); font-size: 11px; }
.check-card small { margin-top: 4px; color: var(--muted); font-size: 9px; line-height: 1.4; }
.upload-box { min-height: 86px; display: flex; align-items: center; gap: 13px; padding: 16px; border: 1px dashed #aebbc4; border-radius: 4px; cursor: pointer; background: #fafbfb; }
.upload-box > i { color: var(--primary); font-size: 22px; }
.upload-box strong, .upload-box small { display: block; }
.upload-box small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.upload-box input { margin-left: auto; max-width: 260px; font-size: 10px; }
.file-list { display: grid; gap: 7px; margin-top: 12px; }
.file-list > div { display: grid; grid-template-columns: 22px 1fr 32px; align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--border); }
.file-list > div > i { color: var(--primary); }
.file-list strong, .file-list small { display: block; }
.file-list strong { font-size: 11px; }
.file-list small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.user-checks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.user-checks label { display: grid; grid-template-columns: 16px 30px 1fr; align-items: center; gap: 9px; padding: 10px; border: 1px solid var(--border); cursor: pointer; }
.user-checks label:has(input:checked) { border-color: #8fd7bd; background: #f3fbf8; }
.user-checks strong, .user-checks small { display: block; }
.user-checks strong { font-size: 11px; }
.user-checks small { color: var(--muted); font-size: 9px; }
.toggle-field { display: flex; align-items: center; gap: 8px; }
.toggle-field > span { margin: 0; }
.field-action { display: flex; align-items: end; }

.run-layout { display: grid; grid-template-columns: minmax(320px, .8fr) minmax(430px, 1.2fr); gap: 14px; }
.run-layout .panel { margin: 0; }
.prompt-input { min-height: 340px; }
.run-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; color: var(--muted); font-size: 10px; }
.run-tools span { display: flex; align-items: center; gap: 5px; padding: 5px 8px; background: var(--surface-soft); }
.result-body { min-height: 440px; }
.result-body pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.7 Inter, system-ui, sans-serif; }
.output-empty { min-height: 400px; display: grid; place-items: center; align-content: center; color: var(--muted); text-align: center; }
.output-empty i { margin-bottom: 14px; color: var(--primary); font-size: 32px; }
.output-empty h3, .output-empty p { margin: 4px; }

.modal { width: min(720px, calc(100% - 28px)); max-height: 92vh; padding: 0; overflow: auto; border: 0; border-radius: 6px; box-shadow: 0 20px 60px rgba(20,31,26,.24); }
.modal::backdrop { background: rgba(31,41,55,.65); }
.modal-head { min-height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 18px; border-top: 1px solid var(--border); }

.auth-body { display: grid; place-items: center; padding: 24px; overflow-x: hidden; background: #eef2f1; }
.auth-body::before { content: ''; position: fixed; inset: 0; background: linear-gradient(120deg, rgba(30,173,126,.07), transparent 42%), linear-gradient(#e9efed 1px, transparent 1px), linear-gradient(90deg,#e9efed 1px,transparent 1px); background-size: auto, 32px 32px, 32px 32px; pointer-events: none; }
.auth-shell { position: relative; z-index: 1; width: 100%; display: grid; place-items: center; }
.auth-card { width: min(450px, 100%); padding: 35px; border-top: 4px solid var(--primary); background: #fff; box-shadow: 0 18px 55px rgba(20,40,31,.12); }
.auth-card-wide { width: min(720px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 34px; color: var(--text); font-weight: 650; }
.auth-brand img { width: 130px; }
.auth-brand span { padding-left: 12px; border-left: 1px solid var(--border); font-size: 12px; }
.auth-kicker { color: var(--primary-dark); font-size: 9px; font-weight: 700; letter-spacing: .13em; }
.auth-card h1 { margin: 10px 0 9px; font-size: 30px; line-height: 1.1; letter-spacing: -.04em; }
.auth-card > p { margin: 0 0 24px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.auth-form { display: grid; gap: 15px; }
.input-icon { position: relative; }
.input-icon i { position: absolute; left: 12px; top: 50%; color: var(--primary); transform: translateY(-50%); }
.input-icon input { padding-left: 35px; }
.otp-input { height: 52px; font-size: 23px; font-weight: 700; letter-spacing: .25em; text-align: center; }
.link-button { display: block; margin: 14px auto 0; color: var(--primary-dark); background: none; font-size: 11px; font-weight: 600; }
.auth-foot { display: block; margin-top: 26px; color: #94a19c; font-size: 9px; text-align: center; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 230px minmax(0, 1fr); }
  .agent-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .check-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .user-checks { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 820px) {
  .shell { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; width: 250px; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 16px 0 40px rgba(0,0,0,.2); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(25,35,31,.45); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .mobile-menu { position: sticky; top: 10px; z-index: 30; width: 40px; height: 40px; display: grid; place-items: center; margin: 10px 14px 0; border: 0; border-radius: 4px; color: #fff; background: var(--sidebar); box-shadow: var(--shadow); }
  .main-content { min-height: calc(100vh - 50px); padding: 18px 14px 40px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .run-layout { grid-template-columns: 1fr; }
  .result-body { min-height: 320px; }
  .prompt-input { min-height: 230px; }
}

@media (max-width: 600px) {
  .page-head { align-items: stretch; flex-direction: column; gap: 13px; }
  .page-head > .btn, .page-head > button { width: 100%; }
  .agent-grid, .form-grid.two, .check-grid, .user-checks { grid-template-columns: 1fr; }
  .agent-card { min-height: 285px; }
  .kpi-grid { gap: 8px; }
  .kpi { min-height: 120px; padding: 14px; }
  .kpi strong { font-size: 24px; }
  .panel-body { padding: 14px; }
  .upload-box { align-items: flex-start; flex-wrap: wrap; }
  .upload-box input { width: 100%; max-width: none; margin: 4px 0 0; }
  .form-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .auth-body { padding: 12px; }
  .auth-card { padding: 25px 20px; }
  .auth-card h1 { font-size: 27px; }
  .modal-body.form-grid { grid-template-columns: 1fr; }
  .truncate-cell { max-width: 220px; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

