/* Minimal, readable styling */
:root { --bg:#0f172a; --card:#111827; --muted:#9ca3af; --accent:#38bdf8; --text:#e5e7eb; --danger:#ef4444; --ok:#22c55e; }
* { box-sizing: border-box; }
html, body { margin:0; padding:0; background:var(--bg); color:var(--text); font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 980px; margin: 0 auto; padding: 24px; }
.nav { display:flex; align-items:center; justify-content:space-between; padding:16px 24px; background:#0b1220; border-bottom:1px solid #1f2937;}
.brand { font-weight:700; letter-spacing:.4px; }
.nav a { margin-right: 14px; }
.card { background: var(--card); padding:20px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.25); border:1px solid #1f2937; }
.grid { display:grid; gap:16px; grid-template-columns: repeat(12, 1fr); }
.col-12 { grid-column: span 12; }
.col-6 { grid-column: span 6; }
.col-4 { grid-column: span 4; }
label { display:block; font-size: 14px; margin-bottom: 6px; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="datetime-local"], select, textarea {
  width:100%; background:#0b1220; color:var(--text); border:1px solid #1f2937; padding:10px 12px; border-radius:10px;
}
textarea { resize: vertical; min-height: 90px; }
.btn { display:inline-block; background:#111827; border:1px solid #1f2937; padding:10px 14px; border-radius: 12px; color:var(--text); cursor:pointer; }
.btn.primary { background: var(--accent); color:#0a0a0a; border-color: transparent; font-weight:600; }
.btn.danger { background: var(--danger); color:white; border-color: transparent; }
.btn:hover { filter:brightness(1.1); }
.table { width:100%; border-collapse: collapse; }
.table th, .table td { border-bottom:1px solid #1f2937; padding:10px; text-align:left; vertical-align: top; }
.kpi { font-size:28px; font-weight:700; }
.kpi-sub { font-size:12px; color:var(--muted); margin-top:2px; }
.notice { padding:10px 12px; border-radius:10px; background:#0b1220; border:1px solid #1f2937; color: var(--muted); }
footer { text-align:center; color:var(--muted); padding: 24px; }
.small { font-size: 12px; color: var(--muted); }
.form-row { display:flex; gap:12px; }
.form-row > * { flex:1; }
.error { color: var(--danger); margin-bottom: 10px; }
.success { color: var(--ok); margin-bottom: 10px; }

/* Auth layout: fixed width, perfectly centered, no stretching */
html, body { height: 100%; }

.auth-page{
  min-height: calc(100vh - 100px);   /* header+footer allowance */
  display: grid;
  place-items: center;                /* vertical + horizontal center */
  padding: 24px;
}

/* Shell constrains width so .card can't stretch */
.auth-shell{
  width: min(480px, 92vw);
  margin: 0 auto;
}

/* Ensure inner card fills only the shell width */
.auth-shell .card{
  width: 100%;
  max-width: none;    /* ignore any global max-widths */
  margin: 0 auto;
}

/* ===== Progress bars ===== */
.bar{
  width:100%;
  height:12px;
  background:#0b1220;
  border:1px solid #1f2937;
  border-radius:12px;
  overflow:hidden;
}
.barfill{
  height:100%;
  width:0%;
  background:var(--accent);
  transition: width .5s;
}
.barfill.warn{ background:#f59e0b; }
.barfill.over{ background:#ef4444; }

/* ========== Mobile responsiveness ========== */

/* Grid: 12-column base, then stack on smaller screens */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.col-12 { grid-column: span 12; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-3  { grid-column: span 3; }

/* Tablet: prefer two-wide tiles */
@media (max-width: 1024px) {
  .col-6 { grid-column: span 12; }   /* stack big tiles */
  .col-4 { grid-column: span 6; }    /* two per row */
  .col-3 { grid-column: span 6; }    /* two per row */
}

/* Phone: stack everything */
@media (max-width: 640px) {
  .grid { gap: 10px; }
  .col-12, .col-6, .col-4, .col-3 { grid-column: span 12; }
}

/* Card padding scales down a bit on phones */
.card { padding: 16px; }
@media (max-width: 640px) {
  .card { padding: 12px; }
}

/* KPI text and headings scale with viewport */
h2, h3 { line-height: 1.2; }
.kpi { font-size: clamp(20px, 4.5vw, 32px); font-weight: 700; }
.kpi-sub { font-size: clamp(12px, 2.8vw, 14px); opacity: .9; }

/* Progress bars shrink slightly on small screens */
.bar { height: 10px; }
@media (max-width: 640px) { .bar { height: 8px; } }

/* Forms: inputs full-width, rows wrap on mobile, large tap targets */
input[type="text"], input[type="email"], input[type="password"],
input[type="datetime-local"], select, textarea {
  width: 100%;
  font-size: 16px;               /* prevents iOS zoom on focus */
}
.form-row { display: flex; gap: 8px; flex-wrap: wrap; }
.form-row > * { flex: 1; }
@media (max-width: 640px) {
  .form-row { flex-direction: column; }
  .form-row > * { width: 100%; }
}

/* Buttons: allow wrapping to full width on phones */
.btn { white-space: nowrap; }
@media (max-width: 640px) {
  .btn { width: 100%; text-align: center; }
}

/* Header nav (Login/Register) can wrap neatly on phones */
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 640px) {
  .header-actions { width: 100%; justify-content: flex-end; }
}

/* Auth pages: keep the card narrow and centered (non-stretched) */
.auth-page{ min-height: calc(100vh - 100px); display: grid; place-items: center; padding: 16px; }
.auth-shell{ width: min(480px, 92vw); margin: 0 auto; }
.auth-shell .card{ width: 100%; }

/* Tables (e.g., History): horizontal scroll on mobile */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 10px; white-space: nowrap; }

/* ==== Panel controls (collapse + drag) ==== */
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 8px;
}
.card-header h3 { margin: 0; }
.card-actions { display: flex; align-items: center; gap: 6px; }

/* Modern circular minimise button with animated chevron */
.toggle-btn {
  width: 30px; height: 30px; border-radius: 9999px;
  display: grid; place-items: center;
  background: #0b1220; border: 1px solid #1f2937; color: #e5e7eb;
  transition: background .2s, border-color .2s, transform .2s;
}
.toggle-btn:hover { background: #111827; border-color: #374151; }
.toggle-btn svg { width: 14px; height: 14px; transition: transform .2s ease; }
.toggle-btn[aria-expanded="false"] svg { transform: rotate(-90deg); }

/* Rearranging mode visuals */
#livePanels.rearranging .panel { cursor: grab; outline: 1px dashed #374151; border-radius: 12px; }
#livePanels.rearranging .panel:active { cursor: grabbing; }
.panel.dragging { opacity: .6; }

/* Rearrange button highlight */
#rearrangeBtn.is-active {
  background: #0b1220;
  border-color: #3b82f6;
  color: #e5e7eb;
  box-shadow: 0 0 0 2px rgba(59,130,246,.35);
}
#rearrangeBtn.is-active:hover {
  background: #111827;
  border-color: #93c5fd;
}

/* Hide panel bodies when collapsed */
.panel.collapsed .card-body { display: none; }

/* --- Simple info banner --- */
.notice{
  display:flex; align-items:center; gap:10px;
  padding:12px 44px 12px 16px;
  border-radius:12px; color:#fff;
  position:relative; margin:8px 0;
  box-shadow:0 6px 22px rgba(0,0,0,.18);
}
.notice-info{ background:#3b82f6; }            /* blue */
.notice strong{ font-weight:700; }
.notice-text{ opacity:.95; }

/* close button */
.notice-close{
  position:absolute; right:10px; top:50%; transform:translateY(-50%);
  width:28px; height:28px; border-radius:9999px;
  border:1px solid rgba(255,255,255,.35);
  background:transparent; color:#fff; cursor:pointer;
  display:grid; place-items:center; line-height:1; font-size:16px;
}
.notice-close:hover{ background:rgba(255,255,255,.12); }
.notice-close:focus{ outline:2px solid rgba(255,255,255,.6); outline-offset:2px; }
