/* ── MiniCRM Global Styles ── */
:root {
  --primary:    #6c5ce7;
  --primary-lt: #f0eeff;
  --sidebar-bg: #1e1f2e;
  --sidebar-w:  220px;
  --header-h:   56px;
  --text:       #2d2d3a;
  --muted:      #8a8a9a;
  --border:     #e8e8f0;
  --surface:    #ffffff;
  --bg:         #f4f5fb;
  --danger:     #e74c3c;
  --success:    #27ae60;
  --warning:    #f39c12;
  --info:       #2980b9;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: inherit; text-decoration: none; }

/* ── Sidebar ── */
.sidebar {
  position: fixed; top: 0; left: 0; height: 100vh;
  width: var(--sidebar-w); background: var(--sidebar-bg);
  display: flex; flex-direction: column; z-index: 100;
}
.sidebar-logo {
  height: var(--header-h); padding: 0 20px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo span { font-size: 18px; font-weight: 700; color: #fff; letter-spacing: -.3px; }
.sidebar-logo .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: rgba(255,255,255,.65);
  font-size: 13.5px; font-weight: 500; border-radius: 0;
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-nav a.active { background: rgba(108,92,231,.25); color: #fff; border-left: 3px solid var(--primary); }
.sidebar-nav a svg { opacity: .75; flex-shrink: 0; }
.sidebar-nav a.active svg { opacity: 1; }
.sidebar-section { padding: 14px 20px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: rgba(255,255,255,.3); }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-info .name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info .role { font-size: 11px; color: rgba(255,255,255,.45); }
.logout-btn { font-size: 11px; color: rgba(255,255,255,.45); margin-top: 8px; display: inline-block; }
.logout-btn:hover { color: var(--danger); }

/* ── Main layout ── */
.main-wrap { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: var(--header-h); background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 28px;
  position: sticky; top: 0; z-index: 90;
  gap: 16px;
}
.topbar h1 { font-size: 17px; font-weight: 700; flex: 1; }
.page-content { flex: 1; padding: 28px; }

/* ── Cards ── */
.card { background: var(--surface); border-radius: 10px; border: 1px solid var(--border); }
.card-body { padding: 20px 24px; }
.card-header-bar { padding: 16px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header-bar h2 { font-size: 15px; font-weight: 700; }

/* ── Stat cards ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border-radius: 10px; border: 1px solid var(--border); padding: 20px 22px; display: flex; align-items: center; gap: 16px; }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon.purple { background: var(--primary-lt); color: var(--primary); }
.stat-icon.blue   { background: #e8f4fd; color: #2980b9; }
.stat-icon.green  { background: #eafaf1; color: #27ae60; }
.stat-icon.orange { background: #fef9e7; color: #f39c12; }
.stat-val { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap; background: #fafafa;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #fafbff; }
tbody td { padding: 12px 14px; vertical-align: middle; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge-active      { background: #e8faf3; color: #1a9e5c; }
.badge-not-started { background: #fef9e7; color: #d68910; }
.badge-on-hold     { background: #f0f0f0; color: #7a7a8a; }
.badge-completed   { background: #e8f8f0; color: #1e8449; }
.badge-in-progress { background: #e8f4fd; color: #1a6eb5; }
.badge-waiting     { background: #f4f4f4; color: #7a7a8a; }
.badge-ongoing     { background: #fff3e0; color: #e65100; }
.badge-overdue     { background: #fdecea; color: #c0392b; }
.badge-high        { background: #fdecea; color: #c0392b; }
.badge-medium      { background: #fff8e1; color: #d68910; }
.badge-low         { background: #e8f8f0; color: #1e8449; }
.badge-design      { background: #f3e5f5; color: #7b1fa2; }
.badge-development { background: #e3f2fd; color: #1565c0; }
.badge-marketing   { background: #fff3e0; color: #e65100; }
.badge-support     { background: #e8f5e9; color: #2e7d32; }
.badge-training    { background: #fce4ec; color: #880e4f; }

/* ── Priority dot ── */
.priority-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.priority-dot.high   { background: #e74c3c; }
.priority-dot.medium { background: #f39c12; }
.priority-dot.low    { background: #27ae60; }

/* ── Avatar ── */
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 11px; font-weight: 700; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.avatar-lg { width: 38px; height: 38px; font-size: 14px; }
.av-purple { background: #6c5ce7; }
.av-blue   { background: #0984e3; }
.av-green  { background: #00b894; }
.av-orange { background: #e17055; }
.av-pink   { background: #fd79a8; }
.av-teal   { background: #00cec9; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 7px; font-size: 13.5px;
  font-weight: 600; cursor: pointer; border: none;
  transition: opacity .15s, box-shadow .15s;
}
.btn:hover { opacity: .88; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-outline  { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-sm       { padding: 5px 12px; font-size: 12.5px; border-radius: 6px; }
.btn-icon     { padding: 6px; border-radius: 6px; background: transparent; border: none; cursor: pointer; color: var(--muted); transition: background .15s, color .15s; }
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* ── Filters bar ── */
.filters-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.filters-bar input, .filters-bar select {
  padding: 7px 12px; border: 1.5px solid var(--border); border-radius: 7px;
  font-size: 13.5px; background: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s;
}
.filters-bar input:focus, .filters-bar select:focus { border-color: var(--primary); }
.search-box { position: relative; }
.search-box input { padding-left: 32px; min-width: 220px; }
.search-box svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); }

/* ── Form ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 12.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.form-group input, .form-group select, .form-group textarea {
  padding: 9px 13px; border: 1.5px solid var(--border); border-radius: 7px;
  font-size: 14px; color: var(--text); outline: none; background: var(--surface);
  transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }
.form-group textarea { resize: vertical; min-height: 90px; }
.checkboxes { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-pill { display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px; border-radius: 20px; border: 1.5px solid var(--border); font-size: 13px; cursor: pointer; transition: all .15s; }
.checkbox-pill input { display: none; }
.checkbox-pill:has(input:checked) { background: var(--primary-lt); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 500; margin-bottom: 18px; }
.alert-success { background: #eafaf1; color: #1e8449; border: 1px solid #a9dfbf; }
.alert-error   { background: #fdecea; color: #c0392b; border: 1px solid #f5b7b1; }
.alert ul      { margin: 0; padding-left: 18px; }

/* ── Progress bar ── */
.progress-wrap { background: #eee; border-radius: 20px; height: 7px; overflow: hidden; min-width: 80px; }
.progress-bar { height: 100%; border-radius: 20px; background: var(--primary); transition: width .4s; }
.progress-bar.green  { background: #27ae60; }
.progress-bar.orange { background: #f39c12; }
.progress-bar.red    { background: #e74c3c; }

/* ── Detail page ── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-item label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; display: block; margin-bottom: 3px; }
.detail-item span { font-size: 14px; }

/* ── Subtask table ── */
.subitem-row td { font-size: 13px; padding: 9px 14px; }
.subitem-check { width: 16px; height: 16px; accent-color: var(--primary); }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state svg { margin-bottom: 14px; opacity: .35; }
.empty-state p { font-size: 15px; }

/* ── Health dot ── */
.health-dot { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; }
.health-dot::before { content: ''; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.health-completed::before   { background: #27ae60; }
.health-on-track::before    { background: #2980b9; }
.health-delayed::before     { background: #e74c3c; }
.health-ongoing::before     { background: #f39c12; }

/* ── Login page ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e1f2e 0%, #2d3063 100%); }
.login-box { background: #fff; border-radius: 14px; padding: 42px 40px; width: 100%; max-width: 400px; }
.login-box .logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.login-box .logo-row span { font-size: 22px; font-weight: 800; color: var(--text); }
.login-box h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.login-box p  { font-size: 13.5px; color: var(--muted); margin-bottom: 24px; }
.login-box .form-group label { color: var(--muted); }
.login-box .form-group + .form-group { margin-top: 14px; }
.login-box .btn { width: 100%; justify-content: center; margin-top: 20px; padding: 11px; font-size: 15px; }

/* ── Breadcrumb ── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 16px; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb span { color: var(--text); font-weight: 600; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-wrap { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ══════════════════════════════════════════════════════════════
   Task Execution Table  (te-*)
   ══════════════════════════════════════════════════════════════ */

.te-card { overflow: visible; }

/* Main table */
.te-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.te-head th {
  background: #fafafa; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap; text-align: left;
}

/* Column widths */
.te-col-toggle   { width: 36px; }
.te-col-name     { width: 220px; }
.te-col-project  { width: 160px; }
.te-col-client   { width: 130px; }
.te-col-sub      { width: 110px; }
.te-col-status   { width: 110px; }
.te-col-priority { width: 90px; }
.te-col-due      { width: 80px; }
.te-col-comp     { width: 80px; }
.te-col-actions  { width: 64px; }

/* Group header row */
.te-group-header td {
  background: #fafbff; padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; /* NOT a flex row — see below */ 
}
.te-group-header > td {
  display: table-cell;
  vertical-align: middle;
}
.te-group-header {
  cursor: default;
}
.te-group-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 0 6px 0 0;
  transition: transform .2s; display: inline-flex; align-items: center;
  vertical-align: middle;
}
.te-group-toggle.collapsed svg { transform: rotate(-90deg); }
.te-group-toggle svg { transition: transform .2s; }
.te-group-count {
  display: inline-flex; align-items: center; justify-content: center;
  background: #e8e8f0; color: var(--muted); border-radius: 10px;
  font-size: 11px; font-weight: 700; padding: 1px 8px; margin-left: 8px;
}

/* Task rows */
.te-task-row td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.te-task-row:hover td { background: #fafbff; }
.te-task-toggle {
  background: none; border: none; cursor: pointer; padding: 3px;
  color: var(--muted); border-radius: 4px; display: inline-flex;
  align-items: center; transition: background .15s, color .15s;
}
.te-task-toggle:hover { background: var(--primary-lt); color: var(--primary); }
.te-arrow { transition: transform .2s; }
.te-task-toggle.open .te-arrow { transform: rotate(90deg); }

.te-task-name {
  font-weight: 600; color: var(--text); font-size: 13.5px;
  transition: color .15s;
}
.te-task-name:hover { color: var(--primary); }
.te-subcount {
  display: inline-flex; align-items: center; justify-content: center;
  background: #e8e8f0; color: var(--muted);
  border-radius: 10px; font-size: 10px; font-weight: 700;
  padding: 1px 6px; margin-left: 6px;
}
.te-link { color: var(--muted); font-size: 12.5px; }
.te-link:hover { color: var(--primary); }
.te-muted { color: var(--muted); font-size: 12px; }
.te-overdue { color: #e74c3c !important; font-weight: 600; font-size: 12px; }
.te-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.te-task-row:hover .te-actions { opacity: 1; }

/* Substatus color bar */
.substatus-bar {
  display: inline-block; padding: 3px 10px; border-radius: 4px;
  font-size: 11.5px; font-weight: 600; color: #fff;
  white-space: nowrap;
}

/* Subitem section wrapper */
.te-sub-section td { padding: 0 !important; border-bottom: 1px solid var(--border); }
.te-sub-wrap { background: #f8f9fe; border-top: 1px solid var(--border); }

/* Subitem table */
.te-sub-table { width: 100%; border-collapse: collapse; }
.te-sub-head th {
  background: #f0f1f8; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px; color: #8a90b0;
  padding: 7px 14px 7px 14px; border-bottom: 1px solid #e0e2f0;
  white-space: nowrap; text-align: left;
}
.te-sub-head th:first-child { width: 36px; padding: 7px 8px; text-align: center; }

/* Subitem data rows */
.te-sub-row td {
  padding: 9px 14px; border-bottom: 1px solid #eaedf5;
  font-size: 13px; vertical-align: middle;
}
.te-sub-row td:first-child { padding: 9px 8px; width: 36px; text-align: center; }
.te-sub-row:hover td { background: #f0f2fc; }
.te-sub-done .te-sub-name { text-decoration: line-through; color: var(--muted); }
.te-sub-empty {
  padding: 14px 16px !important; color: var(--muted);
  font-size: 13px; font-style: italic;
}

/* Add subitem row */
.te-add-row td { padding: 8px 14px 10px 16px !important; border-bottom: none; }
.te-add-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px; border-radius: 6px; transition: background .15s, color .15s;
}
.te-add-btn:hover { background: var(--primary-lt); color: var(--primary); }
.te-add-form-row td { padding: 0 0 12px 0 !important; border-bottom: none; }

/* Inline add form */
.te-inline-form { background: #fff; border: 1.5px solid var(--primary); border-radius: 8px; padding: 12px 16px; margin: 0 10px; }
.te-form-grid { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.te-form-cell { flex: 1; min-width: 100px; }
.te-form-cell.te-assignee-cell { min-width: 160px; flex: 1.5; }
.te-input {
  width: 100%; padding: 7px 10px; border: 1.5px solid var(--border);
  border-radius: 6px; font-size: 13px; background: #fff;
  outline: none; transition: border-color .15s;
}
.te-input:focus { border-color: var(--primary); }

/* Multi-select dropdown */
.te-multi-select { position: relative; }
.te-ms-trigger {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px; border: 1.5px solid var(--border); border-radius: 6px;
  font-size: 13px; cursor: pointer; background: #fff; gap: 6px;
  transition: border-color .15s;
}
.te-ms-trigger:hover { border-color: var(--primary); }
.te-ms-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.te-ms-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border: 1.5px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.1); z-index: 200; overflow: hidden;
}
.te-ms-option {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  cursor: pointer; font-size: 13px; transition: background .1s;
}
.te-ms-option:hover { background: var(--primary-lt); }
.te-ms-option input[type=checkbox] { accent-color: var(--primary); width: 14px; height: 14px; flex-shrink: 0; }

/* ── Assignee tooltip ────────────────────────────────────────── */
.te-assignee-wrap {
  position: relative; display: inline-flex; align-items: center; gap: 3px;
}
.te-assignee-wrap::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%; transform: translateX(-50%);
  background: #1e1f2e; color: #fff;
  font-size: 12px; font-weight: 500;
  padding: 5px 10px; border-radius: 6px;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .15s;
  z-index: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
}
.te-assignee-wrap::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 1px);
  left: 50%; transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1e1f2e;
  pointer-events: none;
  opacity: 0; transition: opacity .15s;
  z-index: 500;
}
.te-assignee-wrap:hover::after,
.te-assignee-wrap:hover::before { opacity: 1; }
.te-assignee-extra {
  font-size: 11px; background: #e8e8f0; border-radius: 10px;
  padding: 2px 7px; font-weight: 600; color: var(--muted);
}

/* ── Inline edit form ────────────────────────────────────────── */
.te-edit-form { border-color: #f39c12; background: #fffdf5; }
.te-edit-form-row td { background: transparent; }
.te-form-label {
  display: block; font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); margin-bottom: 4px;
}

