/* SystemInventer — Shadow UI
   Layered neutral elevation (Beautiful sm / md / lg) */

:root {
  --si-bg: #eef1f5;
  --si-surface: #ffffff;
  --si-border: rgba(25, 28, 33, 0.08);
  --si-border-strong: rgba(25, 28, 33, 0.14);
  --si-text: #1c2430;
  --si-text-secondary: #5b6573;
  --si-muted: #8b949e;
  --si-primary: #1e4d7b;
  --si-primary-hover: #163a5c;
  --si-primary-soft: #e8eef4;
  --si-success: #1f6f43;
  --si-success-bg: #e8f5ee;
  --si-warning: #8a6a12;
  --si-warning-bg: #faf3e0;
  --si-danger: #b42318;
  --si-danger-bg: #fdeceb;
  --si-info: #1a5f8a;
  --si-info-bg: #e7f1f7;
  --si-sidebar: #121c2c;
  --si-sidebar-text: #c5ced9;
  --si-sidebar-active: #ffffff;
  --si-radius: 10px;
  --si-radius-sm: 8px;
  --si-font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --si-mono: "IBM Plex Mono", ui-monospace, monospace;
  --si-sidebar-w: 248px;

  /* Beautiful Shadows — neutral layered elevation */
  --shadow-sm:
    0px 2px 3px -1px rgba(0, 0, 0, 0.1),
    0px 1px 0px 0px rgba(25, 28, 33, 0.02),
    0px 0px 0px 1px rgba(25, 28, 33, 0.08);

  --shadow-md:
    0px 0px 0px 1px rgba(0, 0, 0, 0.06),
    0px 1px 1px -0.5px rgba(0, 0, 0, 0.06),
    0px 3px 3px -1.5px rgba(0, 0, 0, 0.06),
    0px 6px 6px -3px rgba(0, 0, 0, 0.06),
    0px 12px 12px -6px rgba(0, 0, 0, 0.06),
    0px 24px 24px -12px rgba(0, 0, 0, 0.06);

  --shadow-lg:
    0 2.8px 2.2px rgba(0, 0, 0, 0.034),
    0 6.7px 5.3px rgba(0, 0, 0, 0.048),
    0 12.5px 10px rgba(0, 0, 0, 0.06),
    0 22.3px 17.9px rgba(0, 0, 0, 0.072),
    0 41.8px 33.4px rgba(0, 0, 0, 0.086),
    0 100px 80px rgba(0, 0, 0, 0.12);

  --shadow-sidebar:
    4px 0 24px -8px rgba(0, 0, 0, 0.28);

  --shadow-topbar:
    0 1px 0 rgba(25, 28, 33, 0.06),
    0 8px 24px -12px rgba(0, 0, 0, 0.08);
}

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

html {
  font-size: 15px;
}

body {
  margin: 0;
  font-family: var(--si-font);
  color: var(--si-text);
  background: var(--si-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--si-primary);
  text-decoration: none;
}

a:hover {
  color: var(--si-primary-hover);
  text-decoration: underline;
}

/* —— Auth —— */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(30, 77, 123, 0.08), transparent 55%),
    linear-gradient(180deg, #e6ebf1 0%, var(--si-bg) 45%, #e8ecf1 100%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--si-surface);
  border: none;
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 2.15rem 1.85rem 1.85rem;
}

.auth-brand {
  margin-bottom: 1.75rem;
}

.auth-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--si-sidebar);
  color: #fff;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.auth-brand h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-brand p {
  margin: 0;
  color: var(--si-text-secondary);
  font-size: 0.9rem;
}

/* —— Shell —— */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--si-sidebar-w);
  flex-shrink: 0;
  background: var(--si-sidebar);
  color: var(--si-sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
  box-shadow: var(--shadow-sidebar);
}

.sidebar-brand {
  padding: 1.35rem 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-brand .mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 7px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.sidebar-brand h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.01em;
}

.sidebar-brand span {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.75rem;
  color: rgba(197, 206, 217, 0.75);
}

.sidebar-nav {
  padding: 1rem 0.75rem;
  flex: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: 7px;
  color: var(--si-sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.15rem;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.sidebar-nav a i {
  font-size: 1.05rem;
  opacity: 0.85;
  width: 1.2rem;
  text-align: center;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  text-decoration: none;
}

.sidebar-nav a.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--si-sidebar-active);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 1px 2px rgba(0, 0, 0, 0.2);
}

.sidebar-footer {
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 0.8rem;
}

.sidebar-footer .user-name {
  color: #fff;
  font-weight: 500;
  margin-bottom: 0.15rem;
}

.sidebar-footer .user-role {
  color: rgba(197, 206, 217, 0.7);
  margin-bottom: 0.65rem;
  word-break: break-all;
}

.sidebar-footer .account-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
  color: var(--si-sidebar-text);
  text-decoration: none;
  font-size: 0.8rem;
}

.sidebar-footer .account-link:hover,
.sidebar-footer .account-link.active {
  color: #fff;
  text-decoration: none;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: none;
  padding: 0.95rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-topbar);
}

.topbar h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.page-content {
  padding: 1.6rem 1.75rem 2.75rem;
  flex: 1;
}

/* —— Cards / panels —— */
.panel {
  background: var(--si-surface);
  border: none;
  border-radius: var(--si-radius);
  box-shadow: var(--shadow-md);
}

.panel-header {
  padding: 0.95rem 1.2rem;
  border-bottom: 1px solid rgba(25, 28, 33, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.panel-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.panel-body {
  padding: 1.2rem;
}

.panel-body.p-0 {
  padding: 0;
}

/* —— Stats —— */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.35rem;
}

.stat-card {
  background: var(--si-surface);
  border: none;
  border-radius: var(--si-radius);
  padding: 1.15rem 1.2rem;
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.stat-card .label {
  font-size: 0.8rem;
  color: var(--si-text-secondary);
  margin-bottom: 0.35rem;
}

.stat-card .value {
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--si-text);
}

.stat-card .meta {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--si-muted);
}

/* —— Forms —— */
.form-label {
  font-size: 0.8rem;
  font-weight: 550;
  color: var(--si-text-secondary);
  margin-bottom: 0.3rem;
}

.form-control,
.form-select {
  border: none;
  border-radius: var(--si-radius-sm);
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
  color: var(--si-text);
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: transparent;
  box-shadow:
    0 0 0 3px rgba(30, 77, 123, 0.14),
    var(--shadow-sm);
}

.form-control::placeholder {
  color: var(--si-muted);
}

.form-text {
  color: var(--si-muted);
  font-size: 0.75rem;
}

.form-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--si-text-secondary);
  letter-spacing: 0.02em;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(25, 28, 33, 0.06);
}

.form-check-input {
  box-shadow: var(--shadow-sm);
  border: none;
}

.form-check-input:checked {
  background-color: var(--si-primary);
  border-color: var(--si-primary);
}

/* —— Buttons —— */
.btn {
  border-radius: var(--si-radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.48rem 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  line-height: 1.4;
  transition: box-shadow 0.15s ease, transform 0.12s ease, background 0.15s ease;
}

.btn-primary {
  background: var(--si-primary);
  border-color: transparent;
  color: #fff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 1px 2px rgba(22, 58, 92, 0.35),
    0 4px 10px -4px rgba(22, 58, 92, 0.45);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--si-primary-hover);
  border-color: transparent;
  color: #fff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.1) inset,
    0 2px 4px rgba(22, 58, 92, 0.35),
    0 8px 16px -6px rgba(22, 58, 92, 0.5);
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow: var(--shadow-sm);
}

.btn-outline-secondary {
  border: none;
  color: var(--si-text-secondary);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-outline-secondary:hover {
  background: #fafbfc;
  border-color: transparent;
  color: var(--si-text);
  box-shadow: var(--shadow-md);
}

.btn-outline-danger {
  border: none;
  color: var(--si-danger);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-outline-danger:hover {
  background: var(--si-danger-bg);
  border-color: transparent;
  color: var(--si-danger);
  box-shadow: var(--shadow-md);
}

.btn-sm {
  padding: 0.32rem 0.7rem;
  font-size: 0.8rem;
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--si-sidebar-text);
  padding: 0;
  font-size: 0.8rem;
  box-shadow: none;
}

.btn-ghost:hover {
  color: #fff;
  text-decoration: underline;
  box-shadow: none;
}

/* —— Tables —— */
.table-si {
  margin: 0;
  font-size: 0.875rem;
}

.table-si thead th {
  background: #f7f8fa;
  border-bottom: 1px solid rgba(25, 28, 33, 0.06);
  color: var(--si-text-secondary);
  font-weight: 550;
  font-size: 0.75rem;
  letter-spacing: 0.01em;
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

.table-si tbody td {
  padding: 0.8rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid rgba(25, 28, 33, 0.05);
  color: var(--si-text);
}

.table-si tbody tr:last-child td {
  border-bottom: none;
}

.table-si tbody tr:hover td {
  background: #fafbfc;
}

.table-si .mono {
  font-family: var(--si-mono);
  font-size: 0.82rem;
}

.table-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
}

/* —— Badges —— */
.badge-status {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.58rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 550;
  line-height: 1.3;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(25, 28, 33, 0.04);
}

.badge-status-success { background: var(--si-success-bg); color: var(--si-success); }
.badge-status-neutral { background: #eef0f3; color: #4d5663; }
.badge-status-warning { background: var(--si-warning-bg); color: var(--si-warning); }
.badge-status-info    { background: var(--si-info-bg); color: var(--si-info); }
.badge-status-danger  { background: var(--si-danger-bg); color: var(--si-danger); }

.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--si-text-secondary);
  font-size: 0.85rem;
}

.type-chip i {
  color: var(--si-primary);
}

/* —— Alerts —— */
.alert {
  border-radius: var(--si-radius-sm);
  border: none;
  font-size: 0.875rem;
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow-sm);
}

.alert-success {
  background: var(--si-success-bg);
  color: var(--si-success);
}

.alert-danger {
  background: var(--si-danger-bg);
  color: var(--si-danger);
}

.alert-info {
  background: var(--si-info-bg);
  color: var(--si-info);
}

/* —— Filters —— */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: flex-end;
}

.filters-bar .field {
  flex: 1;
  min-width: 140px;
}

.filters-bar .field-search {
  flex: 2;
  min-width: 200px;
}

.filters-bar .field-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 0.45rem;
}

/* —— Detail —— */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem 2rem;
}

.detail-item dt {
  font-size: 0.75rem;
  color: var(--si-muted);
  margin-bottom: 0.15rem;
  font-weight: 500;
}

.detail-item dd {
  margin: 0;
  font-size: 0.925rem;
  color: var(--si-text);
}

.page-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: 3.25rem 1.5rem;
  color: var(--si-text-secondary);
}

.empty-state i {
  font-size: 2rem;
  color: var(--si-muted);
  margin-bottom: 0.75rem;
  display: block;
}

.empty-state h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--si-text);
  margin: 0 0 0.35rem;
}

.empty-state p {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
}

.pagination {
  margin: 0;
  gap: 0.3rem;
}

.page-link {
  border-radius: 7px !important;
  border: none !important;
  color: var(--si-text-secondary);
  font-size: 0.8rem;
  padding: 0.38rem 0.7rem;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.page-link:hover {
  background: #fafbfc;
  color: var(--si-text);
  box-shadow: var(--shadow-md);
}

.page-item.active .page-link {
  background: var(--si-primary);
  color: #fff;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 2px 6px rgba(22, 58, 92, 0.35);
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline li {
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(25, 28, 33, 0.06);
  font-size: 0.85rem;
}

.timeline li:last-child {
  border-bottom: none;
}

.timeline .time {
  color: var(--si-muted);
  font-size: 0.75rem;
}

.mobile-toggle {
  display: none;
  background: #fff;
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  color: var(--si-text);
  box-shadow: var(--shadow-sm);
}

.mobile-toggle:hover {
  box-shadow: var(--shadow-md);
}

@media (max-width: 1100px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-toggle {
    display: inline-flex;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .page-content,
  .topbar {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}

@media (max-width: 560px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stat-card,
  .btn,
  .sidebar-nav a,
  .form-control,
  .form-select {
    transition: none;
  }

  .stat-card:hover {
    transform: none;
  }
}
