*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-bg: #0f172a;
  --sidebar-width: 220px;
  --sidebar-text: #94a3b8;
  --sidebar-hover: #1e293b;
  --sidebar-active-bg: #1d4ed8;
  --sidebar-active-text: #fff;
  --header-height: 52px;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --warning: #f59e0b;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --white: #fff;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.15);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 13px; color: var(--text); background: var(--bg); display: flex; height: 100vh; overflow: hidden; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-logo {
  padding: 18px 20px 14px;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo .logo-icon {
  width: 30px; height: 30px;
  background: var(--primary);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.sidebar-logo span { color: #e2e8f0; font-size: 14px; font-weight: 600; white-space: nowrap; }

.menu-group { padding: 8px 0; }
.menu-group-title {
  padding: 6px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #475569;
}
.menu-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all .15s;
  font-size: 13px;
  border-left: 3px solid transparent;
}
.menu-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.menu-item.active { background: rgba(37,99,235,.15); color: #60a5fa; border-left-color: #2563eb; }
.menu-item svg { width: 15px; height: 15px; flex-shrink: 0; }

/* ===== MAIN LAYOUT ===== */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.header {
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 12px;
  flex-shrink: 0;
}
.header-title { font-size: 15px; font-weight: 600; color: var(--text); flex: 1; }
.header-subtitle { font-size: 12px; color: var(--text-muted); }

.content { flex: 1; overflow-y: auto; padding: 20px 24px; }

/* ===== CARDS ===== */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card-header h3 { font-size: 14px; font-weight: 600; flex: 1; }
.card-body { padding: 16px 20px; }

/* ===== SEARCH BAR ===== */
.search-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.search-bar .form-input, .search-bar .form-select { height: 32px; width: 180px; }
.search-bar .btn { height: 32px; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: #f8fafc; }
th { padding: 10px 12px; text-align: left; font-weight: 600; color: var(--text-muted); font-size: 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; color: var(--text); vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }
.td-actions { display: flex; gap: 6px; white-space: nowrap; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex; align-items: center; justify-content: flex-end; gap: 6px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted);
}
.pagination span { margin-right: auto; }
.page-btn {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  cursor: pointer;
  color: var(--text);
  font-size: 12px;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-default { background: var(--white); border-color: var(--border); color: var(--text); }
.btn-default:hover { border-color: var(--primary); color: var(--primary); }
.btn-text { background: transparent; border-color: transparent; color: var(--primary); padding: 4px 8px; }
.btn-text:hover { background: #eff6ff; }
.btn-text-danger { background: transparent; border-color: transparent; color: var(--danger); padding: 4px 8px; }
.btn-text-danger:hover { background: #fef2f2; }
.btn svg { width: 14px; height: 14px; }
.btn-sm { padding: 3px 10px; font-size: 12px; }

/* ===== TAGS ===== */
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 500;
}
.tag-active { background: #dcfce7; color: #15803d; }
.tag-inactive { background: #f1f5f9; color: #64748b; }
.tag-success { background: #dcfce7; color: #15803d; }
.tag-warning { background: #fef9c3; color: #a16207; }
.tag-danger { background: #fee2e2; color: #b91c1c; }
.tag-info { background: #dbeafe; color: #1d4ed8; }
.tag-blue { background: #dbeafe; color: #1d4ed8; }
.tag-gray { background: #f1f5f9; color: #64748b; }

/* ===== FORM ===== */
.form-row { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; }
.form-item { display: flex; flex-direction: column; gap: 5px; min-width: 200px; flex: 1; }
.form-item.full { flex: 0 0 100%; }
.form-item.half { flex: 0 0 calc(50% - 8px); min-width: 200px; }
.form-label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.form-label.required::after { content: ' *'; color: var(--danger); }
.form-input, .form-select, .form-textarea {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s;
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,.12);
}
.form-textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 80px; }
.form-select { cursor: pointer; }
.form-hint { font-size: 11px; color: var(--text-muted); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal {
  background: var(--white);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
}
.modal-lg { max-width: 900px; }
.modal-xl { max-width: 1100px; }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.modal-header h3 { font-size: 15px; font-weight: 600; flex: 1; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 4px; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ===== DETAIL PAGE ===== */
.detail-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.detail-header .back-btn { color: var(--text-muted); cursor: pointer; display: flex; align-items: center; gap: 4px; font-size: 13px; }
.detail-header .back-btn:hover { color: var(--primary); }
.detail-title { font-size: 18px; font-weight: 700; }

.desc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0; }
.desc-item { padding: 12px 16px; border-bottom: 1px solid #f1f5f9; }
.desc-item:nth-child(odd) { border-right: 1px solid #f1f5f9; }
.desc-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.desc-value { font-size: 13px; color: var(--text); font-weight: 500; }

.section-title { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: .05em; }

/* ===== INLINE TABLE (for nested items like service_host) ===== */
.inline-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.inline-table th { background: #f8fafc; padding: 7px 10px; font-weight: 600; color: var(--text-muted); border: 1px solid var(--border); font-size: 11px; }
.inline-table td { padding: 7px 10px; border: 1px solid var(--border); }

/* ===== DYNAMIC LIST ===== */
.dynamic-list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.dynamic-list-header {
  background: #f8fafc;
  padding: 8px 12px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--text-muted);
}
.dynamic-list-item {
  padding: 12px;
  border-bottom: 1px solid #f1f5f9;
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start;
}
.dynamic-list-item:last-child { border-bottom: none; }
.dynamic-list-item .form-item { min-width: 140px; }
.remove-btn { color: var(--danger); background: none; border: none; cursor: pointer; padding: 4px; border-radius: 4px; margin-top: 22px; flex-shrink: 0; }
.remove-btn:hover { background: #fee2e2; }

/* ===== MULTI SELECT ===== */
.multi-select-tags {
  min-height: 34px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  cursor: pointer;
  background: var(--white);
  transition: border-color .15s;
}
.multi-select-tags:focus-within { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.12); }
.multi-select-tag { display: flex; align-items: center; gap: 3px; background: #dbeafe; color: #1d4ed8; padding: 1px 6px; border-radius: 4px; font-size: 11px; }
.multi-select-tag button { background: none; border: none; cursor: pointer; color: inherit; line-height: 1; padding: 0 1px; font-size: 13px; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .3; }
.empty-state p { font-size: 14px; }

/* ===== TOAST ===== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  max-width: 320px;
  animation: slideIn .2s ease;
}
.toast-success { background: #166534; color: #fff; }
.toast-error { background: #991b1b; color: #fff; }
.toast-info { background: #1d4ed8; color: #fff; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== CONFIRM DIALOG ===== */
.confirm-dialog {
  background: var(--white);
  border-radius: 8px;
  padding: 24px;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.confirm-dialog h4 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.confirm-dialog p { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.confirm-dialog .actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ===== TABS ===== */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { padding: 10px 16px; cursor: pointer; font-size: 13px; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ===== LOADING ===== */
.loading { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--text-muted); gap: 8px; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== RESPONSIVE ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-header h2 { font-size: 16px; font-weight: 700; }

/* Info box */
.info-box { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--radius); padding: 10px 14px; font-size: 12px; color: #1d4ed8; margin-bottom: 16px; }
