:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface2: #f7f7f5;
    --surface3: #efefed;
    --border: #e5e5e5;
    --border-light: #d4d4d4;
    --accent: #2383e2; /* Notion-like blue */
    --accent-dim: rgba(35, 131, 226, 0.1);
    --accent-glow: rgba(35, 131, 226, 0.2);
    --green: #0f7b6c;
    --green-dim: rgba(15, 123, 108, 0.1);
    --red: #eb5757;
    --red-dim: rgba(235, 87, 87, 0.1);
    --amber: #d97706;
    --text: #37352f;
    --text-muted: #787774;
    --text-dim: #9b9a97;
    --mono: 'Roboto Mono', monospace;
    --head: 'Inter', 'Google Sans', Roboto, -apple-system, sans-serif;
    --body: 'Inter', Roboto, -apple-system, sans-serif;
    --radius: 8px; /* Slightly less rounded for Notion feel */
    --radius-sm: 4px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
    --sidebar-w: 260px;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--body);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    overflow: hidden;
  }

  /* ─── LAYOUT ─── */
  #app { display: flex; height: 100vh; }

  /* ─── SIDEBAR ─── */
  #sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .sidebar-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--border);
  }

  .logo {
    font-family: var(--head);
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.5px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
  }

  .logo-icon {
    width: 28px; height: 28px;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
  }

  #global-search {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px 7px 32px;
    color: var(--text);
    font-family: var(--body);
    font-size: 13px;
    outline: none;
    transition: border-color .2s;
    position: relative;
  }
  #global-search:focus { border-color: var(--accent); }

  .search-wrap { position: relative; }
  .search-wrap .icon {
    position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
    color: var(--text-dim); font-size: 14px; pointer-events: none;
  }

  .sidebar-section-label {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    text-transform: uppercase;
    padding: 14px 16px 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  #project-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
  }

  #project-list::-webkit-scrollbar { width: 4px; }
  #project-list::-webkit-scrollbar-track { background: transparent; }
  #project-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

  .project-item {
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s, color .15s;
    display: flex; align-items: center; gap: 8px;
    color: var(--text-muted);
    font-size: 13.5px;
  }
  .project-item:hover { background: var(--surface2); color: var(--text); }
  .project-item.active {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 500;
  }

  .project-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
  }
  .project-item.active .project-dot { background: var(--accent); }

  .project-name-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .project-count {
    font-family: var(--mono);
    font-size: 10px;
    background: var(--surface3);
    padding: 1px 6px;
    border-radius: 10px;
    color: var(--text-dim);
  }
  .project-item.active .project-count { background: var(--accent-dim); color: var(--accent); }

  .sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 4px;
  }

  .sidebar-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    font-size: 13px;
    transition: background .15s, color .15s;
    border: none; background: transparent; width: 100%; text-align: left;
    font-family: var(--body);
  }
  .sidebar-btn:hover { background: var(--surface2); color: var(--text); }

  /* ─── MAIN PANEL ─── */
  #main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  /* ─── EMPTY STATE ─── */
  #empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-dim);
  }

  .empty-icon { font-size: 48px; opacity: 0.3; }

  .empty-title {
    font-family: var(--head);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-muted);
  }

  .empty-sub { font-size: 13px; color: var(--text-dim); text-align: center; max-width: 280px; }

  /* ─── PROJECT VIEW ─── */
  #project-view {
    flex: 1;
    overflow-y: auto;
    display: none;
  }
  #project-view::-webkit-scrollbar { width: 5px; }
  #project-view::-webkit-scrollbar-track { background: transparent; }
  #project-view::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

  .project-header {
    padding: 28px 32px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    position: sticky; top: 0;
    background: var(--bg);
    z-index: 10;
    backdrop-filter: blur(8px);
  }

  .project-header-left { flex: 1; }

  .project-title {
    font-family: var(--head);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
  }

  .project-desc { color: var(--text-muted); font-size: 13px; }

  .project-meta {
    display: flex; align-items: center; gap: 12px;
    margin-top: 8px;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
  }

  .project-header-actions { display: flex; align-items: center; gap: 8px; }

  /* ─── TABS ─── */
  .tabs {
    display: flex;
    gap: 2px;
    padding: 16px 32px 0;
    border-bottom: 1px solid var(--border);
  }

  .tab {
    padding: 8px 16px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    border: 1px solid transparent;
    border-bottom: none;
    transition: all .15s;
    position: relative;
    bottom: -1px;
    display: flex; align-items: center; gap: 6px;
    background: transparent;
    font-family: var(--body);
  }
  .tab:hover { color: var(--text); }
  .tab.active {
    color: var(--accent);
    background: var(--bg);
    border-color: var(--border);
    border-bottom-color: var(--bg);
  }

  .tab-count {
    font-family: var(--mono);
    font-size: 10px;
    background: var(--surface2);
    padding: 1px 6px;
    border-radius: 10px;
  }
  .tab.active .tab-count { background: var(--accent-dim); color: var(--accent); }

  /* ─── CONTENT PANEL ─── */
  .tab-content { padding: 24px 32px; display: none; }
  .tab-content.active { display: block; }

  /* ─── SECTION HEADER ─── */
  .section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
  }

  .section-title {
    font-family: var(--head);
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
  }

  /* ─── ENVIRONMENT CARDS ─── */
  .env-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
  }

  /* ─── LINK CARDS (GitHub & Docs tabs) ─── */
  .links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
  }

  .links-empty {
    color: var(--text-dim);
    font-size: 13px;
    padding: 20px 0;
  }

  .link-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: border-color .2s, box-shadow .2s;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .link-card:hover { border-color: var(--border-light); box-shadow: var(--shadow); }

  .link-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
  }

  .link-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
  }

  .link-card-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .link-card-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
  }

  .link-card-url {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-dim);
    word-break: break-all;
    line-height: 1.6;
  }

  .link-card-branch {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 3px;
  }

  .link-card-actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
  }

  .env-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: border-color .2s, box-shadow .2s;
  }
  .env-card:hover { border-color: var(--border-light); box-shadow: var(--shadow); }

  .env-card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
  }

  .env-badge {
    font-family: var(--mono);
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 500;
  }

  .env-badge.local { background: var(--green-dim); color: var(--green); }
  .env-badge.dev { background: rgba(251,191,36,0.12); color: var(--amber); }
  .env-badge.stage { background: rgba(167,139,250,0.12); color: #a78bfa; }
  .env-badge.live { background: var(--red-dim); color: var(--red); }
  .env-badge.other { background: var(--accent-dim); color: var(--accent); }

  .env-url {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-muted);
    word-break: break-all;
    margin-bottom: 12px;
    line-height: 1.6;
  }

  .env-actions { display: flex; gap: 6px; }

  /* ─── CREDENTIALS TABLE ─── */
  .cred-filters {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
  }

  .filter-input {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    color: var(--text);
    font-family: var(--body);
    font-size: 13px;
    outline: none;
    transition: border-color .2s;
  }
  .filter-input:focus { border-color: var(--accent); }
  .filter-input::placeholder { color: var(--text-dim); }

  .cred-table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
  }

  table {
    width: 100%;
    border-collapse: collapse;
  }

  thead th {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-dim);
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
  }

  tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .12s;
  }
  tbody tr:last-child { border-bottom: none; }
  tbody tr:hover { background: var(--surface2); }

  td {
    padding: 12px 16px;
    font-size: 13.5px;
    vertical-align: middle;
  }

  .cred-username {
    font-weight: 500;
    color: var(--text);
    font-family: var(--mono);
    font-size: 12px;
  }

  .cred-password {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-muted);
    display: flex; align-items: center; gap: 6px;
  }

  .cred-notes {
    color: var(--text-dim);
    font-size: 12px;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .cred-actions { display: flex; gap: 5px; }

  .empty-table {
    padding: 40px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
  }

  /* ─── BUTTONS ─── */
  .btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    border: 1px solid transparent;
    font-family: var(--body);
    white-space: nowrap;
  }

  .btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
  }
  .btn-primary:hover { background: #7d9bff; box-shadow: 0 0 16px var(--accent-glow); }

  .btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
  }
  .btn-ghost:hover { background: var(--surface2); color: var(--text); border-color: var(--border-light); }

  .btn-danger {
    background: transparent;
    color: var(--red);
    border-color: var(--red-dim);
  }
  .btn-danger:hover { background: var(--red-dim); }

  .icon-btn {
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 5px;
    cursor: pointer;
    transition: all .15s;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-size: 13px;
  }
  .icon-btn:hover { background: var(--surface3); color: var(--text); }
  .icon-btn.danger:hover { background: var(--red-dim); color: var(--red); }
  .icon-btn.copy-success { color: var(--green); }

  /* ─── MODAL ─── */
  .modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    animation: fadeIn .15s ease;
  }

  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
  @keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

  .modal {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    padding: 28px;
    width: 100%;
    max-width: 460px;
    box-shadow: var(--shadow-lg);
    animation: slideUp .2s ease;
  }

  .modal-title {
    font-family: var(--head);
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
  }

  .form-group { margin-bottom: 16px; }

  .form-label {
    display: block;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 6px;
  }

  .form-input, .form-select, .form-textarea {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    color: var(--text);
    font-family: var(--body);
    font-size: 13.5px;
    outline: none;
    transition: border-color .2s;
  }
  .form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
  }
  .form-input::placeholder { color: var(--text-dim); }
  .form-textarea { resize: vertical; min-height: 80px; }
  .form-select { cursor: pointer; }
  .form-select option { background: var(--surface2); }

  .password-wrap { position: relative; }
  .password-wrap .form-input { padding-right: 36px; }
  .password-toggle {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer;
    color: var(--text-dim); font-size: 14px;
  }
  .password-toggle:hover { color: var(--text); }

  .modal-footer {
    display: flex; gap: 8px; justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
  }

  /* ─── TOAST ─── */
  #toast-container {
    position: fixed; bottom: 24px; right: 24px;
    z-index: 2000;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
  }

  .toast {
    background: var(--surface3);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text);
    box-shadow: var(--shadow);
    animation: slideUp .2s ease, fadeOut .3s ease 1.8s forwards;
    display: flex; align-items: center; gap: 8px;
  }

  @keyframes fadeOut { to { opacity: 0; transform: translateY(8px); } }

  /* ─── EXPORT/IMPORT BAR ─── */
  .io-bar {
    display: flex; gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
  }

  /* ─── RESPONSIVE ─── */
  @media (max-width: 680px) {
    :root { --sidebar-w: 220px; }
    .project-header { padding: 16px 16px 12px; }
    .tabs { padding: 12px 16px 0; }
    .tab-content { padding: 16px; }
    .env-grid { grid-template-columns: 1fr; }
  }

  /* ─── SCROLLBAR GLOBAL ─── */
  ::-webkit-scrollbar { width: 5px; height: 5px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }