:root{
  --bg:#f4f5f2;
  --surface:#ffffff;
  --surface-soft:#f8faf7;
  --sidebar:#17271c;
  --sidebar-2:#203428;
  --text:#17231b;
  --muted:#6d776f;
  --line:#e5e9e3;
  --green:#3f6b4d;
  --green-dark:#2f543b;
  --green-soft:#eaf3ec;
  --amber:#a87025;
  --amber-soft:#fff5e7;
  --red:#a94f48;
  --red-soft:#fff0ee;
  --shadow:0 10px 30px rgba(25,45,31,.07);
  --shadow-sm:0 4px 16px rgba(25,45,31,.055);
  --radius:18px;
}

*{box-sizing:border-box}
html,body{margin:0;min-height:100%;font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;background:var(--bg);color:var(--text)}
body{min-height:100vh}
a{color:inherit;text-decoration:none}
button,input,textarea,select{font:inherit}

.app-shell{min-height:100vh;display:grid;grid-template-columns:260px 1fr}
.sidebar{position:sticky;top:0;height:100vh;background:linear-gradient(180deg,var(--sidebar) 0%,#142219 100%);padding:26px 18px 20px;color:#ecf2ed;display:flex;flex-direction:column}
.brand-block{display:flex;align-items:center;gap:12px;padding:4px 10px 24px}
.brand-mark{width:42px;height:42px;border-radius:13px;display:grid;place-items:center;background:linear-gradient(145deg,#6f9479,#3d6248);font-weight:800;font-size:18px;box-shadow:inset 0 0 0 1px rgba(255,255,255,.12)}
.brand-name{font-weight:800;font-size:18px;letter-spacing:-.02em}
.brand-subtitle{font-size:12px;color:#aebdaf;margin-top:2px}

.side-nav{display:grid;gap:6px}
.side-nav a{display:flex;align-items:center;gap:11px;padding:11px 12px;border-radius:12px;color:#cfd9d1;font-size:14px;font-weight:600;transition:.18s ease}
.side-nav a:hover{background:rgba(255,255,255,.06);color:#fff}
.side-nav a.active{background:#2b4634;color:#fff;box-shadow:inset 0 0 0 1px rgba(255,255,255,.05)}
.nav-icon{width:24px;height:24px;border-radius:8px;display:grid;place-items:center;background:rgba(255,255,255,.06);font-size:14px}

.sidebar-status{margin-top:auto;padding:18px 10px 14px;border-top:1px solid rgba(255,255,255,.08)}
.status-row{display:flex;align-items:center;gap:8px;color:#b8c5bb;font-size:12px}
.status-dot{width:8px;height:8px;border-radius:50%;background:#8a958c}
.status-dot.online{background:#62bd76;box-shadow:0 0 0 4px rgba(98,189,118,.12)}
.status-dot.offline{background:#d7a95a}

.sidebar-user{display:flex;align-items:center;gap:10px;padding:12px 10px;background:rgba(255,255,255,.045);border-radius:14px}
.user-avatar{width:34px;height:34px;border-radius:50%;display:grid;place-items:center;background:#dce9df;color:#26452f;font-weight:800}
.user-meta{min-width:0;display:grid;gap:3px}
.user-email{max-width:145px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:#b7c4ba}
.user-meta a{font-size:12px;color:#fff;font-weight:700}

.main-wrap{min-width:0;display:flex;flex-direction:column;min-height:100vh}
.top-header{height:96px;padding:22px 34px 18px;border-bottom:1px solid var(--line);background:rgba(244,245,242,.88);backdrop-filter:blur(10px);display:flex;align-items:flex-end;justify-content:space-between;gap:18px;position:sticky;top:0;z-index:20}
.eyebrow{font-size:10px;letter-spacing:.18em;font-weight:800;color:#8b948d;margin-bottom:5px}
.top-header h1{margin:0;font-size:24px;letter-spacing:-.025em}
.top-actions{display:flex;align-items:center;gap:10px}
.connection-pill{display:inline-flex;align-items:center;gap:8px;padding:8px 11px;border-radius:999px;font-size:12px;font-weight:700}
.connection-pill.ok{background:var(--green-soft);color:#356140}
.connection-pill.warn{background:var(--amber-soft);color:#8d6328}
.pill-dot{width:8px;height:8px;border-radius:50%;background:currentColor}

.page-content{padding:30px 34px 38px;max-width:1500px;width:100%;margin:0 auto}
.app-footer{margin-top:auto;padding:16px 34px 24px;display:flex;justify-content:space-between;color:#9aa39c;font-size:11px}

.hero-row{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:24px}
.hero-row.compact{align-items:flex-start}
.hero-row h2{margin:0 0 6px;font-size:26px;letter-spacing:-.035em}
.hero-row p{margin:0;color:var(--muted);font-size:14px}
.back-link{display:inline-block;margin-bottom:10px;color:#55735f;font-size:13px;font-weight:700}

.btn{border:0;border-radius:12px;padding:11px 15px;font-weight:750;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;transition:.18s ease}
.btn-primary{background:var(--green);color:#fff;box-shadow:0 5px 14px rgba(63,107,77,.18)}
.btn-primary:hover{background:var(--green-dark);transform:translateY(-1px)}
.btn-secondary{background:#edf0ec;color:#314037}
.btn-secondary:hover{background:#e3e8e2}

.metric-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px;margin-bottom:24px}
.metric-card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);padding:20px;display:flex;align-items:center;gap:14px;box-shadow:var(--shadow-sm)}
.metric-icon{width:44px;height:44px;border-radius:13px;background:var(--green-soft);display:grid;place-items:center;color:var(--green);font-weight:800}
.metric-card span{display:block;color:var(--muted);font-size:12px;font-weight:700;margin-bottom:4px}
.metric-card strong{display:block;font-size:25px;line-height:1.1;letter-spacing:-.03em}
.metric-card small{display:block;color:#9aa29c;margin-top:5px}

.panel-card{background:var(--surface);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);overflow:hidden}
.content-grid{display:grid;grid-template-columns:minmax(0,1.7fr) minmax(320px,.7fr);gap:18px}
.card-head{padding:20px 22px;border-bottom:1px solid var(--line);display:flex;justify-content:space-between;align-items:flex-start;gap:16px}
.card-head h3{margin:0 0 4px;font-size:16px}
.card-head p{margin:0;color:var(--muted);font-size:12px}
.text-link{font-size:12px;font-weight:750;color:var(--green)}

.activity-list{display:grid}
.activity-item{display:grid;grid-template-columns:12px minmax(0,1fr) auto;gap:12px;align-items:center;padding:15px 22px;border-bottom:1px solid var(--line)}
.activity-item:last-child{border-bottom:0}
.activity-dot{width:8px;height:8px;border-radius:50%;background:#b9c0bb}
.activity-dot.done{background:#60ac72}
.activity-dot.error{background:#c76b63}
.activity-copy{min-width:0;display:grid;gap:3px}
.activity-copy strong{font-size:13px}
.activity-copy span{font-size:12px;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.activity-meta{text-align:right;display:grid;gap:3px}
.activity-meta span{font-size:11px;font-weight:700;color:#506359}
.activity-meta small{font-size:10px;color:#9da49f}

.quick-card{padding-bottom:8px}
.quick-action{display:grid;grid-template-columns:38px minmax(0,1fr) 12px;gap:12px;align-items:center;padding:14px 20px;border-bottom:1px solid var(--line);transition:.16s ease}
.quick-action:last-child{border-bottom:0}
.quick-action:hover{background:var(--surface-soft)}
.quick-icon{width:36px;height:36px;border-radius:11px;background:#edf4ef;color:#456b50;display:grid;place-items:center;font-weight:800}
.quick-action div{display:grid;gap:2px}
.quick-action strong{font-size:13px}
.quick-action small{font-size:11px;color:var(--muted)}

.empty-state{text-align:center;padding:44px 20px;color:var(--muted)}
.empty-state.large{padding:70px 20px}
.empty-icon{width:52px;height:52px;border-radius:16px;background:var(--green-soft);color:var(--green);display:grid;place-items:center;margin:0 auto 14px;font-size:22px}
.empty-state strong{display:block;color:var(--text);margin-bottom:6px}
.empty-state p{margin:0 0 18px;font-size:13px}

.table-shell{overflow:hidden}
.table-toolbar{padding:16px 20px;border-bottom:1px solid var(--line);display:flex;justify-content:space-between}
.table-toolbar strong{font-size:13px}
.table-toolbar span{font-size:12px;color:var(--muted);margin-left:4px}
.responsive-table{overflow-x:auto}
.pro-table{width:100%;border-collapse:collapse}
.pro-table th{padding:12px 18px;background:#fafbfa;border-bottom:1px solid var(--line);font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:#7f8981;text-align:left}
.pro-table td{padding:16px 18px;border-bottom:1px solid var(--line);font-size:13px;vertical-align:middle}
.pro-table tbody tr:hover{background:#fbfcfb}
.pro-table tbody tr:last-child td{border-bottom:0}
.align-right{text-align:right!important}
.campaign-cell{display:flex;align-items:center;gap:11px;min-width:220px}
.campaign-icon{width:34px;height:34px;border-radius:10px;background:var(--green-soft);color:var(--green);display:grid;place-items:center;font-weight:800}
.campaign-cell div:last-child{display:grid;gap:3px}
.campaign-cell strong{font-size:13px}
.campaign-cell small{font-size:11px;color:var(--muted)}
.keyword-chip{display:inline-flex;align-items:center;padding:6px 9px;border-radius:999px;background:#edf4ef;color:#416049;font-size:11px;font-weight:800}
.keyword-chip.neutral{background:#f0f2f0;color:#677169}
.soft-text{color:var(--muted);font-size:12px}
.status-badge{display:inline-flex;align-items:center;gap:7px;padding:6px 9px;border-radius:999px;font-size:11px;font-weight:800}
.status-badge span{width:7px;height:7px;border-radius:50%;background:currentColor}
.status-badge.active{background:var(--green-soft);color:#3d7849}
.status-badge.paused{background:#f1f2f0;color:#778078}
.status-badge.error{background:var(--red-soft);color:var(--red)}
.action-group{display:flex;justify-content:flex-end;gap:5px;align-items:center}
.action-group form{display:flex;gap:5px}
.action-btn{border:1px solid transparent;background:transparent;border-radius:8px;padding:7px 8px;font-size:11px;color:#53655a;cursor:pointer;font-weight:700}
.action-btn:hover{background:#f0f3f0}
.action-btn.danger{color:var(--red)}
.delivery-badges{display:flex;gap:5px;flex-wrap:wrap}
.delivery-badges span{padding:5px 7px;border-radius:7px;font-size:10px;font-weight:750}
.delivery-badges .ok{background:var(--green-soft);color:#3c7547}
.muted-badge{background:#f0f1ef;color:#8b938c}
.comment-preview{display:block;max-width:320px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.error-mini{max-width:260px;margin-top:5px;font-size:10px;color:var(--red);line-height:1.35}

.form-shell{padding:0}
.pro-form{display:grid}
.form-section{padding:22px 24px;border-bottom:1px solid var(--line)}
.form-section-title{display:flex;align-items:flex-start;gap:12px;margin-bottom:18px}
.form-section-title>span{width:26px;height:26px;border-radius:8px;background:var(--green-soft);display:grid;place-items:center;font-size:11px;font-weight:800;color:var(--green)}
.form-section-title>div{display:grid;gap:3px}
.form-section-title strong{font-size:14px}
.form-section-title small{font-size:11px;color:var(--muted)}

label{display:block;font-size:12px;font-weight:750;color:#38463d;margin:14px 0 0}
input,textarea,select{width:100%;margin-top:7px;padding:12px 13px;border:1px solid #dfe4df;border-radius:11px;background:#fff;color:var(--text);outline:none;transition:.16s ease}
input:focus,textarea:focus,select:focus{border-color:#7fa087;box-shadow:0 0 0 4px rgba(63,107,77,.08)}
textarea{resize:vertical}
.hint{display:block;margin-top:6px;font-size:10px;color:#8f9891;font-weight:500}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:14px}
.switch-row{display:flex;align-items:center;gap:11px;padding:14px;border:1px solid var(--line);border-radius:13px;background:#fafbfa;cursor:pointer}
.switch-row input{display:none}
.switch-ui{width:38px;height:22px;border-radius:999px;background:#cfd5d0;position:relative;transition:.18s}
.switch-ui:after{content:"";position:absolute;top:3px;left:3px;width:16px;height:16px;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.14);transition:.18s}
.switch-row input:checked + .switch-ui{background:var(--green)}
.switch-row input:checked + .switch-ui:after{left:19px}
.switch-row>span:last-child{display:grid;gap:2px}
.switch-row strong{font-size:12px}
.switch-row small{font-size:10px;color:var(--muted)}
.sticky-actions{padding:16px 24px;display:flex;justify-content:flex-end;gap:9px;background:#fbfcfb}

.settings-grid{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(320px,.55fr);gap:18px}
.info-card{padding:22px}
.info-icon{width:44px;height:44px;border-radius:14px;background:var(--green-soft);color:var(--green);display:grid;place-items:center;font-size:18px;margin-bottom:15px}
.info-card h3{margin:0 0 5px}
.info-card>p{margin:0 0 16px;color:var(--muted);font-size:12px}
.info-note{margin-top:18px;padding:12px;border-radius:12px;background:#f6f8f5;display:grid;gap:3px}
.info-note strong{font-size:11px}
.info-note span{font-size:10px;color:var(--muted)}

.success,.error{margin:18px 24px 0;padding:11px 13px;border-radius:11px;font-size:12px;font-weight:650}
.success{background:var(--green-soft);color:#376842}
.error{background:var(--red-soft);color:#8d4540}

@media(max-width:1150px){
  .metric-grid{grid-template-columns:repeat(2,1fr)}
  .content-grid,.settings-grid{grid-template-columns:1fr}
}
@media(max-width:860px){
  .app-shell{grid-template-columns:1fr}
  .sidebar{position:relative;height:auto;padding:14px}
  .brand-block{padding:4px 4px 14px}
  .side-nav{grid-template-columns:repeat(4,1fr);gap:5px}
  .side-nav a{justify-content:center;padding:9px 6px}
  .side-nav a span:last-child{display:none}
  .sidebar-status,.sidebar-user{display:none}
  .top-header{position:relative;height:auto;padding:18px 20px}
  .page-content{padding:22px 18px 28px}
  .app-footer{padding:14px 18px}
  .hero-row{align-items:flex-start;flex-direction:column}
  .grid2{grid-template-columns:1fr}
}
@media(max-width:560px){
  .metric-grid{grid-template-columns:1fr}
  .top-actions{display:none}
  .hero-row h2{font-size:22px}
}
