:root {
  --color-bg: #1a1a1a;
  --color-gray: #4a4a4a;
  --color-green: #22c55e;
  --color-text: #ffffff;
  --color-error: #ef4444;
  --color-success: #22c55e;
  --radius: 14px;
  --gap: 10px;
  --pad: 10px;
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ── Main grid ── */

#app {
  height: 100dvh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#grid {
  flex: 1;
  display: grid;
  gap: var(--gap);
  padding: var(--pad);
  justify-content: center;
  align-content: center;
  overflow: hidden;
}

/* Tile */

.tile {
  background: var(--color-gray);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: background 0.3s ease, transform 0.1s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.tile.active {
  background: var(--color-green);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.35);
}

.tile:active,
.tile.pressing {
  transform: scale(0.93);
}

.tile.loading {
  pointer-events: none;
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.tile-name {
  font-size: clamp(0.85rem, 3.5vw, 1.6rem);
  font-weight: 700;
  text-align: center;
  color: var(--color-text);
  padding: 8px;
  line-height: 1.2;
  word-break: break-word;
  hyphens: auto;
}

/* ── Empty state ── */

#empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  height: 100vh;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

#empty-state.visible {
  display: flex;
}

#empty-state h2 {
  font-size: 1.4rem;
  color: #888;
}

#empty-state p {
  color: #666;
  font-size: 0.95rem;
}

#empty-state a {
  color: var(--color-green);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  padding: 10px 24px;
  border: 2px solid var(--color-green);
  border-radius: 8px;
  margin-top: 8px;
  transition: background 0.2s;
}

#empty-state a:hover { background: rgba(34,197,94,0.12); }

/* ── Gear button ── */

#gear-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 100;
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0.35;
  transition: opacity 0.2s;
  padding: 6px;
  border-radius: 50%;
}

#gear-btn:hover,
#gear-btn:focus {
  opacity: 1;
  outline: none;
}

#gear-btn svg {
  width: 26px;
  height: 26px;
  fill: var(--color-text);
  display: block;
}

/* ── Toast ── */

#toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: 90%;
  max-width: 420px;
}

.toast {
  background: var(--color-error);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: toast-in 0.25s ease;
  pointer-events: auto;
}

.toast.success { background: var(--color-green); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Admin page ── */

body.admin-body {
  overflow: auto;
  background: var(--color-bg);
}

.admin-container {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}
.btn:active { opacity: 0.75; }

.btn-primary { background: var(--color-green); color: #000; }
.btn-danger  { background: var(--color-error); color: #fff; }
.btn-ghost   { background: #333; color: var(--color-text); }
.btn-sm      { padding: 6px 12px; font-size: 0.8rem; }

/* Login form */

#login-section {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  min-height: 100vh;
}

.login-card {
  background: #242424;
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-card h2 {
  font-size: 1.3rem;
  text-align: center;
  margin-bottom: 4px;
}

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

.field label {
  font-size: 0.85rem;
  color: #aaa;
}

.field input, .field select {
  background: #333;
  border: 1.5px solid #444;
  border-radius: 8px;
  color: var(--color-text);
  padding: 10px 12px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--color-green); }

.password-wrap {
  position: relative;
  display: flex;
}

.password-wrap input {
  padding-right: 44px;
}

.eye-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  color: #888;
  padding: 4px;
  display: flex;
  align-items: center;
}
.eye-btn:hover { color: var(--color-text); }

/* Employee table */

#admin-section { display: none; }
#admin-section.visible { display: block; }

.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  background: #222;
  margin-bottom: 28px;
}

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

th {
  text-align: left;
  padding: 12px 14px;
  color: #888;
  font-weight: 600;
  border-bottom: 1px solid #333;
  white-space: nowrap;
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid #2a2a2a;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr.in-work td { background: rgba(34,197,94,0.06); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-green { background: rgba(34,197,94,0.2); color: var(--color-green); }
.badge-gray  { background: rgba(255,255,255,0.1); color: #888; }

td input {
  background: #333;
  border: 1.5px solid #555;
  border-radius: 6px;
  color: var(--color-text);
  padding: 6px 8px;
  font-size: 0.85rem;
  width: 100%;
  outline: none;
}
td input:focus { border-color: var(--color-green); }

.actions { display: flex; gap: 6px; white-space: nowrap; }

/* Add form */

.add-form {
  background: #222;
  border-radius: 12px;
  padding: 20px;
}

.add-form h3 {
  font-size: 1rem;
  margin-bottom: 16px;
  color: #ccc;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.error-msg {
  color: var(--color-error);
  font-size: 0.85rem;
  margin-top: 4px;
}
