:root {
  --text: #17201d;
  --muted: #6b7571;
  --line: #dfe5e2;
  --page: #f5f7f6;
  --white: #fff;
  --green: #185545;
  --green-hover: #103f33;
  --danger: #b83b48;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; min-width: 320px; color: var(--text); background: var(--page); font-family: "Segoe UI", "Microsoft YaHei", sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.shell { min-height: 100vh; }

.topbar { height: 60px; padding: 0 24px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); background: var(--white); }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: var(--green); font-size: 14px; font-weight: 700; }
.topbar strong { font-size: 16px; }

main { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.login-layout { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 32px 0; }
.login-form { width: min(380px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); box-shadow: 0 12px 35px rgba(25, 50, 42, .08); }
.login-form h1 { margin: 0 0 26px; font-size: 24px; text-align: center; }
label { display: flex; flex-direction: column; gap: 7px; color: #35413d; font-size: 13px; font-weight: 600; }
.login-form label + label { margin-top: 18px; }
input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid #cbd4d0; border-radius: 7px; outline: none; color: var(--text); background: #fff; }
input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(24, 85, 69, .1); }
small { color: #89928e; font-weight: 400; }
button { min-height: 38px; padding: 0 15px; border: 0; border-radius: 7px; font-weight: 650; }
.primary { color: #fff; background: var(--green); }
.primary:hover { background: var(--green-hover); }
.secondary { color: var(--green); border: 1px solid #bdcbc6; background: #fff; }
.ghost { color: var(--muted); background: transparent; }
.login-form .primary { width: 100%; margin-top: 24px; }
.form-error { min-height: 18px; margin: 10px 0 0; color: var(--danger); font-size: 13px; text-align: center; }
.muted { color: var(--muted); }

.dashboard { padding: 34px 0 48px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.page-heading h1 { margin: 0; font-size: 28px; }
.heading-actions { display: flex; gap: 8px; }
.stats-strip { margin-top: 22px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stats-strip div { padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.stats-strip span { display: block; color: var(--muted); font-size: 12px; }
.stats-strip strong { display: block; margin-top: 5px; font-size: 25px; }

.create-section, .table-section { margin-top: 30px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; }
.section-title h2, .modal-panel h2 { margin: 0; font-size: 19px; }
.create-grid { display: grid; grid-template-columns: 130px 130px 130px 1fr auto; gap: 12px; align-items: end; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
.note-field { min-width: 180px; }
.create-btn { height: 42px; }
.search { width: min(300px, 42vw); }
.table-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--white); }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 14px; color: var(--muted); background: #fafbfa; font-size: 12px; text-align: left; }
td { padding: 14px; border-top: 1px solid #e8edeb; font-size: 13px; vertical-align: top; }
.license-code { color: #24483d; font-family: Consolas, monospace; font-weight: 700; white-space: nowrap; }
.status { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.status.ok { color: #0c7351; background: #e6f5ef; }
.status.off { color: #9a3540; background: #fae9eb; }
.status.expired { color: #a45c20; background: #fff0df; }
.shops { max-width: 260px; color: #52605b; line-height: 1.55; }
.row-actions { display: flex; gap: 6px; }
.row-actions button { min-height: 29px; padding: 0 9px; font-size: 11px; }
.empty { padding: 42px; color: var(--muted); text-align: center; }

.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(16, 28, 24, .46); }
.modal-panel { width: min(520px, 100%); padding: 26px; border-radius: 12px; background: #fff; box-shadow: 0 20px 55px rgba(0, 0, 0, .16); }
.modal-panel .muted { margin: 8px 0 0; font-size: 13px; }
.created-keys { max-height: 280px; margin: 18px 0; overflow: auto; border-block: 1px solid var(--line); }
.created-key { padding: 11px 0; border-bottom: 1px solid #edf1ef; font-family: Consolas, monospace; font-weight: 700; }
.created-key:last-child { border-bottom: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 30; max-width: 360px; padding: 11px 15px; border-radius: 7px; color: #fff; background: #202b27; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .18s; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 820px) {
  .create-grid { grid-template-columns: repeat(2, 1fr); }
  .note-field, .create-btn { grid-column: 1 / -1; }
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .topbar { padding: 0 14px; }
  main { width: calc(100% - 24px); }
  .dashboard { padding-top: 24px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .stats-strip { gap: 8px; }
  .stats-strip div { padding: 14px; }
  .section-title { align-items: stretch; flex-direction: column; }
  .search { width: 100%; }
  .create-grid { grid-template-columns: 1fr; }
  .note-field, .create-btn { grid-column: auto; }
  .table-wrap { overflow-x: auto; }
  table { min-width: 820px; }
}
