/* ===================================================================
   COSMEX WORK · Design System v2 · 2026-05-19
   Подключается во все страницы work-task системы.
   =================================================================== */

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

/* ─── Tokens ─── */
:root {
  --cx-bg:        #fafaf7;
  --cx-surface:   #ffffff;
  --cx-border:    #ece7df;
  --cx-border-2:  #d8d1c4;
  --cx-text:      #1c1917;
  --cx-text-2:    #44403c;
  --cx-muted:     #78716c;
  --cx-accent:    #c66a14;
  --cx-accent-d:  #8a4a0a;
  --cx-accent-l:  #fef3e6;

  --cx-new:       #475569;
  --cx-prog:      #c66a14;
  --cx-wait:      #1e40af;
  --cx-done:      #15803d;
  --cx-over:      #b91c1c;

  --cx-new-bg:    #f1f5f9;
  --cx-prog-bg:   #fef3e6;
  --cx-wait-bg:   #eff6ff;
  --cx-done-bg:   #f0fdf4;
  --cx-over-bg:   #fef2f2;

  --shadow-sm:    0 1px 2px rgba(28,25,23,.06);
  --shadow-md:    0 2px 8px rgba(28,25,23,.06),0 1px 3px rgba(28,25,23,.04);
  --shadow-lg:    0 8px 24px rgba(28,25,23,.08),0 2px 6px rgba(28,25,23,.04);

  /* legacy compat — старые шаблоны используют эти имена */
  --bg:           var(--cx-bg);
  --card:         var(--cx-surface);
  --border:       var(--cx-border);
  --accent:       var(--cx-accent);
  --accent-dark:  var(--cx-accent-d);
  --accent-soft:  var(--cx-accent-l);
  --text:         var(--cx-text);
  --muted:        var(--cx-muted);
  --ok:           var(--cx-done);
  --warn:         #f59e0b;
  --err:          var(--cx-over);

  --col-new:      var(--cx-new);
  --col-prog:     var(--cx-prog);
  --col-wait:     var(--cx-wait);
  --col-done:     var(--cx-done);
  --col-over:     var(--cx-over);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Manrope', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--cx-bg);
  color: var(--cx-text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
button { font-family: inherit; }

/* ─── Top navigation (общий) ─── */
.cx-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--cx-border);
  background: var(--cx-surface);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 12px;
}
.cx-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 16px;
  text-decoration: none;
  color: var(--cx-text);
  letter-spacing: -0.01em;
}
.cx-brand-mark {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, #f59e0b 0%, var(--cx-accent) 50%, var(--cx-accent-d) 100%);
  display: grid; place-items: center;
  color: white; font-weight: 800; font-size: 14px;
  box-shadow: 0 4px 12px -2px rgba(198,106,20,.4);
  flex-shrink: 0;
}
.cx-brand-sub { color: var(--cx-muted); font-weight: 500; font-size: 13px; }
.cx-top-nav {
  display: none;
  gap: 2px;
  background: var(--cx-bg);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--cx-border);
}
.cx-tnav-item {
  padding: 8px 14px;
  border-radius: 7px;
  color: var(--cx-text-2);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  transition: all 0.15s;
  display: flex; align-items: center; gap: 6px;
  cursor: pointer;
  background: transparent;
  border: 0;
  font-family: inherit;
}
.cx-tnav-item:hover { background: var(--cx-surface); color: var(--cx-text); }
.cx-tnav-item.active { background: var(--cx-text); color: white; }
@media (min-width: 768px) { .cx-top-nav { display: flex; } }

.cx-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  background: var(--cx-bg);
  border: 1px solid var(--cx-border);
  border-radius: 999px;
  color: var(--cx-text);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.cx-user-chip:hover { border-color: var(--cx-border-2); }
.cx-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f97316, var(--cx-accent));
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.cx-user-name { font-weight: 600; font-size: 13px; display: none; }
@media (min-width: 480px) { .cx-user-name { display: inline; } }

/* ─── Bottom nav (mobile only) ─── */
.cx-bottombar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255,255,255,0.96);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--cx-border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  z-index: 100;
}
.cx-bnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border-radius: 8px;
  color: var(--cx-muted);
  font-size: 10.5px;
  font-weight: 600;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: all 0.15s;
}
.cx-bnav-item.active { color: var(--cx-accent); background: var(--cx-accent-l); }
.cx-bnav-icon { font-size: 19px; line-height: 1; }
@media (min-width: 768px) { .cx-bottombar { display: none; } }
body.cx-has-bottom { padding-bottom: 76px; }
@media (min-width: 768px) { body.cx-has-bottom { padding-bottom: 0; } }

/* ─── More drawer (modal sheet) ─── */
.cx-drawer-bg {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.4);
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.cx-drawer-bg.show { display: flex; animation: cx-fade-in 0.2s; }
@keyframes cx-fade-in { from { opacity: 0 } to { opacity: 1 } }
.cx-drawer {
  background: var(--cx-surface);
  width: 100%; max-width: 480px;
  border-radius: 18px 18px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 80vh; overflow-y: auto;
  animation: cx-slide-up 0.25s;
}
@keyframes cx-slide-up { from { transform: translateY(100%) } to { transform: translateY(0) } }
.cx-drawer-handle {
  width: 40px; height: 4px;
  background: var(--cx-border-2);
  border-radius: 999px;
  margin: 0 auto 16px;
}
.cx-drawer-title {
  font-weight: 700; font-size: 16px;
  margin: 0 0 14px;
}
.cx-drawer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.cx-drawer-item {
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  padding: 14px 8px;
  background: var(--cx-bg);
  border: 1px solid var(--cx-border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--cx-text);
  font-size: 12px; font-weight: 600;
  text-align: center;
}
.cx-drawer-item:hover { background: var(--cx-accent-l); border-color: var(--cx-accent); }
.cx-drawer-item-ic { font-size: 24px; line-height: 1; }

/* ─── Buttons ─── */
.cx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--cx-border);
  background: var(--cx-surface);
  color: var(--cx-text);
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.cx-btn:hover { background: var(--cx-bg); border-color: var(--cx-border-2); }
.cx-btn.primary {
  background: var(--cx-text);
  color: white;
  border-color: var(--cx-text);
}
.cx-btn.primary:hover { background: var(--cx-accent); border-color: var(--cx-accent); }
.cx-btn.accent {
  background: var(--cx-accent);
  color: white;
  border-color: var(--cx-accent);
}
.cx-btn.accent:hover { background: var(--cx-accent-d); border-color: var(--cx-accent-d); }
.cx-btn.danger { color: var(--cx-over); border-color: #fecaca; }
.cx-btn.ghost { background: transparent; border-color: transparent; color: var(--cx-text-2); }
.cx-btn.sm { padding: 6px 10px; font-size: 12.5px; }
.cx-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* FAB (mobile) */
.cx-fab {
  position: fixed;
  bottom: 86px; right: 16px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--cx-accent);
  color: white;
  border: 0;
  box-shadow: 0 8px 24px -2px rgba(198,106,20,.5), 0 0 0 4px rgba(198,106,20,.1);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 26px;
  z-index: 50;
  transition: transform 0.2s;
}
.cx-fab:hover { transform: scale(1.06); }
@media (min-width: 768px) { .cx-fab { display: none; } }

/* ─── Empty states ─── */
.cx-empty {
  text-align: center;
  padding: 60px 24px;
  background: var(--cx-surface);
  border: 1px dashed var(--cx-border-2);
  border-radius: 14px;
}
.cx-empty-icon { font-size: 48px; line-height: 1; margin-bottom: 16px; opacity: 0.5; }
.cx-empty-title { font-weight: 700; font-size: 18px; margin: 0 0 8px; color: var(--cx-text); }
.cx-empty-sub {
  color: var(--cx-muted); font-size: 14px; line-height: 1.5;
  max-width: 420px; margin: 0 auto 20px;
}
.cx-empty .cx-btn { margin-top: 0; }

/* ─── Status badges & pills ─── */
.cx-badge {
  display: inline-flex; align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.4;
}

.cx-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px;
           background: var(--cx-bg); font-size: 12px; font-weight: 600; color: var(--cx-text-2);
           font-feature-settings: "tnum"; }
.cx-pill.urgent { background: var(--cx-over-bg); color: var(--cx-over); }
.cx-pill.warn   { background: #fef3c7; color: #92400e; }
.cx-pill.ok     { background: var(--cx-done-bg); color: var(--cx-done); }
.cx-pill.info   { background: var(--cx-wait-bg); color: var(--cx-wait); }

/* ─── Cards ─── */
.cx-card {
  background: var(--cx-surface);
  border: 1px solid var(--cx-border);
  border-radius: 12px;
  padding: 16px;
}

/* ─── Compact mobile padding ─── */
.cx-container { max-width: 1280px; margin: 0 auto; padding: 16px; }
@media (min-width: 1024px) { .cx-container { padding: 24px 32px; } }

/* ─── Section title ─── */
.cx-section-hdr {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px; gap: 12px;
}
.cx-section-title {
  font-size: 17px; font-weight: 700; letter-spacing: -0.01em;
  margin: 0; display: inline-flex; align-items: baseline; gap: 8px;
}
.cx-section-title .count { color: var(--cx-muted); font-weight: 600; font-size: 13px; font-feature-settings: "tnum"; }
.cx-section-link { color: var(--cx-muted); font-size: 13px; font-weight: 600; text-decoration: none; }
.cx-section-link:hover { color: var(--cx-accent); }
