:root {
    --bg: #0b1020;
    --panel: rgba(16, 22, 37, 0.86);
    --panel-strong: rgba(12, 18, 31, 0.96);
    --border: rgba(255, 255, 255, 0.08);
    --text: #edf3ff;
    --muted: #93a2c3;
    --primary: #77a8ff;
    --primary-strong: #5b8ef0;
    --danger: #ff7286;
    --success: #56c58b;
    --warning: #ffbf63;
    --radius: 22px;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
    --gap: 18px;
  }
  
  * {
    box-sizing: border-box;
  }
  
  html,
  body {
    margin: 0;
    height: 100%;
  }
  
  body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
      radial-gradient(circle at top left, rgba(86, 123, 255, 0.14), transparent 30%),
      radial-gradient(circle at top right, rgba(68, 211, 255, 0.09), transparent 20%),
      linear-gradient(180deg, #09101c, #0b1120 50%, #0a1020 100%);
    overflow: hidden;
  }
  
  button,
  input,
  textarea,
  select {
    font: inherit;
  }
  
  input,
  textarea,
  select {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border-radius: 14px;
    padding: 11px 12px;
    outline: none;
    transition: 0.18s ease;
  }
  
  input:focus,
  textarea:focus,
  select:focus {
    border-color: rgba(119, 168, 255, 0.8);
    box-shadow: 0 0 0 4px rgba(119, 168, 255, 0.12);
  }
  
  textarea {
    resize: vertical;
  }
  
  .app-shell {
    height: 100vh;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: var(--gap);
    padding: var(--gap);
  }
  
  .card {
    background: var(--panel);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
  }
  
  .sidebar {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    overflow: auto;
  }
  
  .main-panel {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: var(--gap);
    min-height: 0;
  }
  
  .topbar {
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
  }
  
  .topbar h2,
  .brand h1,
  .section-title-row h2 {
    margin: 0;
  }
  
  .muted {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
  }
  
  .brand {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  
  .brand-badge {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    font-weight: 800;
    background: linear-gradient(135deg, rgba(119, 168, 255, 0.3), rgba(86, 197, 139, 0.14));
    border: 1px solid rgba(255, 255, 255, 0.08);
  }
  
  .sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  
  .section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }
  
  .compact-row {
    margin-bottom: 8px;
  }
  
  .field {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  
  .field label {
    font-size: 0.88rem;
    color: #dce7ff;
  }
  
  .field-grid.two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  
  .field-grid.four {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }
  
  .stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  
  .stat-box {
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
  }
  
  .stat-box small {
    display: block;
    color: var(--muted);
    margin-bottom: 6px;
  }
  
  .stat-box strong {
    font-size: 1.3rem;
  }
  
  .primary-btn,
  .ghost-btn,
  .icon-btn,
  .action-btn,
  .status-btn {
    border: none;
    cursor: pointer;
    transition: 0.18s ease;
  }
  
  .primary-btn:hover,
  .ghost-btn:hover,
  .icon-btn:hover,
  .action-btn:hover,
  .status-btn:hover {
    transform: translateY(-1px);
  }
  
  .primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: white;
    padding: 11px 16px;
    border-radius: 14px;
    font-weight: 700;
  }
  
  .ghost-btn,
  .action-btn,
  .status-btn {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.06);
  }
  
  .small-btn {
    padding: 8px 10px;
    font-size: 0.9rem;
  }
  
  .icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    color: white;
  }
  
  .toggle-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  
  .toggle-pill {
    position: relative;
  }
  
  .toggle-pill input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }
  
  .toggle-pill span {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--muted);
    cursor: pointer;
  }
  
  .toggle-pill input:checked + span {
    color: white;
    border-color: rgba(119, 168, 255, 0.35);
    background: rgba(119, 168, 255, 0.18);
  }
  
  .tasks-wrapper {
    min-height: 0;
    padding: 14px;
    overflow: hidden;
  }
  
  .tasks-list {
    height: 100%;
    overflow: auto;
    display: grid;
    gap: 12px;
    padding-right: 4px;
  }
  
  .task-card {
    padding: 14px;
    border-radius: 20px;
    background: var(--panel-strong);
    border: 1px solid var(--border);
  }
  
  .task-head,
  .task-meta,
  .task-footer,
  .badges-row,
  .task-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  
  .task-head {
    justify-content: space-between;
    align-items: flex-start;
  }
  
  .task-title {
    margin: 0;
    font-size: 1rem;
  }
  
  .task-description,
  .task-notes,
  .empty-state {
    color: var(--muted);
  }
  
  .task-description {
    margin: 6px 0 0;
  }
  
  .task-meta {
    margin: 10px 0;
    color: var(--muted);
    font-size: 0.86rem;
  }
  
  .badge {
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
  }
  
  .badge.low { color: #97dcb4; }
  .badge.medium { color: #9fc2ff; }
  .badge.high { color: #ffd27e; }
  .badge.critical { color: #ff8b97; }
  
  .task-footer {
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
  }
  
  .checklist-list,
  .checklist-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  
  .checklist-input-row,
  .check-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
  }
  
  .check-item {
    grid-template-columns: auto 1fr;
    padding: 9px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
  }
  
  .empty-state {
    min-height: 100%;
    display: grid;
    place-items: center;
    text-align: center;
    border: 1px dashed rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.03);
    padding: 24px;
  }
  
  .modal {
    position: fixed;
    inset: 0;
    z-index: 40;
  }
  
  .modal.hidden {
    display: none;
  }
  
  .modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 8, 15, 0.6);
    backdrop-filter: blur(6px);
  }
  
  .modal-panel {
    position: relative;
    z-index: 1;
    width: min(900px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    margin: 16px auto;
    background: rgba(13, 18, 31, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
    display: grid;
    grid-template-rows: auto 1fr;
    overflow: hidden;
  }
  
  .modal-header {
    padding: 18px 20px 14px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }
  
  .modal-body {
    padding: 18px 20px 20px;
    overflow: auto;
  }
  
  .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
  }
  
  .hidden {
    display: none !important;
  }
  
  @media (max-width: 1080px) {
    .app-shell {
      grid-template-columns: 1fr;
      overflow: auto;
      height: 100vh;
    }
  
    body {
      overflow: auto;
    }
  
    .main-panel {
      min-height: 70vh;
    }
  }
  
  @media (max-width: 720px) {
    .field-grid.two,
    .field-grid.four,
    .stats-grid {
      grid-template-columns: 1fr;
    }
  
    .topbar,
    .task-head,
    .task-footer {
      flex-direction: column;
      align-items: stretch;
    }
  
    .modal-panel {
      width: calc(100vw - 16px);
      max-height: calc(100vh - 16px);
      margin: 8px auto;
    }
  }

  .inline-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
  }
  
  .compact-select {
    min-width: 180px;
    width: auto;
  }
  
  .template-mini-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .mini-template-pill {
    padding: 8px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: var(--muted);
    font-size: 0.84rem;
  }
  
  .empty-mini {
    color: var(--muted);
    font-size: 0.9rem;
  }
  
  .template-modal-panel {
    width: min(1150px, calc(100vw - 32px));
  }
  
  .template-modal-grid {
    display: grid;
    grid-template-columns: 420px minmax(0, 1fr);
    gap: 18px;
  }
  
  .template-form-panel,
  .template-list-panel {
    min-width: 0;
  }
  
  .template-list {
    display: grid;
    gap: 12px;
    max-height: 100%;
    overflow: auto;
  }
  
  .template-card {
    padding: 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
  }
  
  .template-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
  }
  
  .template-card-head h4 {
    margin: 0;
  }
  
  .template-items-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
  }
  
  .template-item-chip {
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    background: rgba(119, 168, 255, 0.12);
    border: 1px solid rgba(119, 168, 255, 0.18);
    color: #dce9ff;
  }
  
  @media (max-width: 980px) {
    .template-modal-grid {
      grid-template-columns: 1fr;
    }
  
    .inline-actions {
      flex-direction: column;
      align-items: stretch;
    }
  
    .compact-select {
      width: 100%;
    }
  }

  .checklist-input-row-advanced {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto;
  }
  
  .check-item-advanced {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
  }
  
  .check-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  
  .open-link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 12px;
    text-decoration: none;
    color: white;
    background: rgba(119, 168, 255, 0.16);
    border: 1px solid rgba(119, 168, 255, 0.22);
    transition: 0.18s ease;
  }
  
  .open-link-btn:hover {
    transform: translateY(-1px);
    background: rgba(119, 168, 255, 0.24);
  }
  
  @media (max-width: 860px) {
    .checklist-input-row-advanced {
      grid-template-columns: 1fr;
    }
  
    .check-item-advanced {
      grid-template-columns: 1fr;
    }
  
    .check-item-advanced input[type="checkbox"] {
      justify-self: start;
    }
  }
  

  .auth-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
  }
  
  .auth-card {
    width: min(420px, 100%);
    padding: 32px;
    border-radius: 28px;
    background: rgba(13, 18, 31, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
    text-align: center;
  }
  
  .auth-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 18px;
    display: grid;
    place-items: center;
    border-radius: 22px;
    font-weight: 800;
    font-size: 1.4rem;
    background: linear-gradient(135deg, rgba(119, 168, 255, 0.3), rgba(86, 197, 139, 0.14));
    border: 1px solid rgba(255, 255, 255, 0.08);
  }
  
  .auth-card h1 {
    margin: 0 0 8px;
  }
  
  .auth-subtitle {
    margin-bottom: 24px;
  }
  
  .auth-login-btn {
    width: 100%;
    min-height: 48px;
  }
  
  .auth-error {
    margin-top: 14px;
    color: #ff8b97;
  }
  
  .hidden {
    display: none !important;
  }