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

:root {
  --bg:       #f0f4f8;
  --surface:  #ffffff;
  --surface2: #e8eef5;
  --border:   #cdd6e0;
  --accent:   #2563eb;
  --accent2:  #7c3aed;
  --success:  #16a34a;
  --warning:  #d97706;
  --danger:   #dc2626;
  --text:     #1e293b;
  --muted:    #64748b;
  --radius:   12px;
  --shadow:   0 2px 16px rgba(0,0,0,.08);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 0 0 3rem;
}

.app {
  width: 100%;
  max-width: 800px;
  padding: 0 1rem;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0 .75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.header-right { display: flex; gap: .75rem; align-items: center; }

.ws-badge {
  font-size: .75rem;
  color: var(--warning);
  transition: color .3s;
}
.ws-badge.connected { color: var(--success); }
.ws-badge.error     { color: var(--danger);  }

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .5rem;
}
.tab {
  background: none;
  border: none;
  color: var(--muted);
  font-size: .9rem;
  padding: .4rem .9rem;
  cursor: pointer;
  border-radius: var(--radius);
  transition: color .2s, background .2s;
}
.tab:hover   { color: var(--text); background: var(--surface2); }
.tab.active  { color: var(--accent); background: var(--surface2); font-weight: 600; }

.tab-content        { display: none; flex-direction: column; gap: 1rem; }
.tab-content.active { display: flex; }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1.05rem; margin-bottom: 1rem; color: var(--text); }
.card h3 { font-size: .9rem;  margin-bottom: .75rem; color: var(--muted); }
.card-header-row { display: flex; justify-content: space-between; align-items: center; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: .85rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
  white-space: nowrap;
}
.btn:hover         { background: var(--border); }
.btn:active        { transform: scale(.97); }
.btn-sm            { padding: .3rem .7rem; font-size: .78rem; }
.btn-lg            { padding: .75rem 1.6rem; font-size: 1rem; }
.btn-primary       { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #3a7be8; }
.btn-danger        { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover  { background: #d63232; }

/* ── NFC card ── */
.nfc-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
  padding: 2.5rem 1.5rem;
}
.nfc-icon {
  font-size: 4rem;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%,100% { transform: scale(1);    opacity: 1; }
  50%      { transform: scale(1.12); opacity: .7; }
}
.nfc-hint { color: var(--muted); font-size: .95rem; }
.manual-row {
  display: flex; gap: .5rem; width: 100%; max-width: 380px;
}
.manual-row input { flex: 1; }

/* ── Session panel ── */
.session-panel { display: flex; flex-direction: column; align-items: center; gap: 1.1rem; }
.session-header {
  display: flex; justify-content: space-between; align-items: flex-start; width: 100%;
}
.session-label { font-size: 1.1rem; font-weight: 600; }
.session-uid   { font-size: .78rem; color: var(--muted); font-family: monospace; }
.status-badge {
  padding: .25rem .7rem;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  background: var(--success);
  color: #fff;
}
.status-badge.warning  { background: var(--warning); }
.status-badge.expired  { background: var(--danger); }

/* ── Timer ring ── */
.timer-ring-wrap {
  position: relative;
  width: 160px; height: 160px;
}
.timer-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg      { fill: none; stroke: var(--border); stroke-width: 10; }
.ring-progress {
  fill: none;
  stroke: var(--accent);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset .9s linear, stroke .3s;
}
.ring-progress.warning { stroke: var(--warning); }
.ring-progress.danger  { stroke: var(--danger);  }

.timer-center {
  position: absolute;
  inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
}
.timer-elapsed   { font-size: 1.5rem; font-weight: 700; }
.timer-remaining { font-size: 1.1rem; font-weight: 600; color: var(--accent); }
.timer-remaining.warning { color: var(--warning); }
.timer-remaining.danger  { color: var(--danger);  }
.timer-label     { font-size: .65rem; color: var(--muted); line-height: 1.2; }

/* ── Progress bar ── */
.progress-bar-wrap {
  width: 100%;
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .9s linear, background .3s;
  border-radius: 4px;
}
.progress-bar.warning { background: linear-gradient(90deg, var(--warning), #f97316); }
.progress-bar.danger  { background: var(--danger); }

/* ── Overuse ── */
.overuse-row {
  display: flex; align-items: center; gap: .5rem;
  color: var(--danger);
  font-size: .9rem;
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: 8px;
  padding: .5rem 1rem;
  width: 100%;
  justify-content: center;
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: .5rem;
  z-index: 999;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem 1.1rem;
  min-width: 240px;
  max-width: 340px;
  font-size: .85rem;
  box-shadow: var(--shadow);
  animation: slideIn .25s ease;
}
@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.toast.warning { border-left: 3px solid var(--warning); }
.toast.danger  { border-left: 3px solid var(--danger);  }
.toast.success { border-left: 3px solid var(--success); }
.toast.info    { border-left: 3px solid var(--accent);  }

/* ── Admin ── */
.sessions-list { display: flex; flex-direction: column; gap: .6rem; }
.session-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem 1rem;
  font-size: .85rem;
  gap: .5rem;
}
.session-row .info { display: flex; flex-direction: column; gap: .15rem; }
.session-row .uid  { font-family: monospace; color: var(--muted); font-size: .75rem; }
.session-row .time { color: var(--warning); font-weight: 600; }

.row-input  { display: flex; gap: .5rem; }
.row-input input { flex: 1; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .6rem;
}
.form-grid button { grid-column: span 2; }

/* ── Tags list ── */
.tags-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.tag-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem 1rem;
  font-size: .85rem;
  gap: .5rem;
  flex-wrap: wrap;
}
.tag-row .tag-info { display: flex; flex-direction: column; gap: .1rem; }
.tag-row .tag-uid  { font-family: monospace; font-size: .72rem; color: var(--muted); }
.tag-row .tag-bal  { font-weight: 600; color: var(--success); }
.tag-row .tag-bal.low { color: var(--danger); }
.tag-topup { display: flex; gap: .4rem; align-items: center; }
.tag-topup input { width: 80px; }

/* ── History table ── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.data-table th, .data-table td {
  padding: .5rem .75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--muted); font-weight: 600; }
.data-table tr:hover td { background: var(--surface2); }
.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
}
.badge-active  { background: rgba(34,197,94,.2);  color: var(--success); }
.badge-closed  { background: rgba(79,142,247,.15); color: var(--accent);  }
.badge-expired { background: rgba(239,68,68,.2);  color: var(--danger);  }

/* ── Inputs ── */
input[type="text"],
input[type="number"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .45rem .75rem;
  font-size: .85rem;
  outline: none;
  width: 100%;
  transition: border-color .2s;
}
input:focus { border-color: var(--accent); }

.hidden { display: none !important; }
.empty  { color: var(--muted); font-size: .85rem; text-align: center; padding: 1rem; }

hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
