@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600;700&family=Noto+Serif+SC:wght@500;600;700&display=swap');

:root {
  --navy: #071d3b;
  --blue: #0b67d1;
  --blue-dark: #0753ab;
  --blue-pale: #eff7ff;
  --canvas: #f4f8fc;
  --surface: #fff;
  --ink: #112844;
  --muted: #6a819b;
  --line: #dbe6f1;
  --success: #157d57;
  --warning: #a87511;
  --danger: #c64747;
  --shadow: 0 12px 30px rgba(24, 63, 105, .08);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 84% 8%, #dceeff 0, transparent 29%), var(--canvas); color: var(--ink); font: 15px/1.5 'IBM Plex Sans', 'Noto Serif SC', sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
.hidden { display: none !important; }
.eyebrow { margin: 0; color: var(--blue); font: 500 11px/1.3 'DM Mono', monospace; letter-spacing: 1.35px; }
.muted { color: var(--muted); line-height: 1.75; }

/* Public redemption page */
.shell { display: flex; flex-direction: column; min-height: 100vh; max-width: 1180px; margin: auto; padding: 30px 42px 24px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 600 13px/1.05 'DM Mono', monospace; letter-spacing: 1.15px; }
.signal { color: var(--blue); font-size: 21px; letter-spacing: -6px; transform: skew(-15deg); }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; background: linear-gradient(135deg, #2d9dff, #0755be); color: #fff; box-shadow: 0 8px 18px rgba(0, 91, 205, .25); font: 700 19px Georgia, serif; }
.panel { position: relative; width: min(620px, 100%); margin: auto; padding: 38px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.97); box-shadow: 0 18px 44px rgba(24,63,105,.10); }
.panel h1, .login h1 { margin: 14px 0 20px; font: 600 clamp(42px, 7vw, 70px)/1 'Noto Serif SC', serif; letter-spacing: -3px; }
.panel h1 em { color: var(--blue); font-style: normal; }
.intro { max-width: 500px; margin: 0; color: var(--muted); line-height: 1.8; }
.flow { display: flex; gap: 14px; margin: 26px 0 24px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.step { flex: 1; }
.step b { display: block; margin-bottom: 4px; color: #a5b8ca; font: 500 20px 'DM Mono', monospace; }
.active .step:first-child b, .waiting .step:nth-child(2) b, .done .step:nth-child(3) b { color: var(--blue); }

form { display: grid; gap: 14px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 500; }
input, select { width: 100%; height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); outline: 0; }
input:focus, select:focus { border-color: #3890ed; box-shadow: 0 0 0 3px #dceeff; }
button, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 17px; border: 1px solid transparent; border-radius: 8px; background: var(--blue); color: #fff; cursor: pointer; font-size: 14px; font-weight: 600; transition: background .18s, transform .18s; }
button:hover, .button:hover { background: var(--blue-dark); transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: .5; }
.notice { margin: 18px 0; padding: 12px 14px; border-left: 3px solid var(--blue); background: var(--blue-pale); color: #28557d; line-height: 1.65; }
.notice.error { border-color: var(--danger); background: #fff1f1; color: #9c3838; }
.phone-label { margin-top: 24px; color: var(--muted); font-size: 12px; }
.phone { margin: 8px 0; color: var(--blue); font: 500 32px 'DM Mono', monospace; }
#phoneBox:not(.phone-ready) .phone-label,
#phoneBox:not(.phone-ready) .phone,
#phoneBox:not(.phone-ready) .phone + .muted { display: none; }
.timer { margin-top: 24px; font-size: 22px; }
.timer span { color: var(--blue); font: 500 46px 'DM Mono', monospace; }
.message { margin-top: 18px; padding: 16px; border: 1px solid #a5d0ff; border-radius: 8px; background: var(--blue-pale); color: var(--blue-dark); white-space: pre-wrap; }
#waitBox.history .timer,
#waitBox.history #pollStatus { display: none; }
footer { color: #91a7be; font: 11px 'DM Mono', monospace; text-align: center; }

/* Administration shell */
.admin { padding-left: 250px; }
.sidebar { position: fixed; z-index: 10; inset: 0 auto 0 0; display: flex; flex-direction: column; width: 250px; padding: 28px 18px 20px; background: var(--navy); color: #cfe4fb; }
.sidebar .brand b { color: #92c9ff; }
.sidebar nav { display: grid; gap: 5px; margin-top: 48px; }
.sidebar nav a { padding: 12px 14px; border-radius: 8px; color: #9dbbd9; font-weight: 500; }
.sidebar nav a:hover, .sidebar nav .active { background: #0d3b70; color: #fff; }
.sidebar nav .active { box-shadow: inset 3px 0 #49a6ff; }
.side-bottom { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin-top: auto; padding: 14px 9px 2px; color: #9ab6d5; font-size: 12px; }
.side-bottom a { grid-column: 2; color: #fff; }
.user-dot { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: #4ad49e; }
.nav-toggle { display: none; }
.admin-main { max-width: 1320px; margin: auto; padding: 46px 50px 70px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.page-header h1 { margin: 7px 0 0; font: 600 38px/1.15 'Noto Serif SC', serif; letter-spacing: -1.4px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }
.stats > div, .content-card, .form-card, .project-hero { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.stats > div { padding: 20px 22px; }
.stats span, .project-metric span { display: block; color: var(--muted); font-size: 12px; }
.stats strong { display: block; margin-top: 6px; color: var(--blue); font: 500 28px 'DM Mono', monospace; }
.content-card, .form-card { margin-bottom: 18px; padding: 25px; }
.form-card { max-width: 700px; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.card-heading h2 { margin: 0; font: 600 20px 'Noto Serif SC', serif; }
.card-heading p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.project-table { border-top: 1px solid var(--line); }
.project-item { display: grid; grid-template-columns: 42px minmax(190px, 1fr) 82px 72px 83px 120px; align-items: center; gap: 14px; padding: 15px 4px; border-bottom: 1px solid var(--line); }
.project-icon { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 9px; background: var(--blue-pale); color: var(--blue); font-size: 12px; font-weight: 700; }
.project-name strong { display: block; }
.project-name span { color: var(--muted); font: 12px 'DM Mono', monospace; }
.project-metric { text-align: center; }
.project-metric b { font: 500 16px 'DM Mono', monospace; }
.status { display: inline-block; width: max-content; padding: 4px 8px; border-radius: 999px; background: #eef2f6; color: #587087; font-size: 11px; font-weight: 600; }
.status.online, .status.unused, .status.received { background: #e7f7ef; color: var(--success); }
.status.offline, .status.expired { background: #fff0ef; color: var(--danger); }
.status.waiting { background: #fff6df; color: var(--warning); }
.text-action { color: var(--blue); font-size: 13px; font-weight: 600; text-align: right; }
.form-grid { grid-template-columns: 1fr 1fr; gap: 18px; }
.form-actions { display: flex; grid-column: 1 / -1; align-items: center; justify-content: flex-end; gap: 18px; margin-top: 3px; }
.form-actions a { color: var(--muted); font-weight: 500; }
.project-hero { display: flex; align-items: center; justify-content: space-between; gap: 22px; margin-bottom: 18px; padding: 27px; background: linear-gradient(110deg, #fff, #eaf5ff); }
.project-hero h2 { margin: 10px 0 4px; font: 600 29px 'Noto Serif SC', serif; }
.project-hero p { margin: 0; color: var(--muted); }
code { font-family: 'DM Mono', monospace; }
.hero-actions, .hero-actions form, .table-actions, .table-actions form { display: flex; align-items: center; gap: 10px; }
.secondary, .outline { border-color: var(--line); background: #fff; color: var(--blue); }
.outline { min-height: 42px; color: var(--ink); }
.danger-action { border-color: #efc3c1; color: var(--danger); }
.code-tools .generate-form { grid-template-columns: minmax(230px, 1fr) 150px auto; align-items: end; }
.filter { display: grid; grid-template-columns: minmax(200px, 1fr) 145px auto; align-items: end; margin-bottom: 18px; padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: #f8fbff; }
.filter input, .filter select, .filter button { height: 40px; min-height: 40px; }
.scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 13px 9px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .4px; }
.voucher { color: var(--blue); font-weight: 500; }
.delete { min-height: auto; padding: 0; background: transparent; color: var(--danger); font-size: 12px; }
.delete:hover { background: transparent; color: #982b2b; transform: none; }
.empty { padding: 38px; color: var(--muted); text-align: center; }
.empty a, .pagination a { color: var(--blue); font-weight: 600; }
.pagination { margin: 18px 0 0; color: var(--muted); font-size: 13px; }
.pagination a { margin-left: 12px; }

/* Login */
.login-page { display: grid; min-height: 100vh; place-items: center; background: linear-gradient(135deg, #edf7ff, #f9fbfe); }
.login { width: min(440px, calc(100% - 36px)); padding: 34px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: var(--shadow); }
.login .brand-mark { margin-bottom: 28px; }
.login h1 { font-size: 38px; }
.login form { margin-top: 24px; }

@media (max-width: 860px) {
  .admin { padding-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .22s; }
  .nav-open .sidebar { transform: translateX(0); box-shadow: 14px 0 32px rgba(4, 30, 59, .38); }
  .nav-toggle { position: fixed; z-index: 11; top: 15px; left: 15px; display: grid; width: 39px; min-height: 39px; padding: 0; place-items: center; background: var(--navy); }
  .admin-main { padding: 77px 22px 42px; }
  .project-item { grid-template-columns: 42px 1fr auto; gap: 12px; }
  .project-metric { display: none; }
  .project-item .status { grid-column: 2; }
  .text-action { grid-column: 3; grid-row: 1 / 3; }
}

@media (max-width: 600px) {
  .shell { padding: 22px 16px 18px; }
  .panel { margin: auto 0; padding: 28px 20px 24px; border-radius: 11px; }
  .panel h1 { font-size: 43px; }
  .flow { gap: 7px; font-size: 10px; }
  .flow .step b { font-size: 16px; }
  .phone { font-size: 25px; }
  .phone-label { margin-top: 20px; }
  .phone { overflow-wrap: anywhere; font-size: 24px; }
  #phoneBox .muted { font-size: 14px; }
  .page-header { align-items: flex-end; }
  .page-header h1 { font-size: 31px; }
  .page-header .button { min-height: 40px; padding: 0 11px; font-size: 12px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats > div:last-child { grid-column: 1 / -1; }
  .content-card, .form-card { padding: 18px; border-radius: 10px; }
  .form-grid, .code-tools .generate-form, .filter { grid-template-columns: 1fr; }
  .project-hero { display: grid; padding: 21px; }
  .hero-actions, .table-actions { flex-wrap: wrap; }
  .table-actions { width: 100%; }
  .table-title { display: grid; align-items: flex-start; }
  .scroll { margin: 0 -18px; }
  .scroll table { min-width: 730px; }
  .login { padding: 27px; }
  .login h1 { font-size: 34px; }
}
