:root {
  --bg: #FAFAF7;
  --surface: #FFFFFF;
  --surface-2: #F4F3EE;
  --surface-hover: #EEEDE6;
  --border: rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.14);
  --text: #1A1A18;
  --text-2: #5F5E5A;
  --text-3: #8B8A82;
  --info: #185FA5; --info-bg: #E6F1FB; --info-text: #0C447C;
  --success: #0F6E56; --success-bg: #E1F5EE; --success-text: #085041;
  --warning: #854F0B; --warning-bg: #FAEEDA; --warning-text: #633806;
  --danger: #A32D2D; --danger-bg: #FCEBEB; --danger-text: #791F1F;
  --purple-bg: #EEEDFE; --purple-text: #3C3489;
  --pink-bg: #FBEAF0; --pink-text: #72243E;
  --teal-bg: #E1F5EE; --teal-text: #085041;
  --coral-bg: #FAECE7; --coral-text: #712B13;
  --amber-bg: #FAEEDA; --amber-text: #633806;
  --radius: 8px;
  --radius-lg: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  display: grid;
  grid-template-columns: 248px 1fr;
  line-height: 1.5;
}
h1, h2, h3, h4 { font-weight: 500; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--info-text); }

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 0.5px solid var(--border);
  overflow-y: auto;
  height: 100vh;
  position: sticky;
  top: 0;
}
.sidebar-header {
  padding: 18px 20px 14px;
  border-bottom: 0.5px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-header .logo {
  width: 28px; height: 28px; background: var(--text); color: var(--surface);
  border-radius: 6px; display: grid; place-items: center; font-weight: 500; font-size: 13px;
}
.sidebar-header .title { font-weight: 500; font-size: 14px; }
.sidebar-header .subtitle { font-size: 11px; color: var(--text-3); }

.nav-section { padding: 12px 12px 6px; }
.nav-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-3); padding: 6px 10px 4px; font-weight: 500;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  transition: background 0.1s;
  text-decoration: none;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--surface-2); font-weight: 500; }
.nav-item i { font-size: 17px; color: var(--text-2); width: 17px; }
.nav-item.active i { color: var(--text); }
.nav-item .badge {
  margin-left: auto; font-size: 11px;
  background: var(--danger-bg); color: var(--danger-text);
  padding: 1px 7px; border-radius: 10px; font-weight: 500;
}
.badge-soon {
  margin-left: auto; font-size: 10px;
  background: var(--surface-2); color: var(--text-3);
  padding: 1px 6px; border-radius: 8px;
}
.nav-item .dot-down { width: 6px; height: 6px; background: var(--danger); border-radius: 50%; margin-left: auto; }
.nav-sub { padding-left: 28px; font-size: 12.5px; color: var(--text-2); }
.nav-sub.active { background: var(--surface-2); color: var(--text); font-weight: 500; }
.muted { color: var(--text-2); }
.tertiary { color: var(--text-3); }

/* Main */
.main { overflow-y: auto; height: 100vh; }
.topbar {
  height: 56px;
  border-bottom: 0.5px solid var(--border);
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.breadcrumb { font-size: 13px; color: var(--text-2); display: flex; gap: 6px; align-items: center; }
.breadcrumb .sep { color: var(--text-3); }
.breadcrumb .current { color: var(--text); font-weight: 500; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.view-content { padding: 24px; }
.view-inner {}

/* Buttons */
.btn {
  background: var(--surface); border: 0.5px solid var(--border-strong);
  padding: 6px 12px; border-radius: var(--radius); font-size: 13px; cursor: pointer;
  color: var(--text); display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit; text-decoration: none;
}
.btn:hover { background: var(--surface-hover); color: var(--text); }
.btn-primary { background: var(--text); color: var(--surface); border-color: var(--text); }
.btn-primary:hover { background: #333; color: var(--surface); }
.btn-icon { padding: 6px 8px; }

/* Cards */
.card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-title { font-weight: 500; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.card-title i { font-size: 16px; color: var(--text-2); }
.card-meta { font-size: 12px; color: var(--text-3); }
a.card-meta:hover { color: var(--info-text); }

.stat-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}
.stat-label { font-size: 12px; color: var(--text-2); }
.stat-value { font-size: 24px; font-weight: 500; margin-top: 4px; }
.stat-trend { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* Grid */
.grid { display: grid; gap: 12px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-overview { grid-template-columns: 2fr 1fr; }

/* Pills */
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 2px 8px;
  border-radius: 12px; font-weight: 500;
  background: var(--surface-2); color: var(--text-2);
}
.pill-success { background: var(--success-bg); color: var(--success-text); }
.pill-warning { background: var(--warning-bg); color: var(--warning-text); }
.pill-danger { background: var(--danger-bg); color: var(--danger-text); }
.pill-info { background: var(--info-bg); color: var(--info-text); }
.pill-purple { background: var(--purple-bg); color: var(--purple-text); }
.pill-pink { background: var(--pink-bg); color: var(--pink-text); }
.pill-teal { background: var(--teal-bg); color: var(--teal-text); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-success { background: var(--success); }
.dot-warning { background: var(--warning); }
.dot-danger { background: var(--danger); }
.dot-muted { background: var(--text-3); }

/* Table */
.ptable { width: 100%; border-collapse: collapse; font-size: 13px; }
.ptable thead th {
  text-align: left; font-weight: 500; font-size: 11px;
  color: var(--text-2); padding: 8px 12px;
  background: var(--surface-2); border-bottom: 0.5px solid var(--border);
}
.ptable thead th:first-child { border-top-left-radius: var(--radius); }
.ptable thead th:last-child { border-top-right-radius: var(--radius); }
.ptable tbody td { padding: 10px 12px; border-bottom: 0.5px solid var(--border); vertical-align: middle; }
.ptable tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.ptable tbody tr.row-danger td { background: var(--danger-bg); }
.ptable .proj-name { font-weight: 500; }
.ptable .proj-meta { font-size: 11px; color: var(--text-3); margin-top: 1px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; font-size: 11px; color: var(--text-2);
  padding: 8px 12px; background: var(--surface-2);
  font-weight: 500; border-bottom: 0.5px solid var(--border);
}
.data-table td { padding: 9px 12px; border-bottom: 0.5px solid var(--border); }
.data-table tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Progress */
.progress { background: var(--surface-2); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--info); transition: width 0.3s; }
.progress-bar.warn { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

/* Mail */
.mail-layout {
  display: grid;
  grid-template-columns: 220px 340px 1fr;
  gap: 12px;
  height: calc(100vh - 56px - 48px - 24px);
}
.mail-folders {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius-lg); overflow-y: auto; padding: 8px;
}
.mail-folder {
  padding: 7px 10px; display: flex; align-items: center; gap: 8px;
  border-radius: var(--radius); cursor: pointer; font-size: 13px; text-decoration: none; color: var(--text);
}
.mail-folder:hover { background: var(--surface-2); color: var(--text); }
.mail-folder.active { background: var(--surface-2); font-weight: 500; }
.mail-folder i { font-size: 15px; color: var(--text-2); }
.mail-folder .count { margin-left: auto; font-size: 11px; color: var(--text-3); }
.mail-folder .count.has { color: var(--text); font-weight: 500; }
.mail-section-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-3); padding: 12px 10px 4px; font-weight: 500;
}
.mail-list {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius-lg); overflow-y: auto;
}
.mail-list-header {
  padding: 10px 14px; border-bottom: 0.5px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; font-size: 13px;
}
.mail-item { padding: 12px 14px; border-bottom: 0.5px solid var(--border); cursor: pointer; position: relative; text-decoration: none; display: block; color: var(--text); }
.mail-item:hover { background: var(--surface-2); }
.mail-item.unread::before {
  content: ''; position: absolute; left: 4px; top: 50%;
  width: 4px; height: 4px; background: var(--info); border-radius: 50%; transform: translateY(-50%);
}
.mail-item.unread .mail-from, .mail-item.unread .mail-subject { font-weight: 500; }
.mail-item.selected { background: var(--info-bg); }
.mail-item-top { display: flex; justify-content: space-between; margin-bottom: 2px; }
.mail-from { font-size: 13px; }
.mail-time { font-size: 11px; color: var(--text-3); }
.mail-subject { font-size: 13px; margin-bottom: 2px; }
.mail-preview { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-tag-row { margin-top: 6px; display: flex; gap: 4px; }
.mail-reader {
  background: var(--surface); border: 0.5px solid var(--border);
  border-radius: var(--radius-lg); display: flex; flex-direction: column; overflow: hidden;
}
.mail-reader-header { padding: 16px 18px; border-bottom: 0.5px solid var(--border); }
.mail-reader-subject { font-size: 16px; font-weight: 500; margin-bottom: 8px; }
.mail-reader-meta { display: flex; gap: 12px; align-items: center; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.mail-reader-body { padding: 16px 18px; flex: 1; overflow-y: auto; font-size: 13.5px; line-height: 1.65; }

/* Project detail */
.proj-hero { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.proj-hero-title { display: flex; align-items: center; gap: 12px; }
.proj-hero-actions { display: flex; gap: 8px; }
.sub-tabs { display: flex; gap: 4px; border-bottom: 0.5px solid var(--border); margin-bottom: 18px; }
.sub-tab {
  padding: 9px 14px; font-size: 13px; color: var(--text-2); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none;
}
.sub-tab:hover { color: var(--text); }
.sub-tab.active { color: var(--text); border-bottom-color: var(--text); font-weight: 500; }

.proc-list { display: flex; flex-direction: column; gap: 8px; }
.proc-row {
  display: grid; grid-template-columns: 24px 2fr 1fr 1fr 1fr 1fr;
  gap: 12px; padding: 10px 12px; background: var(--surface-2);
  border-radius: var(--radius); align-items: center; font-size: 13px;
}
.proc-row .name { font-weight: 500; font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12.5px; }
.proc-row .meta { font-size: 11px; color: var(--text-3); }

/* Alert rows */
.alert-row {
  display: flex; gap: 10px; padding: 10px 12px;
  border-bottom: 0.5px solid var(--border); align-items: flex-start; font-size: 13px;
}
.alert-row:last-child { border-bottom: none; }
.alert-row i { font-size: 16px; margin-top: 1px; }
.alert-row .alert-title { font-weight: 500; font-size: 13px; }
.alert-row .alert-desc { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.alert-row .alert-time { margin-left: auto; font-size: 11px; color: var(--text-3); flex-shrink: 0; }

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.form-input, .form-select, .form-textarea {
  width: 100%; border: 0.5px solid var(--border-strong);
  border-radius: var(--radius); padding: 8px 10px;
  font-family: inherit; font-size: 13px; background: var(--surface); color: var(--text);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--info); box-shadow: 0 0 0 2px rgba(24,95,165,0.1);
}
.form-textarea { resize: vertical; min-height: 90px; }

/* Helpers */
.strong { font-weight: 500; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 16px; }
.gap-2 { display: flex; gap: 8px; align-items: center; }
.gap-3 { display: flex; gap: 12px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; gap: 8px; }
.text-success { color: var(--success-text); }
.text-danger { color: var(--danger-text); }
.text-warning { color: var(--warning-text); }
.nowrap { white-space: nowrap; }

.logo { width: 28px; height: 28px; background: var(--text); color: var(--surface); border-radius: 6px; display: grid; place-items: center; font-weight: 500; font-size: 13px; }
