/* =========================================================
   1. DESIGN TOKENS
========================================================= */
:root{
  --font-ui:'Inter',-apple-system,BlinkMacSystemFont,sans-serif;
  --font-mono:'JetBrains Mono',ui-monospace,monospace;

  --bg:#E8ECEF;
  --surface:#FFFFFF;
  --surface-2:#F1F2F5;
  --surface-hover:#F7F8FA;
  --border:#E4E6EC;
  --border-strong:#D4D7E0;

  --text-primary:#14161C;
  --text-secondary:#5B6172;
  --text-tertiary:#9096A5;
  --text-inverse:#FFFFFF;

  --accent:#12141C;
  --accent-hover:#1A1D28;
  --accent-soft:#E4E6EC;
  --accent-soft-text:#12141C;

  --success:#12805C;
  --success-soft:#E4F6EE;
  --warning:#B4670A;
  --warning-soft:#FDF1DF;
  --danger:#C22A2A;
  --danger-soft:#FBE7E7;
  --neutral:#6B7280;
  --neutral-soft:#EEF0F3;

  --shadow-sm:0 1px 2px rgba(20,22,28,0.04);
  --shadow-md:0 4px 16px rgba(20,22,28,0.06);
  --shadow-lg:0 12px 32px rgba(20,22,28,0.10);

  --sidebar-bg:#12141C;
  --sidebar-bg-2:#1A1D28;
  --sidebar-border:#242835;
  --sidebar-text:#9BA0B0;
  --sidebar-text-active:#FFFFFF;

  --radius-sm:6px;
  --radius-md:10px;
  --radius-lg:14px;

  --nav-w:248px;
  --nav-w-collapsed:72px;
}

html.dark{
  --bg:#0A0B0F;
  --surface:#14161C;
  --surface-2:#1B1E27;
  --surface-hover:#1F222C;
  --border:#262A36;
  --border-strong:#333847;

  --text-primary:#F2F3F6;
  --text-secondary:#9BA0B0;
  --text-tertiary:#676D7E;
  --text-inverse:#14161C;

  --accent:#6C63F5;
  --accent-hover:#7D75F7;
  --accent-soft:#211F3B;
  --accent-soft-text:#9691FA;

  --success:#3ED999;
  --success-soft:#122B22;
  --warning:#F5A93F;
  --warning-soft:#332413;
  --danger:#F16565;
  --danger-soft:#331A1A;
  --neutral:#8A8F9C;
  --neutral-soft:#1E212B;

  --sidebar-bg:#0A0B10;
  --sidebar-bg-2:#14161F;
  --sidebar-border:#1E212C;
}

*{box-sizing:border-box; margin:0; padding:0;}
body{
  font-family:var(--font-ui);
  background:var(--bg);
  color:var(--text-primary);
  font-size:14px;
  line-height:1.5;
  -webkit-font-smoothing:antialiased;
  transition:background .2s ease, color .2s ease;
  overflow-x:hidden;
}
::selection{background:var(--accent-soft); color:var(--accent-soft-text);}
a{color:inherit; text-decoration:none;}
button{font-family:inherit; cursor:pointer;}
input,select,textarea{font-family:inherit; font-size:14px;}
svg{display:block;}
::-webkit-scrollbar{width:10px; height:10px;}
::-webkit-scrollbar-track{background:transparent;}
::-webkit-scrollbar-thumb{background:var(--border-strong); border-radius:8px; border:2px solid var(--bg);}

.mono{font-family:var(--font-mono); letter-spacing:-0.01em;}

/* =========================================================
   2. APP SHELL
========================================================= */
.app{display:flex; min-height:100vh;}

/* ---- Sidebar ---- */
.sidebar{
  width:var(--nav-w);
  flex-shrink:0;
  background:linear-gradient(180deg,var(--sidebar-bg),var(--sidebar-bg-2));
  border-right:1px solid var(--sidebar-border);
  display:flex; flex-direction:column;
  height:100vh; position:sticky; top:0;
  transition:width .18s ease;
  z-index:40;
}
.sidebar.collapsed{width:var(--nav-w-collapsed);}
.sidebar-brand{
  display:flex; align-items:center; gap:10px;
  padding:20px 18px; height:64px;
  border-bottom:1px solid var(--sidebar-border);
  flex-shrink:0;
}
.brand-mark{
  width:28px; height:28px; border-radius:8px;
  background:linear-gradient(135deg,#6C63F5,#4338CA);
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
}
.brand-mark svg{width:16px; height:16px;}
.brand-name{color:#fff; font-weight:700; font-size:15px; letter-spacing:-0.01em; white-space:nowrap; overflow:hidden;}
.sidebar.collapsed .brand-name, 
.sidebar.collapsed .nav-label, 
.sidebar.collapsed .nav-section-title, 
.sidebar.collapsed .user-meta, 
.sidebar.collapsed .sidebar-toggle span,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .theme-toggle-row,
.sidebar.collapsed .user-card { display: none; }

.sidebar.collapsed .nav-item svg { width: 22px; height: 22px; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .sidebar-footer { border-top: none; padding-top: 0; }
.sidebar.collapsed .sidebar-toggle { justify-content: center; }

.sidebar-nav{flex:1; overflow-y:auto; padding:16px 12px;}
.nav-section{margin-bottom:18px;}
.nav-section-title{
  font-size:11px; font-weight:600; text-transform:uppercase; letter-spacing:.06em;
  color:#565C6E; padding:0 10px 8px;
}
.nav-item{
  display:flex; align-items:center; gap:11px;
  padding:9px 10px; border-radius:8px; color:var(--sidebar-text);
  font-size:13.5px; font-weight:500; cursor:pointer; white-space:nowrap;
  transition:background .12s ease, color .12s ease; margin-bottom:2px; position:relative;
}
.nav-item svg{width:17px; height:17px; flex-shrink:0; opacity:.85;}
.nav-item:hover{background:rgba(255,255,255,0.05); color:#fff;}
.nav-item.active{background:rgba(108,99,245,0.16); color:#fff;}
.nav-item.active::before{
  content:''; position:absolute; left:-12px; top:8px; bottom:8px; width:3px;
  background:var(--accent); border-radius:0 3px 3px 0;
}
.nav-item.active svg{opacity:1; color:#9691FA;}
.nav-badge{
  margin-left:auto; font-size:10.5px; font-weight:700; background:rgba(255,255,255,0.08);
  color:#C7CAD6; padding:1px 6px; border-radius:20px;
}
.nav-item.active .nav-badge{background:var(--accent); color:#fff;}

.sidebar-footer{border-top:1px solid var(--sidebar-border); padding:16px 12px; flex-shrink:0;}
.theme-toggle-row{
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  padding:8px 10px; border-radius:8px; margin-bottom:6px;
}
.theme-toggle{
  display:flex; background:rgba(255,255,255,0.06); border-radius:20px; padding:2px; gap:2px;
}
.theme-toggle button{
  border:none; background:transparent; color:#8A90A2; width:26px; height:24px; border-radius:16px;
  display:flex; align-items:center; justify-content:center;
}
.theme-toggle button.active{background:var(--accent); color:#fff;}
.theme-toggle svg{width:13px; height:13px;}
.user-card{
  display:flex; align-items:center; gap:10px; padding:8px; border-radius:9px; cursor:pointer;
}
.user-card:hover{background:rgba(255,255,255,0.05);}
.user-avatar{
  width:32px; height:32px; border-radius:8px; background:linear-gradient(135deg,#F5A93F,#C22A2A);
  color:#fff; font-weight:700; font-size:13px; display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
.user-meta{overflow:hidden;}
.user-name{color:#fff; font-size:13px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.user-role{color:#6B7180; font-size:11.5px; white-space:nowrap;}
.sidebar-toggle{
  display:flex; align-items:center; gap:8px; width:100%; background:transparent; border:none; color:#6B7180;
  padding:8px 10px; border-radius:8px; font-size:12px; margin-top:4px;
}
.sidebar-toggle:hover{background:rgba(255,255,255,0.05); color:#fff;}
.sidebar-toggle svg{width:15px; height:15px; transition:transform .18s ease;}
.sidebar.collapsed .sidebar-toggle svg{transform:rotate(180deg);}

/* ---- Main column ---- */
.main{flex:1; min-width:0; display:flex; flex-direction:column;}

/* ---- Topbar ---- */
.topbar{
  height:64px; flex-shrink:0; background:var(--surface); border-bottom:1px solid var(--border);
  display:flex; align-items:center; gap:16px; padding:0 24px; position:sticky; top:0; z-index:30;
}
.mobile-menu-btn{display:none; background:none; border:none; color:var(--text-secondary); padding:6px;}
.mobile-menu-btn svg{width:20px; height:20px;}
.breadcrumb{display:flex; align-items:center; gap:6px; font-size:13px; color:var(--text-tertiary); flex-shrink:0;}
.breadcrumb b{color:var(--text-primary); font-weight:600;}
.topbar-search{
  flex:1; max-width:600px; display:flex; align-items:center; gap:9px;
  background:var(--surface-2); border:1px solid var(--border); border-radius:9px;
  padding:8px 12px; color:var(--text-tertiary); cursor:pointer; transition:border-color .15s;
}
.topbar-search:hover{border-color:var(--border-strong);}
.topbar-search svg{width:15px; height:15px; flex-shrink:0;}
.topbar-search span{font-size:13px; flex:1;}
.kbd{
  font-family:var(--font-mono); font-size:10.5px; background:var(--surface); border:1px solid var(--border);
  border-radius:4px; padding:1px 5px; color:var(--text-tertiary); flex-shrink:0;
}
.topbar-actions{display:flex; align-items:center; gap:10px; margin-left:auto; flex-shrink:0;}
.icon-btn{
  width:36px; height:36px; border-radius:9px; border:1px solid var(--border); background:var(--surface);
  display:flex; align-items:center; justify-content:center; color:var(--text-secondary); position:relative; flex-shrink:0;
}
.icon-btn:hover{background:var(--surface-hover); color:var(--text-primary);}
.icon-btn svg{width:17px; height:17px;}
.dot-flag{
  position:absolute; top:6px; right:6px; width:7px; height:7px; border-radius:50%; background:var(--danger);
  border:1.5px solid var(--surface);
}
.avatar-btn{
  width:36px; height:36px; border-radius:9px; background:linear-gradient(135deg,#F5A93F,#C22A2A);
  color:#fff; font-weight:700; font-size:13px; display:flex; align-items:center; justify-content:center; flex-shrink:0; border:none;
}

/* ---- Page content ---- */
.page{padding:32px 48px 60px; max-width:1440px; width:100%; margin:0 auto;}
.page-header{display:flex; align-items:flex-start; justify-content:space-between; gap:20px; margin-bottom:24px; flex-wrap:wrap;}
.page-title{font-size:23px; font-weight:700; letter-spacing:-0.015em; margin-bottom:4px;}
.page-subtitle{color:var(--text-secondary); font-size:13.5px;}
.page-actions{display:flex; gap:10px; flex-shrink:0;}

/* =========================================================
   3. COMPONENTS: buttons, badges, cards
========================================================= */
.btn{
  display:inline-flex; align-items:center; gap:7px; font-size:13.5px; font-weight:600;
  padding:9px 14px; border-radius:9px; border:1px solid transparent; transition:all .12s ease; white-space:nowrap;
}
.btn svg{width:15px; height:15px;}
.btn-primary{background:var(--accent); color:#fff;}
.btn-primary:hover{background:var(--accent-hover);}
.btn-secondary{background:var(--surface); border-color:var(--border); color:var(--text-primary);}
.btn-secondary:hover{background:var(--surface-hover); border-color:var(--border-strong);}
.btn-ghost{background:transparent; color:var(--text-secondary);}
.btn-ghost:hover{background:var(--surface-2); color:var(--text-primary);}
.btn-danger{background:var(--danger-soft); color:var(--danger);}
.btn-danger:hover{filter:brightness(0.95);}
.btn-sm{padding:6px 10px; font-size:12.5px; border-radius:7px;}
.btn:disabled{opacity:.5; cursor:not-allowed;}

.badge{
  display:inline-flex; align-items:center; gap:5px; font-size:11.5px; font-weight:600;
  padding:3px 9px; border-radius:20px; white-space:nowrap; line-height:1.6;
}
.badge::before{content:''; width:6px; height:6px; border-radius:50%; background:currentColor; flex-shrink:0;}
.badge-success{background:var(--success-soft); color:var(--success);}
.badge-warning{background:var(--warning-soft); color:var(--warning);}
.badge-danger{background:var(--danger-soft); color:var(--danger);}
.badge-neutral{background:var(--neutral-soft); color:var(--neutral);}
.badge-accent{background:var(--accent-soft); color:var(--accent-soft-text);}

.card{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg);
  box-shadow:var(--shadow-sm);
}
.card-pad{padding:20px;}

/* Stat cards */
.stat-grid{
  display:grid; grid-template-columns:repeat(5,1fr); gap:14px; margin-bottom:22px;
}
.stat-card{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg);
  padding:16px 18px; box-shadow:var(--shadow-sm); transition:border-color .15s, transform .15s;
}
.stat-card:hover{border-color:var(--border-strong); transform:translateY(-1px);}
.stat-top{display:flex; align-items:center; justify-content:space-between; margin-bottom:10px;}
.stat-label{font-size:12px; color:var(--text-secondary); font-weight:600;}
.stat-icon{width:28px; height:28px; border-radius:7px; display:flex; align-items:center; justify-content:center;}
.stat-icon svg{width:15px; height:15px;}
.stat-value{font-size:26px; font-weight:800; letter-spacing:-0.02em; margin-bottom:5px;}
.stat-trend{font-size:11.5px; font-weight:600; display:flex; align-items:center; gap:4px;}
.trend-up{color:var(--success);}
.trend-down{color:var(--danger);}
.trend-flat{color:var(--text-tertiary);}

/* Dashboard grid */
.dash-grid{display:grid; grid-template-columns:1.4fr 1fr; gap:16px; margin-bottom:16px;}
.dash-grid-2{display:grid; grid-template-columns:1fr 1fr 1fr; gap:16px; margin-bottom:16px;}
.section-card{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); box-shadow:var(--shadow-sm); overflow:hidden;}
.section-card-head{display:flex; align-items:center; justify-content:space-between; padding:16px 20px; border-bottom:1px solid var(--border);}
.section-card-title{font-size:14.5px; font-weight:700;}
.section-card-sub{font-size:12px; color:var(--text-tertiary); margin-top:2px;}
.section-card-body{padding:18px 20px;}
.link-btn{font-size:12.5px; font-weight:600; color:var(--accent); display:flex; align-items:center; gap:4px;}
.link-btn svg{width:13px; height:13px;}

/* Attention list */
.attn-item{display:flex; align-items:center; gap:12px; padding:11px 0; border-bottom:1px solid var(--border);}
.attn-item:last-child{border-bottom:none;}
.attn-icon{width:34px; height:34px; border-radius:8px; background:var(--warning-soft); color:var(--warning); display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.attn-icon svg{width:16px; height:16px;}
.attn-icon.critical{background:var(--danger-soft); color:var(--danger);}
.attn-main{flex:1; min-width:0;}
.attn-name{font-size:13.5px; font-weight:600; font-family:var(--font-mono);}
.attn-meta{font-size:12px; color:var(--text-tertiary); margin-top:1px;}
.attn-days{font-size:12px; font-weight:700; padding:3px 9px; border-radius:6px; flex-shrink:0;}

/* Table */
.table-wrap{overflow-x:auto;}
table{width:100%; border-collapse:collapse; font-size:13px;}
thead th{
  text-align:left; font-size:11.5px; font-weight:700; text-transform:uppercase; letter-spacing:.04em;
  color:var(--text-tertiary); padding:11px 20px; border-bottom:1px solid var(--border); white-space:nowrap; background:var(--surface-2);
}
tbody td{padding:13px 20px; border-bottom:1px solid var(--border); white-space:nowrap; color:var(--text-primary);}
tbody tr{transition:background .1s ease; cursor:pointer;}
tbody tr:hover{background:var(--surface-hover);}
tbody tr:last-child td{border-bottom:none;}
.cell-primary{font-weight:600;}
.cell-sub{color:var(--text-tertiary); font-size:12px; margin-top:1px;}
.cell-flex{display:flex; align-items:center; gap:10px;}
.avatar-sm{width:24px; height:24px; border-radius:6px; background:var(--accent-soft); color:var(--accent-soft-text); font-size:10.5px; font-weight:700; display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.env-chip{font-size:11px; font-weight:700; padding:2px 8px; border-radius:5px;}
.env-production{background:var(--danger-soft); color:var(--danger);}
.env-staging{background:var(--warning-soft); color:var(--warning);}
.env-development{background:var(--neutral-soft); color:var(--neutral);}
.row-actions{display:flex; justify-content:flex-end;}
.actions-btn{width:28px; height:28px; border-radius:6px; border:1px solid transparent; background:transparent; color:var(--text-tertiary); display:flex; align-items:center; justify-content:center;}
.actions-btn:hover{background:var(--surface-2); color:var(--text-primary); border-color:var(--border);}
.actions-btn svg{width:16px; height:16px;}

/* Empty state */
.empty-state{display:flex; flex-direction:column; align-items:center; justify-content:center; padding:56px 24px; text-align:center;}
.empty-icon{width:52px; height:52px; border-radius:14px; background:var(--surface-2); display:flex; align-items:center; justify-content:center; color:var(--text-tertiary); margin-bottom:14px;}
.empty-icon svg{width:24px; height:24px;}
.empty-title{font-size:14.5px; font-weight:700; margin-bottom:4px;}
.empty-sub{font-size:13px; color:var(--text-secondary); max-width:320px; margin-bottom:16px;}

/* Toolbar / filters */
.toolbar{display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:14px;}
.search-input{
  display:flex; align-items:center; gap:8px; background:var(--surface); border:1px solid var(--border);
  border-radius:9px; padding:8px 12px; min-width:230px; flex:1; max-width:320px;
}
.search-input svg{width:15px; height:15px; color:var(--text-tertiary); flex-shrink:0;}
.search-input input{border:none; outline:none; background:transparent; width:100%; color:var(--text-primary);}
.filter-select{
  border:1px solid var(--border); background:var(--surface); border-radius:9px; padding:8px 30px 8px 12px;
  color:var(--text-secondary); font-size:13px; font-weight:500; appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239096A5' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 12px center; cursor:pointer;
}
.view-toggle{display:flex; background:var(--surface-2); border:1px solid var(--border); border-radius:9px; padding:2px; margin-left:auto;}
.view-toggle button{border:none; background:transparent; padding:7px 12px; border-radius:7px; font-size:12.5px; font-weight:600; color:var(--text-secondary); display:flex; align-items:center; gap:6px;}
.view-toggle button.active{background:var(--surface); color:var(--text-primary); box-shadow:var(--shadow-sm);}
.view-toggle svg{width:14px; height:14px;}

.chip-row{display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:14px;}
.chip{
  display:flex; align-items:center; gap:6px; background:var(--accent-soft); color:var(--accent-soft-text);
  font-size:12px; font-weight:600; padding:5px 8px 5px 11px; border-radius:20px;
}
.chip button{background:none; border:none; color:inherit; display:flex; opacity:.7;}
.chip button:hover{opacity:1;}
.chip button svg{width:12px; height:12px;}
.chip-clear{font-size:12px; font-weight:600; color:var(--text-tertiary);}
.chip-clear:hover{color:var(--text-primary);}

/* Pagination */
.pagination{display:flex; align-items:center; justify-content:space-between; padding:14px 20px; border-top:1px solid var(--border);}
.pagination-info{font-size:12.5px; color:var(--text-tertiary);}
.pagination-controls{display:flex; gap:6px;}
.page-btn{width:30px; height:30px; border-radius:7px; border:1px solid var(--border); background:var(--surface); color:var(--text-secondary); font-size:12.5px; font-weight:600;}
.page-btn:hover{background:var(--surface-hover);}
.page-btn.active{background:var(--accent); color:#fff; border-color:var(--accent);}
.page-btn:disabled{opacity:.4;}

/* Grid cards for Projects */
.project-grid{display:grid; grid-template-columns:repeat(3,1fr); gap:16px;}
.project-card{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); padding:18px; box-shadow:var(--shadow-sm); cursor:pointer; transition:border-color .15s, transform .15s;}
.project-card:hover{border-color:var(--border-strong); transform:translateY(-2px); box-shadow:var(--shadow-md);}
.project-card-top{display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:12px;}
.project-icon{width:38px; height:38px; border-radius:9px; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:14px; color:#fff; flex-shrink:0;}
.project-name{font-size:14.5px; font-weight:700; margin-bottom:2px;}
.project-domain{font-size:12px; color:var(--text-tertiary); font-family:var(--font-mono);}
.project-meta-row{display:flex; align-items:center; justify-content:space-between; font-size:12px; color:var(--text-tertiary); padding-top:12px; margin-top:12px; border-top:1px solid var(--border);}
.project-devs{display:flex; align-items:center;}
.project-devs .avatar-sm{margin-left:-8px; border:2px solid var(--surface);}
.project-devs .avatar-sm:first-child{margin-left:0;}

/* Hosting cards */
.host-grid{display:grid; grid-template-columns:repeat(4,1fr); gap:16px; margin-bottom:20px;}
.host-card{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); padding:18px; box-shadow:var(--shadow-sm); cursor:pointer;}
.host-card:hover{border-color:var(--border-strong);}
.host-logo{width:40px; height:40px; border-radius:9px; display:flex; align-items:center; justify-content:center; font-weight:800; color:#fff; font-size:15px; margin-bottom:12px;}
.host-name{font-weight:700; font-size:15px; margin-bottom:2px;}
.host-plan{font-size:12px; color:var(--text-tertiary); margin-bottom:14px;}
.host-stats{display:grid; grid-template-columns:1fr 1fr; gap:10px;}
.host-stat-val{font-size:16px; font-weight:700;}
.host-stat-label{font-size:11px; color:var(--text-tertiary);}
.storage-bar{height:6px; border-radius:4px; background:var(--surface-2); margin-top:14px; overflow:hidden;}
.storage-bar-fill{height:100%; background:var(--accent); border-radius:4px;}

/* People */
.person-grid{display:grid; grid-template-columns:repeat(3,1fr); gap:16px;}
.person-card{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); padding:18px; box-shadow:var(--shadow-sm); cursor:pointer; display:flex; gap:13px;}
.person-card:hover{border-color:var(--border-strong);}
.person-avatar{width:44px; height:44px; border-radius:10px; color:#fff; font-weight:700; font-size:15px; display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.person-name{font-weight:700; font-size:14px; margin-bottom:1px;}
.person-role{font-size:12px; color:var(--text-tertiary); margin-bottom:8px;}
.person-stats{display:flex; gap:14px; font-size:11.5px; color:var(--text-secondary);}
.person-stats b{color:var(--text-primary); font-size:13px; display:block;}

/* Timeline */
.timeline{position:relative; padding-left:6px;}
.timeline-item{position:relative; padding:0 0 20px 24px; border-left:2px solid var(--border);}
.timeline-item:last-child{border-color:transparent; padding-bottom:0;}
.timeline-dot{position:absolute; left:-7px; top:0; width:12px; height:12px; border-radius:50%; background:var(--accent); border:2px solid var(--surface);}
.timeline-dot.dot-success{background:var(--success);}
.timeline-dot.dot-warning{background:var(--warning);}
.timeline-date{font-size:11.5px; color:var(--text-tertiary); font-weight:600; margin-bottom:3px;}
.timeline-title{font-size:13.5px; font-weight:600; margin-bottom:2px;}
.timeline-sub{font-size:12.5px; color:var(--text-secondary);}

/* Tabs */
.tabs{display:flex; gap:2px; border-bottom:1px solid var(--border); margin-bottom:20px;}
.tab{padding:11px 4px; margin-right:22px; font-size:13.5px; font-weight:600; color:var(--text-tertiary); border-bottom:2px solid transparent; position:relative; top:1px;}
.tab.active{color:var(--text-primary); border-color:var(--accent);}
.tab:hover{color:var(--text-primary);}

/* Detail header */
.detail-header{display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:6px; gap:16px; flex-wrap:wrap;}
.detail-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 6px 14px 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    margin-bottom: 20px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    width: fit-content;
}
.detail-back:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
    border-color: var(--border-strong);
    transform: translateX(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}
.detail-back svg {
    width: 15px; 
    height: 15px; 
    transition: transform 0.2s ease;
}
.detail-back:hover svg {
    transform: translateX(-3px);
}
.detail-title-row{display:flex; align-items:center; gap:12px;}
.detail-title{font-size:22px; font-weight:800; font-family:var(--font-mono); letter-spacing:-0.02em;}
.detail-grid{display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:16px;}
.kv-row{display:flex; align-items:center; justify-content:space-between; padding:11px 0; border-bottom:1px solid var(--border); font-size:13px;}
.kv-row:last-child{border-bottom:none;}
.kv-label{color:var(--text-tertiary); font-weight:500;}
.kv-value{font-weight:600; text-align:right;}
.subdomain-pill{display:inline-flex; align-items:center; gap:7px; background:var(--surface-2); border:1px solid var(--border); border-radius:8px; padding:8px 12px; font-family:var(--font-mono); font-size:12.5px; font-weight:600; margin:0 8px 8px 0;}

/* =========================================================
   4. MODALS / DRAWERS / OVERLAYS
========================================================= */
.overlay{
  position:fixed; inset:0; background:rgba(10,11,16,0.5); backdrop-filter:blur(2px);
  display:flex; align-items:flex-start; justify-content:center; z-index:200; opacity:0; pointer-events:none;
  transition:opacity .18s ease; padding:80px 20px 20px;
}
.overlay.open{opacity:1; pointer-events:auto;}
.overlay.center{align-items:center; padding:20px;}
.modal{
  background:var(--surface); border-radius:var(--radius-lg); width:100%; max-width:520px;
  box-shadow:var(--shadow-lg); transform:translateY(-10px); transition:transform .18s ease; max-height:86vh; display:flex; flex-direction:column;
  border:1px solid var(--border);
}
.overlay.open .modal{transform:translateY(0);}
.modal-header{display:flex; align-items:center; justify-content:space-between; padding:18px 22px; border-bottom:1px solid var(--border); flex-shrink:0;}
.modal-title{font-size:15.5px; font-weight:700;}
.modal-close{width:30px; height:30px; border-radius:8px; border:none; background:var(--surface-2); color:var(--text-secondary); display:flex; align-items:center; justify-content:center;}
.modal-close svg{width:15px; height:15px;}
.modal-body{padding:20px 22px; overflow-y:auto;}
.modal-footer{display:flex; justify-content:flex-end; gap:10px; padding:16px 22px; border-top:1px solid var(--border); flex-shrink:0;}

.form-group{margin-bottom:16px;}
.form-label{display:block; font-size:12.5px; font-weight:600; color:var(--text-secondary); margin-bottom:6px;}
.form-control{width:100%; padding:9px 12px; border:1px solid var(--border); border-radius:8px; background:var(--surface); color:var(--text-primary); outline:none;}
.form-control:focus{border-color:var(--accent);}
select.form-control{
  appearance:none; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239096A5' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 12px center; padding-right:30px;
}
.form-row{display:grid; grid-template-columns:1fr 1fr; gap:12px;}

.quick-add-grid{display:grid; grid-template-columns:1fr 1fr; gap:10px;}
.qa-option{display:flex; align-items:center; gap:12px; padding:14px; border:1px solid var(--border); border-radius:10px; transition:all .2s ease; cursor:pointer;}
.qa-option:hover{border-color:var(--accent); background:var(--accent-soft); box-shadow:0 4px 12px rgba(0,0,0,0.05); transform:translateY(-2px);}
.qa-icon{width:36px; height:36px; border-radius:9px; background:var(--surface-2); display:flex; align-items:center; justify-content:center; flex-shrink:0; color:var(--accent);}
.qa-icon svg{width:17px; height:17px;}
.qa-title{font-size:13px; font-weight:700;}
.qa-sub{font-size:11.5px; color:var(--text-tertiary);}

/* Drawer (right side) */
.drawer-overlay{
  position:fixed; inset:0; background:rgba(10,11,16,0.5); z-index:210; opacity:0; pointer-events:none; transition:opacity .18s ease;
}
.drawer-overlay.open{opacity:1; pointer-events:auto;}
.drawer{
  position:fixed; top:0; right:0; bottom:0; width:480px; max-width:92vw; background:var(--surface);
  border-left:1px solid var(--border); box-shadow:var(--shadow-lg); transform:translateX(100%); transition:transform .2s ease;
  z-index:211; display:flex; flex-direction:column;
}
.drawer-overlay.open .drawer{transform:translateX(0);}
.drawer-header{padding:20px 22px; border-bottom:1px solid var(--border); display:flex; align-items:flex-start; justify-content:space-between; flex-shrink:0;}
.drawer-body{padding:22px; overflow-y:auto; flex:1;}
.drawer-footer{padding:16px 22px; border-top:1px solid var(--border); display:flex; gap:10px; justify-content:flex-end; flex-shrink:0;}

/* Search palette */
.search-palette{width:100%; max-width:600px; margin-top:0;}
.sp-input-row{display:flex; align-items:center; gap:10px; padding:16px 20px; border-bottom:1px solid var(--border);}
.sp-input-row svg{width:18px; height:18px; color:var(--text-tertiary); flex-shrink:0;}
.sp-input-row input{flex:1; border:none; outline:none; background:transparent; font-size:15px; color:var(--text-primary);}
.sp-results{max-height:60vh; overflow-y:auto; padding:8px;}
.sp-group-title{font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--text-tertiary); padding:10px 12px 6px;}
.sp-item{display:flex; align-items:center; gap:11px; padding:9px 12px; border-radius:8px;}
.sp-item:hover{background:var(--surface-2);}
.sp-item-icon{width:30px; height:30px; border-radius:7px; background:var(--surface-2); display:flex; align-items:center; justify-content:center; color:var(--text-secondary); flex-shrink:0;}
.sp-item-icon svg{width:15px; height:15px;}
.sp-item-title{font-size:13.5px; font-weight:600;}
.sp-item-sub{font-size:11.5px; color:var(--text-tertiary);}
.sp-empty{padding:40px 20px; text-align:center; color:var(--text-tertiary); font-size:13px;}

/* Notifications dropdown */
.dropdown-panel{
  position:absolute; top:48px; right:0; width:340px; background:var(--surface); border:1px solid var(--border);
  border-radius:12px; box-shadow:var(--shadow-lg); z-index:100; opacity:0; transform:translateY(-6px); pointer-events:none; transition:all .15s ease;
}
.dropdown-panel.open{opacity:1; transform:translateY(0); pointer-events:auto;}
.dropdown-head{padding:14px 16px; border-bottom:1px solid var(--border); font-size:13.5px; font-weight:700; display:flex; justify-content:space-between; align-items:center;}
.notif-item{display:flex; gap:10px; padding:12px 16px; border-bottom:1px solid var(--border);}
.notif-item:last-child{border-bottom:none;}
.notif-dot{width:7px; height:7px; border-radius:50%; background:var(--accent); flex-shrink:0; margin-top:5px;}
.notif-text{font-size:12.5px; line-height:1.45;}
.notif-time{font-size:11px; color:var(--text-tertiary); margin-top:3px;}

/* Toast */
.toast-stack{position:fixed; bottom:20px; right:20px; z-index:300; display:flex; flex-direction:column; gap:10px;}
.toast{
  background:var(--surface); border:1px solid var(--border); box-shadow:var(--shadow-lg); border-radius:10px;
  padding:12px 16px; display:flex; align-items:center; gap:10px; font-size:13px; font-weight:600; min-width:260px;
  animation:toastIn .2s ease;
}
@keyframes toastIn{from{opacity:0; transform:translateY(8px);} to{opacity:1; transform:translateY(0);}}
.toast-icon{width:22px; height:22px; border-radius:50%; background:var(--success-soft); color:var(--success); display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.toast-icon svg{width:12px; height:12px;}

/* Charts container */
.chart-box{position:relative; height:230px;}
.chart-box.small{height:190px;}
.legend-row{display:flex; flex-wrap:wrap; gap:14px; margin-top:14px; justify-content:center;}
.legend-item{display:flex; align-items:center; gap:6px; font-size:12px; color:var(--text-secondary);}
.legend-dot{width:8px; height:8px; border-radius:2px;}

/* Reports */
.report-type-grid{display:grid; grid-template-columns:repeat(4,1fr); gap:12px; margin-bottom:22px;}
.report-type-card{background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:16px; cursor:pointer; transition:all .12s;}
.report-type-card:hover{border-color:var(--accent);}
.report-type-card.active{border-color:var(--accent); background:var(--accent-soft);}
.report-type-icon{width:32px; height:32px; border-radius:8px; background:var(--surface-2); color:var(--accent); display:flex; align-items:center; justify-content:center; margin-bottom:10px;}
.report-type-icon svg{width:16px; height:16px;}
.report-type-card.active .report-type-icon{background:var(--surface);}
.report-type-title{font-size:13px; font-weight:700; margin-bottom:2px;}
.report-type-sub{font-size:11.5px; color:var(--text-tertiary);}

/* Mobile bottom sheet */
.sheet-overlay{position:fixed; inset:0; background:rgba(10,11,16,0.5); z-index:220; opacity:0; pointer-events:none; transition:opacity .18s;}
.sheet-overlay.open{opacity:1; pointer-events:auto;}
.sheet{position:fixed; left:0; right:0; bottom:0; background:var(--surface); border-radius:18px 18px 0 0; max-height:80vh; transform:translateY(100%); transition:transform .22s ease; z-index:221; display:flex; flex-direction:column;}
.sheet-overlay.open .sheet{transform:translateY(0);}
.sheet-handle{width:36px; height:4px; background:var(--border-strong); border-radius:4px; margin:10px auto;}
.sheet-header{padding:6px 20px 14px; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center;}
.sheet-body{padding:16px 20px; overflow-y:auto;}
.sheet-footer{padding:14px 20px; border-top:1px solid var(--border); display:flex; gap:10px;}

/* Delete confirm */
.confirm-icon{width:46px; height:46px; border-radius:12px; background:var(--danger-soft); color:var(--danger); display:flex; align-items:center; justify-content:center; margin-bottom:14px;}
.confirm-icon svg{width:22px; height:22px;}

/* Mobile sidebar */
.sidebar-backdrop{position:fixed; inset:0; background:rgba(10,11,16,0.5); z-index:39; opacity:0; pointer-events:none; transition:opacity .18s;}
.sidebar-backdrop.open{opacity:1; pointer-events:auto;}

/* =========================================================
   5. RESPONSIVE
========================================================= */
@media (max-width:1200px){
  .stat-grid{grid-template-columns:repeat(3,1fr);}
  .dash-grid{grid-template-columns:1fr;}
  .dash-grid-2{grid-template-columns:1fr 1fr;}
  .project-grid{grid-template-columns:repeat(2,1fr);}
  .host-grid{grid-template-columns:repeat(2,1fr);}
  .person-grid{grid-template-columns:repeat(2,1fr);}
  .report-type-grid{grid-template-columns:repeat(2,1fr);}
}
@media (max-width:900px){
  .sidebar{position:fixed; left:0; top:0; bottom:0; transform:translateX(-100%); transition:transform .2s ease; width:260px;}
  .sidebar.mobile-open{transform:translateX(0);}
  .mobile-menu-btn{display:flex;}
  .breadcrumb{display:none;}
  .topbar-search span, .topbar-search .kbd{display:none;}
  .topbar-search{max-width:44px; padding:9px;}
  .page{padding:18px 16px 50px;}
  .stat-grid{grid-template-columns:repeat(2,1fr);}
  .dash-grid-2{grid-template-columns:1fr;}
  .project-grid, .host-grid, .person-grid{grid-template-columns:1fr;}
  .detail-grid{grid-template-columns:1fr;}
  .form-row{grid-template-columns:1fr;}
  .report-type-grid{grid-template-columns:repeat(2,1fr);}
  .drawer{width:100%; max-width:100%;}
  table thead{display:none;}
  table, tbody, tbody tr, tbody td{display:block; width:100%;}
  tbody tr{border:1px solid var(--border); border-radius:12px; margin-bottom:10px; padding:6px 4px; background:var(--surface); box-shadow:var(--shadow-sm);}
  tbody td{border-bottom:none; padding:6px 14px; white-space:normal;}
  tbody td::before{content:attr(data-label); display:block; font-size:10.5px; font-weight:700; text-transform:uppercase; letter-spacing:.04em; color:var(--text-tertiary); margin-bottom:2px;}
  .table-wrap{overflow-x:visible;}
  .row-actions{justify-content:flex-start;}
}
@media (max-width:560px){
  .stat-grid{grid-template-columns:1fr 1fr;}
  .page-header{flex-direction:column;}
  .page-actions{width:100%;}
  .page-actions .btn{flex:1; justify-content:center;}
  .quick-add-grid{grid-template-columns:1fr;}
  .report-type-grid{grid-template-columns:1fr 1fr;}
}

.hidden{display:none !important;}
.icon-only-btn{background:none; border:none; color:var(--text-tertiary); display:flex; align-items:center;}

/* =========================================================
   6. MODERN FORMS (Add Record)
========================================================= */
.page-modern { max-width: 900px; margin: 0 auto; padding: 32px 16px 64px; font-family: var(--font-ui); }
.header-modern { margin-bottom: 28px; }
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 6px 14px 6px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    text-decoration: none;
    margin-bottom: 24px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    width: fit-content;
}
.back-link:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
    border-color: var(--border-strong);
    transform: translateX(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}
.back-link svg {
    width: 15px; 
    height: 15px; 
    transition: transform 0.2s ease;
}
.back-link:hover svg {
    transform: translateX(-3px);
}
.page-title-modern { font-size: 24px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; letter-spacing: -0.015em; }
.page-subtitle-modern { font-size: 14px; color: var(--text-secondary); }
.form-card-modern { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03), 0 1px 3px rgba(0, 0, 0, 0.02); overflow: hidden; }
.form-section { padding: 32px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: none; }
.form-section-title { font-size: 16px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.form-section-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 24px; }
.form-grid-modern { display: grid; grid-template-columns: 1fr; gap: 20px 24px; }
@media (min-width: 768px) {
    .form-grid-modern.two-cols { grid-template-columns: 1fr 1fr; }
    .form-grid-modern .full-width { grid-column: span 2; }
}
.form-group-modern { display: flex; flex-direction: column; }
.form-label-modern { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.form-control-modern { width: 100%; height: 44px; padding: 0 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; color: var(--text-primary); background: var(--surface); transition: all 0.2s ease; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02); outline: none; }
textarea.form-control-modern { height: auto; padding: 12px 14px; resize: vertical; font-family: inherit; }
.form-control-modern:hover { border-color: var(--border-strong); }
.form-control-modern:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.form-control-modern { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239096A5' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; cursor: pointer; }
.form-actions-modern { padding: 24px 32px; background: var(--surface-2); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 12px; }
.btn-modern { display: inline-flex; align-items: center; justify-content: center; height: 42px; padding: 0 20px; font-size: 13.5px; font-weight: 600; border-radius: 8px; cursor: pointer; transition: all 0.15s ease; border: 1px solid transparent; }
.btn-secondary-modern { background: var(--surface); border-color: var(--border); color: var(--text-primary); }
.btn-secondary-modern:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-primary-modern { background: var(--accent); color: #fff; }
.btn-primary-modern:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(67, 56, 202, 0.15); }
@media (max-width: 600px) {
    .form-actions-modern { flex-direction: column-reverse; }
    .form-actions-modern .btn-modern { width: 100%; }
    .form-section { padding: 24px 20px; }
}