/* ── Variables ─────────────────────────────────────────────── */
:root {
  --dark:          #0d1117;
  --dark-2:        #0f172a;
  --dark-3:        #1e293b;
  --accent:        #1d4ed8;
  --accent-bright: #3b82f6;
  --cyan:          #06b6d4;
  --success:       #16a34a;
  --success-dk:    #15803d;
  --bg:            #e8edf5;
  --card-bg:       #ffffff;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --border:        #e2e8f0;
  --radius:        8px;
  --shadow:        0 2px 16px rgba(0, 0, 0, .07);
  --header-h:      56px;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: radial-gradient(circle, rgba(99, 132, 174, .22) 1px, transparent 1px);
  background-size: 24px 24px;
}

a { color: var(--accent-bright); }

/* ── Site Header ───────────────────────────────────────────── */
.site-header {
  background: var(--dark);
  border-bottom: 2px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 28px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Brand ─────────────────────────────────────────────────── */
.brand {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .35em;
  color: #fff;
  text-decoration: none;
  text-transform: uppercase;
}

.brand::after {
  content: '_';
  color: var(--accent-bright);
  animation: blink 1.2s step-end infinite;
}

@keyframes blink { 50% { opacity: 0; } }

/* ── Site Nav ──────────────────────────────────────────────── */
.site-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-user {
  font-size: 0.85rem;
  color: #94a3b8;
  font-weight: 500;
}

.nav-sep {
  width: 1px;
  height: 16px;
  background: #334155;
}

.btn-nav {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  text-decoration: none;
  transition: color .15s;
  font-family: inherit;
}

.btn-nav:hover { color: #f1f5f9; }

.btn-logout { color: #64748b; }
.btn-logout:hover { color: #f87171; }

.nav-logout-form { display: inline; }

/* ── Main ──────────────────────────────────────────────────── */
.site-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── Card ──────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  border-top: 3px solid var(--accent);
}

.card + .card { margin-top: 28px; }

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.card-subtitle {
  color: var(--text-muted);
  font-size: 0.87rem;
  margin-bottom: 24px;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 16px;
}

label {
  font-size: 0.74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #475569;
}

input[type="text"],
input[type="password"] {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  background: #f8fafc;
  color: var(--text);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
  background: #fff;
}

/* field form two-column grid */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 28px;
}

.form-grid .form-group { margin-bottom: 14px; }

.error   { color: #dc2626; font-size: 0.8rem; }

.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.88rem;
  margin-bottom: 20px;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 10px 28px;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  letter-spacing: .04em;
  transition: background .15s, transform .1s;
  font-family: inherit;
  text-align: center;
}

.btn:active { transform: scale(.98); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1e40af; color: #fff; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-dk); color: #fff; }

.btn-block { display: block; width: 100%; margin-top: 8px; }

/* ── Home page ─────────────────────────────────────────────── */
.home-layout {
  position: relative;
  justify-content: center;
}

.home-nav {
  position: absolute;
  top: 20px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.home-card {
  text-align: center;
  padding: 40px 56px 48px;
  width: min(900px, calc(100vw - 48px));
}

.home-card .welcome {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.9rem;
  color: #64748b;
  letter-spacing: .05em;
  margin-bottom: 36px;
}

.home-card .welcome strong { color: #94a3b8; }

.home-btn-group {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.btn-home {
  flex: 0 0 150px;
  width: 150px;
  padding: 14px 0;
  font-size: 1rem;
  border-radius: 8px;
  letter-spacing: .08em;
  white-space: nowrap;
}

/* ── Upload area ───────────────────────────────────────────── */
.upload-area {
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  padding: 40px 32px;
  text-align: center;
  margin-bottom: 16px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}

.upload-area:hover { border-color: var(--accent-bright); background: #f0f7ff; }

.upload-area input[type="file"] { display: none; }

.upload-icon { font-size: 1.8rem; color: #94a3b8; margin-bottom: 12px; }

.upload-filename {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 0.87rem;
}

/* ── Table ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }

th {
  background: #f8fafc;
  padding: 9px 12px;
  text-align: left;
  font-size: 0.71rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #475569;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

td { padding: 8px 12px; border-bottom: 1px solid #f1f5f9; }

tr:hover td { background: #f8fafc; }

.text-muted { color: var(--text-muted); }

/* ── Dark page layout (upload / field) ────────────────────── */
.page-layout {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #0f1b2d;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(29, 78, 216, .22) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 30%, rgba(6, 182, 212, .13) 0%, transparent 50%),
    radial-gradient(circle, rgba(59, 130, 246, .06) 1px, transparent 1px);
  background-size: auto, auto, 28px 28px;
  padding: 0 24px 60px;
}

.page-nav {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0 0;
}

.page-nav-left,
.page-nav-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.page-brand {
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  letter-spacing: .5em;
  text-indent: .5em;
  color: #f1f5f9;
  text-transform: uppercase;
  padding: 40px 0 36px;
  text-shadow: 0 0 60px rgba(59, 130, 246, .4), 0 0 120px rgba(6, 182, 212, .15);
}

.page-card {
  background: var(--dark-2);
  border-top: 2px solid var(--accent);
  border-radius: 0 0 12px 12px;
  padding: 32px;
  width: min(900px, calc(100vw - 48px));
  box-shadow: 0 28px 72px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .04);
  margin-bottom: 28px;
}

.page-card .card-title  { color: #f1f5f9; }
.page-card .card-subtitle { color: #475569; }

.page-card label { color: #94a3b8; }

.page-card input[type="text"],
.page-card input[type="password"] {
  background: var(--dark-3);
  border-color: #334155;
  color: #f1f5f9;
}

.page-card input[type="text"]:focus,
.page-card input[type="password"]:focus {
  border-color: var(--accent-bright);
  background: var(--dark-3);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .2);
}

.page-card .upload-area {
  border-color: #334155;
}

.page-card .upload-area:hover {
  border-color: var(--accent-bright);
  background: rgba(59, 130, 246, .05);
}

.page-card th {
  background: rgba(255, 255, 255, .03);
  color: #64748b;
  border-bottom-color: #1e293b;
}

.page-card td {
  border-bottom-color: #1e293b;
  color: #cbd5e1;
}

.page-card tr:hover td { background: rgba(255, 255, 255, .03); }

.page-card a { color: var(--accent-bright); }
.page-card .text-muted { color: #475569; }
.page-card .error { color: #f87171; }

/* ── Login layout ──────────────────────────────────────────── */
.login-layout {
  min-height: 100vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #0f1b2d;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(29, 78, 216, .22) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 30%, rgba(6, 182, 212, .13) 0%, transparent 50%),
    radial-gradient(circle, rgba(59, 130, 246, .06) 1px, transparent 1px);
  background-size: auto, auto, 28px 28px;
}

.login-topline {
  width: 100%;
  height: 3px;
  position: fixed;
  top: 0;
  left: 0;
  background: linear-gradient(90deg, #1d4ed8, #06b6d4, #1d4ed8);
  background-size: 200% 100%;
  animation: line-slide 4s ease infinite;
}

@keyframes line-slide {
  0%, 100% { background-position: 0% 50%; }
  50%       { background-position: 100% 50%; }
}

.login-brand {
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(2.2rem, 6vw, 3.5rem);
  font-weight: 700;
  letter-spacing: .5em;
  text-indent: .5em;   /* offset letter-spacing on last char */
  color: #f1f5f9;
  text-transform: uppercase;
  padding: 56px 24px 48px;
  text-shadow: 0 0 60px rgba(59, 130, 246, .4), 0 0 120px rgba(6, 182, 212, .15);
}

.login-card {
  background: var(--dark-2);
  border-top: 2px solid var(--accent);
  border-radius: 0 0 12px 12px;
  padding: 40px 40px 48px;
  width: min(400px, calc(100vw - 48px));
  box-shadow: 0 28px 72px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .04);
}

.login-card label { color: #94a3b8; }

.login-card input[type="text"],
.login-card input[type="password"] {
  background: var(--dark-3);
  border-color: #334155;
  color: #f1f5f9;
}

.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus {
  border-color: var(--accent-bright);
  background: var(--dark-3);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .2);
}

.login-card .btn-primary { background: var(--accent); width: 100%; margin-top: 8px; }
.login-card .btn-primary:hover { background: #2563eb; }

/* ── Config page ───────────────────────────────────────────── */
.config-card {
  width: min(640px, calc(100vw - 48px));
}

.config-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.config-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.config-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #475569;
  padding-bottom: 8px;
  border-bottom: 1px solid #1e293b;
}

.config-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.config-label {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 500;
}

.config-input {
  background: var(--dark-3);
  border: 1px solid #334155;
  border-radius: var(--radius);
  color: #f1f5f9;
  font-size: 0.9rem;
  padding: 8px 12px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}

.config-input:focus {
  outline: none;
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .2);
}

.config-error {
  font-size: 0.78rem;
  color: #f87171;
}

.config-actions {
  display: flex;
  gap: 12px;
  padding-top: 8px;
}

.config-messages {
  list-style: none;
  margin-bottom: 16px;
}

.config-msg {
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: rgba(22, 163, 74, .15);
  color: #4ade80;
  border: 1px solid rgba(22, 163, 74, .3);
}
