/* Nexus - modern white theme, class-based, no preprocessor. */

:root {
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-surface-2: #f7f8fa;
  --color-surface-3: #eef1f5;
  --color-border: #e3e6ec;
  --color-border-strong: #cdd3dd;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-text-subtle: #94a3b8;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-soft: #eff4ff;
  --color-danger: #dc2626;
  --color-danger-soft: #fef2f2;
  --color-success: #059669;
  --color-success-soft: #ecfdf5;
  --color-warning: #d97706;
  --color-warning-soft: #fffbeb;

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

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 2px 6px rgba(15, 23, 42, 0.06);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --nav-h: 56px;
  --side-w: 220px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
.muted { color: var(--color-text-muted); }
.inline { display: inline; }

/* Layout shell ---------------------------------------------------------- */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-h);
  padding: 0 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.navbar-left { display: flex; align-items: center; gap: 10px; }
.navbar-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--color-accent), #60a5fa);
}
.navbar-title { font-weight: 600; font-size: 15px; }
.navbar-right { display: flex; align-items: center; gap: 12px; }
.navbar-search { width: 280px; }

.app-shell {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  min-height: calc(100vh - var(--nav-h));
}

.sidebar {
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 0;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; padding: 0 8px; }
.sidebar-link {
  display: block;
  padding: 8px 12px; border-radius: var(--radius-md);
  color: var(--color-text);
  font-weight: 500;
  cursor: pointer;
}
.sidebar-link:hover { background: var(--color-surface-2); text-decoration: none; }
.sidebar-link.is-active { background: var(--color-accent-soft); color: var(--color-accent); }
.sidebar-link.is-disabled { color: var(--color-text-subtle); pointer-events: none; }

.main { padding: 24px 28px; }

/* Page header ----------------------------------------------------------- */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 20px;
}
.page-title { font-size: 22px; }
.page-sub { color: var(--color-text-muted); font-size: 13px; margin-top: 2px; }
.section { margin-top: 28px; }
.section-title { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); margin-bottom: 10px; }

/* Grid ------------------------------------------------------------------ */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* Buttons --------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 500; font-family: inherit;
  cursor: pointer;
  transition: background-color 120ms, border-color 120ms, color 120ms;
  text-decoration: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-md { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 10px 18px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-accent-hover); }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover:not(:disabled) { background: var(--color-surface-2); }
.btn-ghost { background: transparent; color: var(--color-text); }
.btn-ghost:hover:not(:disabled) { background: var(--color-surface-2); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-icon { display: inline-flex; }

/* Forms ----------------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-actions { margin-top: 4px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; font-weight: 500; color: var(--color-text); }
.field-label .req { color: var(--color-danger); }
.field-hint { font-size: 12px; color: var(--color-text-muted); }
.field-msg { font-size: 12px; color: var(--color-danger); }
.field-error .input, .field-error .select, .field-error .textarea { border-color: var(--color-danger); }

.input, .select, .textarea {
  font-family: inherit; font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  width: 100%;
  transition: border-color 120ms, box-shadow 120ms;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}
.textarea { resize: vertical; }

/* Search bar ------------------------------------------------------------ */
.search-bar {
  position: relative; display: flex; align-items: center;
}
.search-icon {
  position: absolute; left: 10px;
  color: var(--color-text-subtle); font-family: var(--font-mono); font-size: 12px;
  pointer-events: none;
}
.search-input {
  width: 100%; padding: 7px 10px 7px 28px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  font-family: inherit; font-size: 13px;
}
.search-input:focus { outline: none; border-color: var(--color-accent); background: var(--color-surface); }

/* Combobox -------------------------------------------------------------- */
.combobox { position: relative; }
.combobox-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 7px 10px;
  background: var(--color-surface); border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font-family: inherit; font-size: 13px;
  cursor: pointer;
}
.combobox-search-input { flex: 1; border: 0; outline: none; font-size: 13px; font-family: inherit; background: transparent; }
.combobox-caret { color: var(--color-text-muted); font-size: 11px; }
.combobox-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 240px; overflow-y: auto;
  list-style: none;
  z-index: 30;
}
.combobox-option { padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; }
.combobox-option:hover, .combobox-option.is-highlight { background: var(--color-accent-soft); color: var(--color-accent); }

/* Card ------------------------------------------------------------------ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-head { padding: 12px 16px; border-bottom: 1px solid var(--color-border); }
.card-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); }
.card-body { padding: 16px; }
.card-text { font-size: 20px; font-weight: 600; }
.card-foot { padding: 10px 16px; background: var(--color-surface-2); font-size: 12px; }

/* Modal ----------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  width: min(560px, 92vw);
  max-height: 88vh;
  display: flex; flex-direction: column;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--color-border); }
.modal-title { font-size: 16px; }
.modal-close { background: transparent; border: 0; font-size: 18px; cursor: pointer; color: var(--color-text-muted); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: 8px; }

/* Badge / Avatar -------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  font-size: 11px; font-weight: 600;
  border-radius: 999px;
  border: 1px solid transparent;
}
.badge-neutral { background: var(--color-surface-3); color: var(--color-text); }
.badge-soft    { background: var(--color-accent-soft); color: var(--color-accent); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-soft); color: var(--color-danger); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--color-accent-soft); color: var(--color-accent);
  font-weight: 600; text-transform: uppercase;
  border-radius: 999px; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 24px; height: 24px; font-size: 11px; }
.avatar-md { width: 32px; height: 32px; font-size: 12px; }
.avatar-lg { width: 44px; height: 44px; font-size: 14px; }

/* Table ----------------------------------------------------------------- */
.table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--color-border); }
.table thead th { font-weight: 600; color: var(--color-text-muted); background: var(--color-surface-2); }
.table tbody tr:hover { background: var(--color-surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table-empty { padding: 24px; text-align: center; color: var(--color-text-muted); }

/* Calendar -------------------------------------------------------------- */
.calendar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 12px;
  width: max-content;
}
.calendar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.calendar-title { font-weight: 600; }
.calendar-nav { background: transparent; border: 0; cursor: pointer; padding: 4px 8px; color: var(--color-text-muted); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 32px); gap: 4px; }
.calendar-dow { text-align: center; font-size: 11px; color: var(--color-text-muted); padding: 4px 0; }
.calendar-day {
  width: 32px; height: 32px;
  background: transparent; border: 0;
  border-radius: var(--radius-md);
  font-size: 12px; font-family: inherit; cursor: pointer;
}
.calendar-day:hover { background: var(--color-surface-2); }
.calendar-day.is-out { color: var(--color-text-subtle); }
.calendar-day.is-today { border: 1px solid var(--color-accent); color: var(--color-accent); }
.calendar-day.is-selected { background: var(--color-accent); color: #fff; }

/* Accordion ------------------------------------------------------------- */
.accordion { display: flex; flex-direction: column; gap: 6px; }
.accordion-item { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.accordion-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; cursor: pointer; font-weight: 500; list-style: none; }
.accordion-head::-webkit-details-marker { display: none; }
.accordion-caret { color: var(--color-text-muted); font-size: 11px; transition: transform 120ms; }
.accordion-item[open] .accordion-caret { transform: rotate(180deg); }
.accordion-body { padding: 0 14px 14px; color: var(--color-text-muted); font-size: 13px; }

/* Popup / dropdown ------------------------------------------------------ */
.popup-wrap { position: relative; display: inline-block; }
.popup-trigger {
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; padding: 2px;
  border-radius: 999px; cursor: pointer;
}
.popup-trigger:hover { background: var(--color-surface-2); }
.popup-trigger[aria-expanded="true"] { background: var(--color-surface-3); }
.profile-trigger { padding: 2px; }

.popup {
  position: absolute; top: calc(100% + 8px);
  min-width: 220px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.10);
  padding: 6px;
  z-index: 60;
}
.popup-right { right: 0; }
.popup-left  { left: 0; }
.popup[hidden] { display: none; }

.popup-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px 8px;
}
.popup-id { min-width: 0; }
.popup-name { font-weight: 600; font-size: 13px; }
.popup-mail { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.popup-divider { height: 1px; background: var(--color-border); margin: 4px 0; }

.popup-body { display: flex; flex-direction: column; gap: 2px; }
.popup-form { margin: 0; }
.popup-item {
  display: block; width: 100%; text-align: left;
  padding: 8px 10px;
  background: transparent; border: 0;
  border-radius: var(--radius-md);
  font-family: inherit; font-size: 13px; color: var(--color-text);
  cursor: pointer;
  text-decoration: none;
}
.popup-item:hover { background: var(--color-surface-2); text-decoration: none; }
.popup-item.is-disabled { color: var(--color-text-subtle); pointer-events: none; }
.popup-item-danger { color: var(--color-danger); }
.popup-item-danger:hover { background: var(--color-danger-soft); }

/* Toast ----------------------------------------------------------------- */
.toast {
  position: fixed; right: 20px; bottom: 20px;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 120;
}
.toast-success { border-color: var(--color-success); }
.toast-danger  { border-color: var(--color-danger); }
.toast-close { background: transparent; border: 0; cursor: pointer; color: var(--color-text-muted); }

/* Pagination ------------------------------------------------------------ */
.pagination { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.pagination-btn {
  padding: 6px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-md);
  color: var(--color-text); background: var(--color-surface);
}
.pagination-btn.is-disabled { color: var(--color-text-subtle); pointer-events: none; background: var(--color-surface-2); }
.pagination-info { color: var(--color-text-muted); font-size: 13px; }

/* Alerts ---------------------------------------------------------------- */
.alert { padding: 10px 14px; border-radius: var(--radius-md); font-size: 13px; border: 1px solid transparent; margin-bottom: 12px; }
.alert-error { background: var(--color-danger-soft); border-color: #fecaca; color: var(--color-danger); }
.alert-info { background: var(--color-accent-soft); border-color: #bfdbfe; color: var(--color-accent); }

/* Login screen ---------------------------------------------------------- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 0% -10%, var(--color-accent-soft), transparent 60%),
    radial-gradient(900px 500px at 100% 110%, #f0f7ff, transparent 55%),
    var(--color-bg);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 28px;
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 22px; }
.login-mark { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--color-accent), #60a5fa); }
.login-title { font-size: 18px; }
.login-sub { color: var(--color-text-muted); font-size: 13px; }

/* LPU detail page ------------------------------------------------------- */
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12px; }
.alert-warning { background: var(--color-warning-soft); border-color: #fde68a; color: var(--color-warning); }
.alert-danger  { background: var(--color-danger-soft); border-color: #fecaca; color: var(--color-danger); }

.lpu-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 14px 16px; margin-bottom: 16px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}
.lpu-header-main { display: flex; align-items: center; gap: 12px; }
.lpu-id-badge { padding: 4px 10px; font-size: 13px; letter-spacing: 0.04em; }
.lpu-hostname { font-size: 18px; margin: 0; }
.lpu-header-meta { display: flex; gap: 18px; flex-wrap: wrap; }

.kv-inline { display: flex; flex-direction: column; gap: 2px; min-width: 120px; }
.kv-inline .kv-key { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); }
.kv-inline .kv-val { font-size: 13px; }
.kv-inline-row { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 4px; }

.status-pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
}
.status-pill.status-online  { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.status-pill.status-offline { background: rgba(148, 163, 184, 0.18); color: #94a3b8; }

.status-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 999px; margin-right: 6px; vertical-align: middle;
}
.status-dot.status-online  { background: #10b981; }
.status-dot.status-offline { background: #94a3b8; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.section-actions { display: flex; align-items: center; gap: 8px; }

.facts-panel { display: flex; flex-direction: column; gap: 12px; }
.facts-meta { font-size: 12px; }
.facts-meta .dot { padding: 0 6px; }
.facts-grid { gap: 12px; }
.facts-cell {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 10px 12px;
}
.facts-cell-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--color-text-muted); margin-bottom: 6px; }
.facts-cell-body { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.facts-disks { padding: 0; overflow: hidden; }
.facts-disks .facts-cell-title { padding: 10px 12px 6px; }

.kv { display: flex; justify-content: space-between; gap: 12px; }
.kv .kv-key { color: var(--color-text-muted); font-size: 12px; }
.kv .kv-val { font-size: 13px; text-align: right; word-break: break-word; }

.kv-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.kv-list li { display: flex; gap: 8px; font-size: 12px; }
.kv-list .kv-key { color: var(--color-text-muted); min-width: 80px; }

.table-compact th, .table-compact td { padding: 6px 12px; font-size: 12px; }

.row-actions { display: flex; gap: 6px; }
.inline-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.select-sm { padding: 4px 8px; font-size: 12px; }

.device-form-card { margin-bottom: 12px; }
.device-form { display: flex; flex-direction: column; gap: 12px; }
.form-actions { display: flex; gap: 8px; }

.device-type-form .card-foot { display: flex; gap: 8px; justify-content: flex-end; }
.device-type-form .field-hint code { background: var(--color-surface-2); padding: 1px 4px; border-radius: 3px; font-size: 11px; }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }
