:root {
  --background: #ffffff;
  --foreground: #222222;
  --card: #ffffff;
  --card-foreground: #222222;
  --primary: #181e25;
  --primary-foreground: #ffffff;
  --secondary: #f5f5f5;
  --secondary-foreground: #333333;
  --muted: #f5f5f5;
  --muted-foreground: #45515e;
  --accent: #f5f5f5;
  --accent-foreground: #18181b;
  --destructive: #ef4444;
  --border: #e5e5e5;
  --input: #e5e5e5;
  --ring: #3b82f6;
  --brand-blue: #1456f0;
  --brand-blue-bg: #edf4ff;
  --success-bg: #ecfdf5;
  --success-text: #047857;
  --warning-bg: #fffbeb;
  --warning-text: #b45309;
  --danger-bg: #fff1f2;
  --danger-text: #be123c;
  --bg-base: #fff9fb;
  --bg-gradient-start: #fff8fa;
  --bg-gradient-end: #f4f8ff;
  --dot-color: rgba(20, 86, 240, 0.12);
  --shadow-card: 0 8px 24px rgba(24, 40, 72, 0.07);
  --shadow-button: 0 4px 10px rgba(24, 30, 37, 0.12);
  --shadow-button-outline: 0 4px 6px rgba(0, 0, 0, 0.04);
  --shadow-input: 0 2px 4px rgba(0, 0, 0, 0.03);
  --shadow-nav: 0 0 22.576px rgba(44, 74, 116, 0.09);
  --shadow-login: 0 28px 80px rgba(15, 23, 42, 0.12), 0 10px 28px rgba(44, 30, 116, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg-base);
  background-image:
    radial-gradient(var(--dot-color) 1px, transparent 1px),
    linear-gradient(145deg, var(--bg-gradient-start) 0%, var(--background) 48%, var(--bg-gradient-end) 100%);
  background-position: 0 0, center;
  background-size: 12px 12px, cover;
  color: var(--foreground);
  font-family: "SF Pro Display", "SF Pro Text", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  border: 0;
  border-radius: 13px;
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 8px 16px;
  box-shadow: var(--shadow-button);
  cursor: pointer;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

button:hover {
  background: #2a323d;
}

button:active {
  transform: translateY(1px);
}

button.secondary {
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  box-shadow: var(--shadow-button-outline);
}

button.secondary:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

button.danger {
  background: var(--destructive);
  color: #ffffff;
  box-shadow: none;
}

button.danger:hover {
  background: #dc2626;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--input);
  border-radius: 13px;
  background: var(--background);
  color: var(--foreground);
  padding: 9px 12px;
  box-shadow: var(--shadow-input);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input,
select {
  min-height: 40px;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-foreground);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 500;
}

label + label,
.form-row + label,
label + .form-row {
  margin-top: 12px;
}

#app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar.hidden + .main {
  grid-column: 1 / -1;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-nav);
  backdrop-filter: blur(12px);
  padding: 24px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 10px 28px;
  color: var(--foreground);
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: var(--shadow-button-outline);
}

.brand strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.brand span {
  display: block;
  color: var(--muted-foreground);
  font-size: 12px;
  margin-top: 2px;
}

nav {
  display: grid;
  gap: 6px;
}

.nav-button {
  width: 100%;
  justify-content: flex-start;
  min-height: 38px;
  border-radius: 9999px;
  background: transparent;
  color: var(--muted-foreground);
  box-shadow: none;
  text-align: left;
}

.nav-button span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 9999px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 700;
}

.nav-button:hover,
.nav-button.active {
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.nav-button:hover span,
.nav-button.active span {
  background: rgba(255, 255, 255, 0.18);
  color: var(--primary-foreground);
}

.main {
  min-width: 0;
}

.workspace {
  width: min(100%, 1480px);
  margin: 0 auto;
  padding: 32px 36px;
}

.topbar {
  position: sticky;
  top: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-nav);
  backdrop-filter: blur(12px);
  padding: 14px 18px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
  margin-bottom: 16px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted-foreground);
}

.panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow-card);
  padding: 22px;
}

.compact {
  width: min(100%, 390px);
  border-radius: 32px;
  padding: 40px;
  text-align: center;
  box-shadow: var(--shadow-login);
}

.login-panel {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-logo {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: 16px;
  object-fit: cover;
}

.login-panel h1 {
  margin-bottom: 8px;
}

.login-subtitle {
  margin: 0 0 24px;
  color: var(--muted-foreground);
}

.login-panel button {
  width: 100%;
}

.passport-button {
  margin-bottom: 14px;
}

.split {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.split.wide {
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
}

.split.stacked,
.split.wide.stacked {
  grid-template-columns: 1fr;
}

.split.stacked > form {
  max-width: 560px;
}

.split.wide.stacked > form {
  max-width: 720px;
}

#products-view .split.stacked,
#licenses-view .split.stacked,
#customers-view .split.stacked {
  min-height: calc(100vh - 132px);
  grid-template-rows: auto minmax(0, 1fr);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  padding: 18px;
}

.stat span {
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 600;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}

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

.panel-header h2 {
  margin-bottom: 0;
}

.panel-header input {
  max-width: 280px;
}

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

.record-panel {
  min-height: 0;
}

.record-wrap {
  max-height: clamp(240px, calc(100vh - 320px), 760px);
  overflow: auto;
  padding-right: 2px;
}

.record-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
  gap: 14px;
}

.record-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  padding: 18px;
}

.record-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.record-card h3 {
  margin: 0;
  color: var(--foreground);
  font-size: 16px;
  line-height: 1.3;
}

.record-card p {
  margin: 4px 0 0;
  color: var(--muted-foreground);
  font-size: 13px;
}

.record-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.record-meta div {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--muted);
  padding: 10px 12px;
}

.record-meta span,
.record-field span {
  display: block;
  color: var(--muted-foreground);
  font-size: 12px;
  font-weight: 600;
}

.record-meta strong {
  display: block;
  min-width: 0;
  margin-top: 4px;
  overflow: hidden;
  color: var(--foreground);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-field {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.record-field code {
  display: block;
  width: 100%;
  overflow: hidden;
  border-radius: 10px;
  background: var(--muted);
  padding: 9px 10px;
  color: var(--foreground);
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: var(--card);
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

tr:last-child td {
  border-bottom: 0;
}

th {
  background: rgba(245, 245, 245, 0.55);
  color: var(--muted-foreground);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

tbody tr:hover td {
  background: rgba(245, 245, 245, 0.5);
}

td code {
  display: block;
  max-width: 360px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--muted);
  padding: 2px 6px;
  color: var(--foreground);
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 9999px;
  border: 1px solid transparent;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.badge {
  background: var(--brand-blue-bg);
  color: var(--brand-blue);
}

.status.active {
  border-color: #a7f3d0;
  background: var(--success-bg);
  color: var(--success-text);
}

.status.expired {
  border-color: #fde68a;
  background: var(--warning-bg);
  color: var(--warning-text);
}

.status.revoked {
  border-color: #fecdd3;
  background: var(--danger-bg);
  color: var(--danger-text);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.actions button {
  min-height: 32px;
  border-radius: 11px;
  padding: 6px 12px;
  font-size: 13px;
}

.message {
  border: 1px solid #bae6fd;
  border-radius: 12px;
  background: #f0f9ff;
  color: var(--brand-blue);
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}

.message.is-error {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  color: var(--destructive);
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--destructive);
}

.muted {
  color: var(--muted-foreground);
}

.hidden {
  display: none !important;
}

@media (max-width: 1068px) {
  .workspace {
    padding: 24px;
  }

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

@media (max-width: 900px) {
  #app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 16px;
  }

  .sidebar.hidden + .main {
    grid-column: auto;
  }

  nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-button {
    justify-content: center;
    padding: 8px 10px;
  }

  .nav-button span {
    display: none;
  }

  .split,
  .split.wide {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 13px;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .panel-header input {
    width: 100%;
  }

  .topbar-actions button,
  .panel-header input {
    max-width: none;
  }

  nav,
  .form-row,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .compact {
    padding: 32px 24px;
  }

  #products-view .split.stacked,
  #licenses-view .split.stacked,
  #customers-view .split.stacked {
    min-height: 0;
  }

  .record-wrap {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}
