:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-light: #eef2ff;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --radius: 16px;
  --shadow: 0 4px 24px rgba(15, 23, 42, .06);
  --shadow-lg: 0 20px 60px rgba(15, 23, 42, .18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Cairo', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.sm { font-size: 12px; }

/* Buttons */
.btn {
  border: none; border-radius: 12px; padding: 11px 18px; font-family: inherit;
  font-weight: 700; font-size: 14px; cursor: pointer; transition: .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.25); }
.btn-primary:hover { background: var(--brand-dark); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-ghost.sm { padding: 7px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-danger { background: #fef2f2; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.icon-btn { background: none; border: none; font-size: 18px; color: var(--muted); cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--bg); }

/* Login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #2563eb 100%);
  padding: 20px;
}
.login-card {
  background: var(--card); border-radius: 24px; padding: 40px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg); text-align: center;
}
.login-logo {
  width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 18px;
  background: var(--brand-light); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
}
.login-card h1 { font-size: 24px; font-weight: 800; }
.login-card p { margin-bottom: 22px; }
.login-card form { text-align: right; }
.login-card label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
input, textarea, select {
  width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px;
  font-family: inherit; font-size: 14px; background: #fff; color: var(--text); transition: .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.login-card button { margin-top: 22px; }
.error { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; font-weight: 600; }
.success-msg { color: var(--success); font-size: 14px; margin-top: 12px; font-weight: 700; }

/* App layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; background: var(--card); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 22px 16px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--brand); padding: 0 8px 22px; }
nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px;
  color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; transition: .15s;
}
.nav-item svg { width: 20px; height: 20px; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--brand-light); color: var(--brand); }
.nav-badge { background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; margin-right: auto; }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 16px; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 0 6px; }
.avatar { width: 40px; height: 40px; border-radius: 12px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; }
.user-name { font-weight: 700; font-size: 14px; }

.content { flex: 1; padding: 28px 32px; max-width: 1200px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-head h2 { font-size: 24px; font-weight: 800; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat {
  background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  border: 1px solid var(--border); display: flex; align-items: center; gap: 14px;
}
.stat-icon { width: 48px; height: 48px; border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 24px; height: 24px; }
.stat-value { font-size: 26px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); padding: 22px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-head h3 { font-size: 17px; font-weight: 700; }
.form-card { max-width: 640px; }
.form-card label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.form-card label:first-child { margin-top: 0; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.license-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border); padding: 20px; transition: .15s;
}
.license-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.lc-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.lc-name { font-weight: 800; font-size: 16px; }
.lc-user { font-size: 12px; color: var(--muted); font-family: monospace; margin-top: 2px; }
.badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 99px; }
.badge-active { background: #dcfce7; color: var(--success); }
.badge-inactive { background: #fee2e2; color: var(--danger); }
.badge-trial { background: #cffafe; color: #0e7490; }
.lc-meta { display: flex; gap: 16px; margin: 12px 0; font-size: 13px; }
.lc-meta div b { display: block; font-size: 16px; }
.lc-meta div span { color: var(--muted); font-size: 11px; }
.lc-actions { display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; }
.lc-actions .btn { flex: 1; font-size: 12px; padding: 8px 10px; }
.lc-expiry { font-size: 12px; color: var(--muted); margin-top: 6px; }
.lc-expiry.warn { color: var(--warning); font-weight: 700; }
.lc-expiry.trial { color: #0e7490; font-weight: 700; }
.check-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; font-size: 14px; cursor: pointer; }
.check-row input { width: auto; margin: 0; }

.toolbar { margin-bottom: 18px; }
.search { max-width: 360px; }

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.col { flex: 1; min-width: 140px; }
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; }
.divider { text-align: center; margin: 20px 0 14px; position: relative; }
.divider::before { content: ''; position: absolute; top: 50%; right: 0; left: 0; height: 1px; background: var(--border); }
.divider span { background: var(--card); padding: 0 14px; position: relative; font-size: 13px; color: var(--muted); font-weight: 700; }

/* Modal */
.modal-wrap { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; backdrop-filter: blur(3px); }
.modal { background: var(--card); border-radius: 20px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); max-height: 92vh; overflow: auto; }
.sm-modal { max-width: 420px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 18px; font-weight: 800; }
.modal-body { padding: 24px; }
.modal-body label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }

.cred-box { background: var(--bg); border-radius: 14px; padding: 16px; margin: 16px 0; }
.cred-row { display: flex; justify-content: space-between; padding: 8px 0; }
.cred-row span { color: var(--muted); }
.cred-row b { font-family: monospace; font-size: 16px; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 12px 22px; border-radius: 12px;
  font-weight: 700; font-size: 14px; box-shadow: var(--shadow-lg); z-index: 200;
}

@media (max-width: 720px) {
  .sidebar { width: 70px; padding: 18px 8px; }
  .brand span, .nav-item, .user-chip div, .sidebar-footer .btn { display: none; }
  .brand { justify-content: center; }
  .nav-item { justify-content: center; }
  .nav-item.active { display: flex; }
  .user-chip { justify-content: center; display: flex; }
  .content { padding: 18px; }
}
