:root {
  color: #172033;
  background: #f4f6fb;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --primary: #5b6cff;
  --border: #e5e9f2;
  --muted: #728097;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 360px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2, p { margin-top: 0; }
.muted { color: var(--muted); }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 20%, #e0e5ff 0, transparent 32%), radial-gradient(circle at 85% 80%, #ddf4f7 0, transparent 30%), #f4f6fb; }
.login-card { width: min(420px, 100%); padding: 34px; background: white; border: 1px solid var(--border); border-radius: 20px; box-shadow: 0 24px 70px rgba(23, 32, 51, .1); }
.login-card h1 { margin: 20px 0 8px; font-size: 25px; }
.login-card form { margin-top: 26px; }
.brand-mark, .brand-small { display: inline-grid; place-items: center; background: linear-gradient(135deg, #5b6cff, #7c3aed); color: white; font-weight: 800; }
.brand-mark { width: 54px; height: 54px; border-radius: 16px; font-size: 19px; letter-spacing: 1px; }
label { display: block; margin: 16px 0 8px; font-weight: 600; font-size: 14px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid #cfd6e4; border-radius: 9px; background: white; color: #172033; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91, 108, 255, .12); }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 8px 15px; border: 1px solid transparent; border-radius: 9px; font-weight: 600; font-size: 14px; }
.button.primary { color: white; background: var(--primary); }
.button.primary:hover { background: #4a5bea; }
.button.ghost { color: #3c4960; background: white; border-color: #d9dfeb; }
.button.danger { color: #c93636; background: #fff5f5; border-color: #f1cccc; }
.button.small { min-height: 30px; padding: 4px 9px; font-size: 12px; }
.button.full { width: 100%; margin-top: 20px; min-height: 44px; }
.button:disabled { opacity: .6; cursor: not-allowed; }
.topbar { height: 68px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: white; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 750; }
.brand-small { width: 32px; height: 32px; border-radius: 9px; font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar select { width: 190px; }
.container { max-width: 1600px; margin: 0 auto; padding: 28px; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-heading h2 { margin-bottom: 5px; }
.actions { display: flex; gap: 10px; }
.stats-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { padding: 18px; background: white; border: 1px solid var(--border); border-radius: 13px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { margin-top: 7px; font-size: 28px; font-weight: 750; }
.panel { background: white; border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.tabs { display: flex; gap: 24px; padding: 0 22px; border-bottom: 1px solid var(--border); }
.tab { padding: 17px 2px 14px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-weight: 650; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { padding: 20px 22px; }
.filters { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.filters input { max-width: 340px; }
.filters select { max-width: 190px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 11px 12px; text-align: left; color: #66748b; background: #f8f9fc; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 13px 12px; border-bottom: 1px solid #edf0f6; vertical-align: middle; background: transparent; }
tbody tr:nth-child(even) { background: #f3f6fd; }
tbody tr:hover { background: #e9efff; }
#licenses-tab th:last-child,
#licenses-body td.row-actions-cell { text-align: center; }
.code { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.tag { display: inline-flex; padding: 3px 8px; border-radius: 999px; font-size: 12px; white-space: nowrap; background: #eef1f6; color: #5d697c; }
.tag.success { color: #15803d; background: #eaf8ef; }
.tag.warning { color: #b45309; background: #fff4dd; }
.tag.error { color: #c23535; background: #ffeded; }
.tag.processing { color: #4f46e5; background: #eeeeff; }
.row-actions { display: flex; flex-wrap: nowrap; align-items: center; justify-content: center; gap: 5px; }
#licenses-body td.row-actions-cell { min-width: 220px; white-space: nowrap; }
.empty { padding: 46px; text-align: center; color: var(--muted); }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding-top: 18px; color: var(--muted); font-size: 13px; }
.pagination select { width: auto; padding: 6px 8px; }
.dialog { width: min(500px, calc(100vw - 28px)); padding: 26px; border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 24px 90px rgba(15, 23, 42, .25); }
.dialog.wide { width: min(720px, calc(100vw - 28px)); }
.dialog::backdrop { background: rgba(15, 23, 42, .55); backdrop-filter: blur(4px); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.dialog-header h2 { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.field-hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.warning-box { padding: 12px 14px; color: #92400e; background: #fff7df; border: 1px solid #f4dfab; border-radius: 9px; font-size: 13px; line-height: 1.6; }
.generated-list { max-height: 420px; margin-top: 16px; overflow: auto; }
.generated-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #edf0f6; }
.generated-item .index { color: var(--muted); min-width: 34px; }
.generated-item code { flex: 1; word-break: break-all; }
.filter-tag { padding: 7px 10px; color: #4f46e5; background: #eeeeff; border-radius: 8px; font-size: 12px; }
.confirm-code { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #f8f9fc; border: 1px solid var(--border); border-radius: 9px; font-size: 13px; }
.confirm-code code { font-family: "SFMono-Regular", Consolas, monospace; word-break: break-all; }
.more-menu { position: fixed; z-index: 200; display: flex; flex-direction: column; gap: 2px; min-width: 118px; padding: 6px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 14px 34px rgba(15, 23, 42, .14); }
.more-item { padding: 8px 10px; border: 0; border-radius: 7px; background: none; text-align: left; font-size: 13px; color: #3c4960; }
.more-item:hover { background: #f4f6fb; }
.more-item.danger { color: #c93636; }
.more-item.danger:hover { background: #fff1f1; }
.more-toggle.active { border-color: var(--primary); color: var(--primary); }
.toast { position: fixed; left: 50%; bottom: 28px; z-index: 100; transform: translate(-50%, 20px); padding: 11px 18px; color: white; background: #172033; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; }
.toast.error { background: #b42318; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 680px) {
  .topbar { padding: 12px 14px; height: auto; }
  .brand { font-size: 14px; }
  .topbar select { width: 125px; }
  .container { padding: 18px 12px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .tab-panel { padding: 16px 12px; }
  .filters > * { width: 100% !important; max-width: none !important; }
}
