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

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2f3f56;
  --text: #e8edf4;
  --muted: #8fa3bc;
  --accent: #3b9eff;
  --accent-glow: rgba(59, 158, 255, 0.25);
  --product: #f0c040;
  --personel: #5ee0a0;
  --danger: #ff6b6b;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.4;
  padding-bottom: env(safe-area-inset-bottom);
}

.header {
  background: linear-gradient(135deg, #152030 0%, #1a2a40 100%);
  border-bottom: 1px solid var(--border);
  padding: max(1rem, env(safe-area-inset-top)) 1.5rem 1rem;
  padding-left: max(1.5rem, env(safe-area-inset-left));
  padding-right: max(1.5rem, env(safe-area-inset-right));
}

.header-brand {
  max-width: 1680px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
}

.header-logo {
  width: clamp(72px, 10vw, 110px);
  height: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.header-title {
  text-align: center;
  min-width: 0;
}

.header-controls {
  max-width: 1680px;
  margin: 0.75rem auto 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
}

.type-tabs {
  display: flex;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.25rem;
}

.type-tabs[hidden] {
  display: none !important;
}

.type-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.type-tab:hover {
  color: var(--text);
}

.type-tab.is-active {
  background: var(--accent);
  color: #fff;
}

.header h1 {
  font-size: clamp(1.15rem, 2.6vw, 1.7rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.25;
}

.subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 0.35rem;
}

#refreshBtn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s, border-color 0.15s;
}

#refreshBtn:hover {
  background: var(--border);
  border-color: var(--accent);
}

main {
  max-width: 1680px;
  margin: 0 auto;
  padding: 1.25rem 1rem 1.5rem;
}

.status {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.grid-summary {
  display: flex;
  justify-content: stretch;
  align-items: stretch;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.grid-summary[hidden],
.summary-card[hidden],
.status[hidden] {
  display: none !important;
}

.summary-card {
  min-width: 0;
  flex: 1 1 0;
  padding: 0.55rem 0.45rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  text-align: center;
}

.summary-card--open {
  border-color: rgba(94, 224, 160, 0.35);
  background: rgba(94, 224, 160, 0.08);
}

.summary-card--personel {
  border-color: rgba(59, 158, 255, 0.35);
  background: rgba(59, 158, 255, 0.08);
}

.summary-card--closed {
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.08);
}

.summary-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

.summary-card--open .summary-value {
  color: var(--personel);
}

.summary-card--personel .summary-value {
  color: var(--accent);
}

.summary-card--closed .summary-value {
  color: var(--danger);
}

.summary-card--ozet {
  flex: 1.15 1 0;
  min-width: 0;
  max-width: none;
  border-color: rgba(255, 193, 94, 0.35);
  background: rgba(255, 193, 94, 0.08);
}

.summary-card--amir {
  flex: 1.2 1 0;
  min-width: 0;
  border-color: rgba(103, 232, 249, 0.35);
  background: rgba(103, 232, 249, 0.08);
}

.summary-card--amir .summary-ozet-text {
  color: #67e8f9;
  text-transform: uppercase;
}

.summary-card--vardiya-toplam {
  border-color: rgba(147, 112, 219, 0.35);
  background: rgba(147, 112, 219, 0.08);
}

.summary-card--vardiya-toplam .summary-value {
  color: #c4a7ff;
}

.summary-card--note {
  flex: 1.2 1 0;
  min-width: 0;
  max-width: none;
  border-color: rgba(167, 139, 250, 0.35);
  background: rgba(167, 139, 250, 0.08);
}

.summary-card--uretim {
  flex: 1.35 1 0;
  border-color: rgba(94, 224, 160, 0.4);
  background: rgba(94, 224, 160, 0.1);
}

.summary-card--uretim .summary-value {
  color: var(--personel);
}

.summary-card--note .summary-ozet-text {
  color: #c4b5fd;
  text-transform: none;
}

.summary-ozet-text {
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  color: #ffd27d;
  text-transform: lowercase;
}

.summary-value {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.15;
}

.summary-value--uretim {
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  white-space: nowrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.machine-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.machine-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-glow), 0 8px 24px rgba(0, 0, 0, 0.35);
}

.machine-header {
  padding: 0.85rem 1rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
  text-align: center;
  line-height: 1.3;
}

.product-section {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(240, 192, 64, 0.06);
  text-align: center;
}

.product-text {
  color: var(--product);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.4;
  word-break: break-word;
}

.machine-visual {
  flex: 1;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 1rem;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(45, 212, 191, 0.14) 0%, transparent 65%),
    linear-gradient(180deg, var(--surface) 0%, #141c28 100%);
}

.machine-icon {
  width: 100%;
  max-width: 200px;
  filter: drop-shadow(0 8px 24px rgba(45, 212, 191, 0.22));
}

.machine-icon svg {
  width: 100%;
  height: auto;
  display: block;
}

.machine-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.15);
}

.personel-names {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  width: 100%;
}

.personel-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--personel);
  line-height: 1.35;
  word-break: break-word;
  text-align: center;
}

.machine-card--uppercase .machine-header,
.machine-card--uppercase .product-text,
.machine-card--uppercase .personel-name {
  text-transform: uppercase;
}

.machine-card--off {
  border-color: rgba(255, 107, 107, 0.45);
}

.machine-card--off:hover {
  border-color: var(--danger);
  box-shadow: 0 0 0 1px rgba(255, 107, 107, 0.25), 0 8px 24px rgba(0, 0, 0, 0.35);
}

.machine-card--off .product-section {
  background: rgba(255, 107, 107, 0.08);
}

.machine-card--off .machine-visual {
  background:
    radial-gradient(ellipse at 50% 100%, rgba(255, 107, 107, 0.1) 0%, transparent 65%),
    linear-gradient(180deg, var(--surface) 0%, #141c28 100%);
}

.machine-card--off .machine-icon {
  filter: drop-shadow(0 8px 24px rgba(255, 107, 107, 0.2));
  opacity: 0.75;
}

.product-text--off {
  color: var(--danger);
  text-transform: none;
}

@media (max-width: 480px) {
  .header-logo {
    width: 64px;
  }

  .grid {
    grid-template-columns: 1fr;
  }
}
