:root {
  --bg: #f3f6fb;
  --sidebar: #0f1b2d;
  --sidebar-soft: #1f2f49;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --line: #dde4ef;
  --text: #132238;
  --muted: #5b6b80;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success-soft: #dcfce7;
  --danger-soft: #fee2e2;
  --info-soft: #dbeafe;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar), #12233d);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 0 6px rgba(56, 189, 248, 0.2);
}

.sidebar-brand h2 {
  margin: 0;
  color: #ffffff;
  font-size: 1.05rem;
}

.sidebar-brand p {
  margin: 2px 0 0;
  color: #b5c7df;
  font-size: 0.82rem;
}

.sidebar-nav {
  display: grid;
  gap: 8px;
}

.sidebar-nav a,
.logout-link {
  text-decoration: none;
  color: #c9d7ea;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.92rem;
  border: 1px solid transparent;
  transition: 0.2s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active,
.logout-link:hover {
  color: #ffffff;
  background: var(--sidebar-soft);
  border-color: rgba(255, 255, 255, 0.1);
}

.logout-link {
  margin-top: auto;
}

.main-area {
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.4rem;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.content-area {
  padding: 24px;
}

.alert {
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert-success {
  background: #ecfdf3;
  border-color: #bbf7d0;
  color: #166534;
}

.alert-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}

.form-panel {
  max-width: 980px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h3 {
  margin: 0;
  font-size: 1.15rem;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.filters-bar {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: #f8fbff;
  margin-bottom: 14px;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.filter-action .btn {
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

thead {
  background: var(--surface-soft);
}

th,
td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid #e8edf5;
  font-size: 0.9rem;
}

th {
  color: #334155;
  font-weight: 700;
}

tbody tr:hover {
  background: #fbfdff;
}

.actions {
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.inline-form {
  display: inline;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s ease;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-outline {
  border-color: var(--line);
  color: #334155;
  background: #ffffff;
}

.btn-outline:hover {
  background: #f8fafc;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
  margin-right: 6px;
}

.btn-view {
  color: #1d4ed8;
  background: var(--info-soft);
}

.btn-edit {
  color: #166534;
  background: var(--success-soft);
}

.btn-delete {
  color: #b91c1c;
  background: var(--danger-soft);
}

.btn-ghost {
  background: #f1f5f9;
  color: #1e293b;
}

.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.btn-page {
  background: #eef2f8;
  color: #334155;
  padding: 7px 12px;
}

.btn-page.active {
  background: #dbeafe;
  color: #1d4ed8;
}

.kb-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field-full {
  grid-column: 1 / -1;
}

.field-half {
  max-width: 420px;
}

.dimension-inline {
  align-content: end;
}

.dimension-inline-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.layered-title {
  margin: 0 0 12px;
  font-size: 1rem;
  color: #1e293b;
}

.layered-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  font-size: 0.88rem;
  font-weight: 700;
  color: #334155;
}

.field-error {
  color: #b91c1c;
  font-size: 0.8rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d1d9e6;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  color: var(--text);
  background: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.sub-panel {
  margin: 0;
  padding: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.detail-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}

.detail-card strong {
  font-size: 0.82rem;
  color: var(--muted);
}

.detail-card span {
  line-height: 1.5;
  word-break: break-word;
}

.detail-card-full {
  grid-column: 1 / -1;
}

.empty-state {
  text-align: center;
  color: var(--muted);
}

.disabled {
  opacity: 0.55;
  pointer-events: none;
}

.layered-details {
  margin-top: 16px;
}

.product-filters-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.login-body {
  min-height: 100vh;
  background: linear-gradient(145deg, #0f172a, #1e3a5f);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-wrap {
  width: 100%;
  max-width: 460px;
}

.login-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 26px;
  box-shadow: 0 20px 45px rgba(4, 15, 30, 0.35);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.login-brand h1 {
  margin: 0;
  font-size: 1.2rem;
}

.login-brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.login-card h2 {
  margin: 0;
  font-size: 1.25rem;
}

.login-subtitle {
  margin: 6px 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-form {
  display: grid;
  gap: 8px;
}

.login-form .btn {
  margin-top: 6px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding-bottom: 12px;
  }

  .logout-link {
    margin-top: 12px;
  }

  .kb-form {
    grid-template-columns: 1fr;
  }

  .dimension-inline-grid {
    grid-template-columns: 1fr;
  }

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

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

  .filters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .product-filters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar,
  .content-area {
    padding: 16px;
  }
}

@media (max-width: 600px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-head .btn {
    width: 100%;
  }

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

  .product-filters-grid {
    grid-template-columns: 1fr;
  }
}
