/* ============================================================
   License Manager — Main Stylesheet
   Minimalistic corporate: black/white/gray + red highlights
   ============================================================ */

:root {
  --black:     #0d0d0d;
  --white:     #ffffff;
  --gray-50:   #fafafa;
  --gray-100:  #f4f4f4;
  --gray-200:  #e8e8e8;
  --gray-300:  #d0d0d0;
  --gray-400:  #a8a8a8;
  --gray-500:  #737373;
  --gray-700:  #404040;
  --gray-900:  #1a1a1a;

  --red:       #dc2626;
  --red-dark:  #b91c1c;
  --red-light: #fef2f2;
  --red-mid:   #fee2e2;

  --green:     #16a34a;
  --green-light: #f0fdf4;
  --amber:     #d97706;
  --amber-light: #fffbeb;

  --sidebar-w: 240px;
  --header-h:  56px;
  --radius:    4px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--black);
  background: var(--gray-100);
  height: 100%;
}
a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-dark); text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ── Layout ── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--black);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
  color: var(--white);
}
.sidebar-brand:hover { color: var(--white); text-decoration: none; }
.sidebar-brand svg { flex-shrink: 0; }
.brand-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.3;
}
.brand-sub {
  font-size: 11px;
  color: var(--gray-400);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section {
  padding: 16px 20px 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gray-500);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  color: rgba(255,255,255,.7);
  font-size: 13.5px;
  font-weight: 400;
  cursor: pointer;
  transition: background .1s, color .1s;
  text-decoration: none;
  position: relative;
}
.nav-item svg { flex-shrink: 0; opacity: .7; }
.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: var(--white);
  text-decoration: none;
}
.nav-item:hover svg { opacity: 1; }
.nav-item.active {
  background: rgba(220,38,38,.15);
  color: var(--white);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--red);
  border-radius: 0 2px 2px 0;
}
.nav-item.active svg { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px;
  color: var(--gray-500);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: rgba(255,255,255,.6);
}
.sidebar-user-name { font-size: 13px; color: rgba(255,255,255,.85); font-weight: 500; }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 32px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.page-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--black);
}
.page-breadcrumb {
  font-size: 12px;
  color: var(--gray-500);
  margin-bottom: 2px;
}
.page-breadcrumb a { color: var(--gray-500); }
.page-breadcrumb a:hover { color: var(--red); }

.page-body {
  padding: 28px 32px;
  flex: 1;
}

/* ── Cards ── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--black);
}
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Stat Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
  margin-bottom: 6px;
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--black);
  line-height: 1.1;
}
.stat-sub {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}
.stat-card.accent { border-left: 3px solid var(--red); }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
thead th {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
  white-space: nowrap;
}
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  color: var(--gray-900);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }
.table-empty {
  text-align: center;
  padding: 40px;
  color: var(--gray-500);
  font-size: 13px;
}

/* ── Badges / Status ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-green   { background: var(--green-light); color: var(--green); }
.badge-red     { background: var(--red-mid); color: var(--red-dark); }
.badge-amber   { background: var(--amber-light); color: var(--amber); }
.badge-gray    { background: var(--gray-100); color: var(--gray-700); }
.badge-black   { background: var(--gray-900); color: var(--white); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn:focus { outline: 2px solid var(--red); outline-offset: 2px; }

.btn-primary {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}
.btn-primary:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
  color: var(--white);
}

.btn-secondary {
  background: var(--white);
  color: var(--gray-700);
  border-color: var(--gray-300);
}
.btn-secondary:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
  color: var(--black);
}

.btn-dark {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}
.btn-dark:hover {
  background: var(--gray-700);
  border-color: var(--gray-700);
  color: var(--white);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-500);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--gray-100);
  color: var(--black);
}

.btn-danger {
  background: var(--red-light);
  color: var(--red-dark);
  border-color: var(--red-mid);
}
.btn-danger:hover {
  background: var(--red-mid);
  color: var(--red-dark);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}
.btn-lg {
  padding: 10px 20px;
  font-size: 14px;
}

.btn-group {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Forms ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}
.form-grid.single { grid-template-columns: 1fr; }
.form-grid.triple { grid-template-columns: 1fr 1fr 1fr; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-group.span-2 { grid-column: span 2; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.label-hint {
  font-size: 11px;
  color: var(--gray-400);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 6px;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--black);
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  transition: border-color .1s, box-shadow .1s;
  line-height: 1.4;
}
input[type="file"] { padding: 6px 10px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(13,13,13,.08);
}
input:disabled, select:disabled, textarea:disabled {
  background: var(--gray-100);
  color: var(--gray-500);
  cursor: not-allowed;
}
textarea { resize: vertical; min-height: 80px; }
select { appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); background-position: right 8px center; background-repeat: no-repeat; background-size: 16px; padding-right: 32px; }

.form-help {
  font-size: 11.5px;
  color: var(--gray-500);
  margin-top: 2px;
}
.form-error {
  font-size: 12px;
  color: var(--red);
  margin-top: 2px;
}
.errorlist {
  list-style: none;
  padding: 0;
}
.errorlist li {
  color: var(--red);
  font-size: 12px;
  margin-top: 3px;
}
.form-errors-banner {
  background: var(--red-light);
  border: 1px solid var(--red-mid);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 20px;
  color: var(--red-dark);
  font-size: 13px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 20px;
  margin-top: 20px;
  border-top: 1px solid var(--gray-200);
}

/* Checkbox */
.check-group {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 8px;
}
.check-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--red);
  flex-shrink: 0;
}
.check-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--black);
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}

/* ── Alerts / Messages ── */
.messages-wrapper {
  padding: 16px 32px 0;
}
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 10px;
}
.alert-success { background: var(--green-light); color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: var(--red-light);   color: var(--red-dark); border: 1px solid var(--red-mid); }
.alert-warning { background: var(--amber-light);  color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.alert-dismiss { margin-left: auto; cursor: pointer; opacity: .5; font-size: 16px; line-height: 1; background: none; border: none; color: inherit; }
.alert-dismiss:hover { opacity: 1; }

/* ── Filters / Search bar ── */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.filter-bar input[type="text"],
.filter-bar select {
  width: auto;
  min-width: 160px;
}
.search-input { min-width: 240px !important; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: center;
  padding: 20px;
}
.page-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
  background: var(--white);
  text-decoration: none;
}
.page-link:hover { background: var(--gray-100); color: var(--black); text-decoration: none; }
.page-link.current {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}
.page-link.disabled { opacity: .4; pointer-events: none; }

/* ── Progress bar ── */
.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 100px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-fill {
  height: 100%;
  background: var(--red);
  border-radius: 100px;
  transition: width .3s ease;
}
.progress-fill.green { background: var(--green); }
.progress-fill.amber { background: var(--amber); }

/* ── Dashboard specifics ── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.grid-3 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

/* ── Detail sections ── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.detail-row {
  display: contents;
}
.detail-label {
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
}
.detail-value {
  padding: 10px 16px;
  font-size: 13.5px;
  color: var(--black);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
}

/* ── License key display ── */
.license-key {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 10px 12px;
  word-break: break-all;
  max-height: 120px;
  overflow-y: auto;
}

/* ── Reports ── */
.report-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  text-decoration: none;
  display: block;
  color: var(--black);
}
.report-card:hover {
  border-color: var(--red);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: var(--black);
}
.report-card h3 { font-size: 15px; margin-bottom: 6px; }
.report-card p  { font-size: 13px; color: var(--gray-500); }
.report-icon {
  width: 40px;
  height: 40px;
  background: var(--gray-100);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  color: var(--red);
}

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
}
.login-box {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.login-logo-text { font-size: 16px; font-weight: 700; }
.login-logo-sub  { font-size: 12px; color: var(--gray-500); }
.login-divider {
  text-align: center;
  color: var(--gray-400);
  font-size: 12px;
  margin: 16px 0;
  position: relative;
}
.login-divider::before {
  content: '';
  position: absolute;
  top: 50%; left: 0; right: 0;
  border-top: 1px solid var(--gray-200);
  z-index: 0;
}
.login-divider span {
  background: var(--white);
  padding: 0 10px;
  position: relative;
  z-index: 1;
}

/* ── Expiry indicators ── */
.expiry-ok     { color: var(--green); }
.expiry-warn   { color: var(--amber); font-weight: 600; }
.expiry-danger { color: var(--red);   font-weight: 600; }
.expiry-none   { color: var(--gray-400); font-style: italic; }

/* ── Utility ── */
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.text-muted    { color: var(--gray-500); }
.text-red      { color: var(--red); }
.text-sm       { font-size: 12px; }
.text-xs       { font-size: 11px; }
.font-mono     { font-family: var(--font-mono); }
.font-semibold { font-weight: 600; }
.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8         { gap: 8px; }
.gap-12        { gap: 12px; }
.gap-16        { gap: 16px; }
.w-full        { width: 100%; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

/* ── Print ── */
@media print {
  .sidebar, .page-header .btn-group, .filter-bar, .pagination { display: none !important; }
  .main-content { margin-left: 0; }
  .page-header { position: static; border-bottom: 2px solid var(--black); }
  body { font-size: 11px; }
  table { font-size: 11px; }
  .card { box-shadow: none; border: 1px solid var(--gray-300); }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.triple { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-body { padding: 16px; }
  .menu-toggle { display: flex !important; }
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
  color: var(--gray-700);
}
