/* ══════════════════════════════════════════════════
   inTime – mobile.css  (max-width: 768px)
   ══════════════════════════════════════════════════ */

/* Import shared variables from desktop via cascade */
:root {
  --bg: #1a1b1e;
  --bg-card: #1e1f23;
  --bg-input: #15161a;
  --text: #ffffff;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --control-text: #b8c0cf;
  --accent-a: #a855f7;
  --accent-b: #3b82f6;
  --accent-grad: linear-gradient(135deg, #a855f7, #3b82f6);
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --border: #374151;
  --shadow-dark: #121316;
  --shadow-light: #222327;
  --radius-card: 18px;
  --radius-btn: 12px;
  --radius-input: 12px;
  --font: "Inter", system-ui, sans-serif;
}

/* Screen-reader only – SEO text visually hidden */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  height: auto !important; /* override desktop overflow:hidden */
  overflow-x: hidden;
  overflow-y: auto !important; /* allow vertical scroll in portrait */
  -webkit-tap-highlight-color: transparent;
}

html {
  background: #131417;
}

button,
[role="button"],
input[type="button"],
input[type="submit"],
input[type="checkbox"],
label,
select {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button svg,
.btn svg,
.icon-btn svg {
  pointer-events: none;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 60px;
  background: #131417;
  border-bottom: 1px solid var(--border);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}
.topbar-hidden {
  transform: translateY(-100%);
}
.brand-name {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-icon {
  font-size: 20px;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.brand-sep {
  color: var(--text-dim);
  opacity: 0.25;
  font-weight: 300;
  font-size: 13px;
  margin: 0 1px;
}
.topbar-center {
  flex: 1;
  display: flex;
  justify-content: center;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: all 0.3s ease;
}
.badge::before {
  content: "●";
  display: inline-block;
  font-size: 10px;
  line-height: 1;
  flex-shrink: 0;
}
#connectivity-badge {
  background: transparent !important;
  border: none !important;
  padding: 0;
  font-size: 12px;
}
.badge-waiting {
  background: rgba(107, 114, 128, 0.15);
  color: var(--text-muted);
  border: 1px solid #374151;
}
.badge-prestart {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.badge-running {
  background: rgba(168, 85, 247, 0.15);
  color: var(--accent-a);
  border: 1px solid rgba(168, 85, 247, 0.3);
}
.badge-paused {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.badge-stopped {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge-online {
  color: var(--success);
}

.badge-offline {
  color: var(--danger);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow:
    4px 4px 8px var(--shadow-dark),
    -2px -2px 6px var(--shadow-light);
}
.icon-btn svg {
  width: 19px;
  height: 19px;
}
.icon-btn:active {
  box-shadow:
    inset 2px 2px 5px var(--shadow-dark),
    inset -2px -2px 5px var(--shadow-light);
  transform: scale(0.95);
}
.lang-dropdown {
  position: relative;
  flex-shrink: 0;
}
.lang-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 42px;
  height: 42px;
  padding: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow:
    2px 2px 5px var(--shadow-dark),
    -1px -1px 3px var(--shadow-light);
}
.lang-trigger-text {
  font-size: 11px;
  font-weight: 800;
}
.lang-dropdown.open .lang-trigger {
  border-color: var(--accent-a);
  background: rgba(168, 85, 247, 0.08);
  color: var(--accent-a);
  box-shadow: inset 2px 2px 4px var(--shadow-dark);
}
.lang-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: -5px;
  min-width: 160px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 4px;
  z-index: 1000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(14px);
  opacity: 0;
  transform: translateY(10px) scale(0.95);
  pointer-events: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.lang-dropdown.open .lang-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.lang-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}
.lang-item:active {
  background: rgba(168, 85, 247, 0.1);
  color: var(--text);
}
.lang-item.active {
  background: rgba(168, 85, 247, 0.15);
  color: var(--accent-a);
  font-weight: 700;
}
.lang-code {
  font-size: 10px;
  font-weight: 900;
  padding: 2px 5px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  min-width: 24px;
  text-align: center;
}
.lang-name {
  flex: 1;
}

/* App layout: vertical stack */
.app-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  height: auto !important; /* override desktop fixed height */
  overflow: visible !important; /* allow natural page scroll */
  padding-top: 60px; /* Space for fixed topbar */
  padding-bottom: 40px; /* Space so content isn't hidden behind fixed footer */
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

/* Parts section full width */
.parts-section {
  order: 1; /* Appare per prima */
  padding: 10px 6px 16px;
  flex: 1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

/* Control panel becomes collapsible row on mobile */
.control-panel {
  order: 2; /* Appare dopo la lista */
  width: 100%;
  min-width: 0;
  border-right: none;
  border-bottom: 1px solid var(--border);
  padding: 16px 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #17181c;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  padding: 16px 12px;
  box-shadow:
    6px 6px 12px var(--shadow-dark),
    -3px -3px 8px var(--shadow-light);
  border: 1px solid rgba(255, 255, 255, 0.04);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.card-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: #808ba1;
  margin-bottom: 12px;
  display: block;
}

/* Summary */
.summary-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed #2a2d35;
}
.summary-row:last-child {
  border-bottom: none;
}
.summary-label {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.summary-value {
  font-size: 16px;
  font-weight: 700;
}

.summary-card .summary-label {
  font-size: 14px !important;
}

.summary-card .time-input {
  width: 108px !important;
  min-width: 108px;
  min-height: 42px;
  padding: 8px 10px;
  text-align: center;
}

.summary-card #expected-end,
.summary-card #actual-end-val,
.summary-card #total-measured-val {
  font-size: 16px !important;
}
.summary-delta {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 20px;
}
.delta-late {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}
.delta-early {
  color: var(--success);
  background: rgba(34, 197, 94, 0.1);
}

/* Inputs */
.time-input,
.num-input,
.text-input,
.select-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  min-width: 0;
  text-overflow: ellipsis;
  border-radius: 12px;
  color: var(--text);
  font-family: var(--font);
  box-shadow:
    inset 2px 2px 5px var(--shadow-dark),
    inset -2px -2px 3px var(--shadow-light);
}
.time-input {
  font-size: 15px;
  font-weight: 600;
  padding: 7px 10px;
  width: 92px;
  min-height: 42px;
  text-align: center;
}
.time-input::-webkit-calendar-picker-indicator {
  display: none;
  -webkit-appearance: none;
}
.time-input::-webkit-inner-spin-button,
.time-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ── Scheduled Start: center time, remove native arrow ── */
#input-scheduled-start {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  text-align: center;
  text-align-last: center;
  padding: 7px 0;
  width: 108px;
}
#input-scheduled-start::-webkit-calendar-picker-indicator {
  display: none !important;
  -webkit-appearance: none;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
}
#input-scheduled-start::-webkit-date-and-time-value {
  text-align: center;
  margin: 0 auto;
}
#input-scheduled-start::-webkit-datetime-edit {
  text-align: center;
  padding: 0;
}
#input-scheduled-start::-webkit-datetime-edit-fields-wrapper {
  text-align: center;
  display: flex;
  justify-content: center;
}
.num-spin {
  display: inline-flex;
  align-items: stretch;
}
.num-input {
  font-size: 18px;
  font-weight: 700;
  padding: 6px 8px;
  width: 58px;
  min-height: 44px;
  text-align: center;
  border-right: none;
  border-radius: 8px 0 0 8px;
  -webkit-appearance: textfield;
  -moz-appearance: textfield;
  appearance: textfield;
}
.num-input::-webkit-inner-spin-button,
.num-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
}
.num-spin-btns {
  display: flex;
  flex-direction: column;
  width: 34px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0 8px 8px 0;
  overflow: hidden;
}
.num-spin-up,
.num-spin-dn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 6px;
  flex: 1;
  transition:
    background 0.15s,
    color 0.15s;
}
.num-spin-up {
  border-bottom: 1px solid var(--border);
}
.num-spin-up:hover,
.num-spin-dn:hover {
  background: rgba(168, 85, 247, 0.18);
  color: var(--accent-a);
}
.num-spin-up:active,
.num-spin-dn:active {
  background: rgba(168, 85, 247, 0.32);
}
.num-spin-up svg,
.num-spin-dn svg {
  width: 14px;
  height: 10px;
  display: block;
}
.text-input {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 11px 12px;
  min-height: 46px;
  width: 100%;
}
.select-input {
  color: var(--control-text);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 10px 11px;
  min-height: 46px;
  width: 100%;
}
.num-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius-btn);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  border: none;
  transition: all 0.18s;
  white-space: nowrap;
  min-height: 48px; /* Touch target */
}
.btn svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--control-text);
  border: 1px solid var(--border);
}
.btn-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-large {
  padding: 14px 18px;
  font-size: 17px;
  min-height: 54px;
}

.btn-sm {
  font-size: 15px;
  min-height: 46px;
  padding: 10px 14px;
}
.btn-block {
  width: 100%;
}

/* Utilities for truncating text inside buttons nicely */
.btn-truncate {
  min-width: 0;
}
.btn-truncate .truncate-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}

.template-actions .btn {
  gap: 7px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
}

.template-actions .btn svg {
  width: 16px;
  height: 16px;
}

.template-actions-top {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: stretch;
}

#btn-open-template-folder .truncate-text {
  min-width: 0;
}

/* Main controls */
.main-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.main-controls .btn {
  width: 100%;
  min-width: 0;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  animation: mobile-btn-fade 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes mobile-btn-fade {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

#btn-back {
  grid-column: 1;
  grid-row: 1;
  order: 1;
}
#btn-skip {
  grid-column: 2;
  grid-row: 1;
  order: 2;
}
#btn-start,
#btn-pause,
#btn-resume {
  grid-column: 1;
  grid-row: 2;
  order: 3;
}
#btn-stop {
  grid-column: 2;
  grid-row: 2;
  order: 4;
}

/* Enlarge Start or Reset button in waiting/stopped state */
.main-controls.is-waiting #btn-start,
.main-controls.is-waiting #btn-reset-timer {
  grid-column: 1 / span 2;
  grid-row: 1 / span 2;
  padding-top: 16px;
  padding-bottom: 16px;
  font-size: 16px;
  border-radius: 12px;
}
.main-controls.is-waiting #btn-start svg {
  width: 22px;
  height: 22px;
}

/* Center and widen Skip and Stop when side is empty */
.main-controls:not(.has-back):not(.has-pause-resume) #btn-skip {
  grid-column: 1 / span 2;
}
.main-controls:not(.has-back):not(.has-pause-resume) #btn-stop {
  grid-column: 1 / span 2;
}

/* Control rows */
.prestart-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.template-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  position: relative;
}
.tpl-temp-dropzone {
  display: none !important;
}

/* Notification Style Card */
.notification-card {
  margin-top: 0;
}
.add-part-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.add-part-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.add-part-title-input {
  flex: 1;
  min-width: 0;
}
.add-part-time-labels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 1px;
  margin-bottom: -5px;
}
.add-part-time-labels span {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.add-part-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.add-part-time-col {
  display: flex;
}
.add-part-time-col .num-spin {
  width: 100%;
}
.add-part-time-col .num-input {
  flex: 1;
  width: auto;
  min-width: 0;
}
.ping-button-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #737d8f;
  cursor: pointer;
  transition:
    color 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    opacity 0.2s ease;
  flex-shrink: 0;
  opacity: 0.55;
}

.ping-button-toggle[data-active="true"] {
  color: #ffb200;
  opacity: 1;
}

.ping-button-toggle[data-active="false"]:hover {
  color: #8a94a7;
  opacity: 0.8;
}

.ping-button-toggle[data-active="true"]:hover {
  color: #ffc133;
}

.ping-button-toggle svg {
  display: block;
  width: 18px;
  height: 18px;
}

/* Pre-start overlay */
.prestart-overlay {
  position: absolute;
  inset: 0;
  background: rgba(26, 27, 30, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(6px);
}
.prestart-content {
  text-align: center;
}
.prestart-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.prestart-timer {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: -4px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

/* Table wrapper — limited height to show ~4 rows, then scroll */
.table-wrapper {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  box-shadow:
    6px 6px 12px var(--shadow-dark),
    -3px -3px 8px var(--shadow-light);
  border: 1px solid rgba(255, 255, 255, 0.04);
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: auto; /* Enable inner scroll */
  max-height: 295px; /* Roughly 4 rows (4 * 72px) + room for header/footer if any */
  -webkit-overflow-scrolling: touch;
}

/* Parts table */
.parts-table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
.parts-table thead {
  display: none;
}
.parts-table tbody tr {
  display: grid !important;
  grid-template-areas:
    "idx title title title"
    "idx dur cum timer";
  grid-template-columns: 32px 1.15fr 1fr 1.15fr;
  padding: 6px 8px 6px 0px;
  border-bottom: 1px solid var(--border);
  gap: 1px 8px;
  align-items: center;
  height: auto !important;
}
body.edit-mode-unlocked .parts-table tbody tr {
  grid-template-columns: 56px 1.15fr 1fr 1.15fr;
}
.parts-table td {
  padding: 0 !important;
  border-bottom: none !important;
  font-size: 13px;
  display: flex !important;
  align-items: center;
  min-height: 28px !important;
  height: auto !important;
}
.parts-table tbody tr:last-child {
  border-bottom: none;
}

.part-row-actions {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  opacity: 1;
}

.part-row-stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: transparent;
  box-shadow: none;
}

.part-row-stack:last-child {
  border-right: 0;
}

.part-row-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--control-text);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
}

.part-row-icon {
  width: 14px !important;
  height: 14px !important;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5 !important;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.part-row-btn-bottom {
  border-bottom: 0;
}

.part-row-btn:disabled {
  opacity: 0.3;
}

.part-row-btn-add,
.part-row-btn-delete {
  color: var(--control-text);
  font-size: 17px !important;
  font-weight: 800 !important;
  line-height: normal !important;
}

.row-summary {
  display: flex !important;
  width: 100%;
  justify-content: flex-start;
  align-items: center;
  min-height: 58px;
  padding: 10px 10px !important;
  background: #101216;
  border-top: 1px solid rgba(86, 95, 118, 0.45);
  gap: 6px;
}
.row-summary td {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 58px;
  padding: 0 4px !important;
  font-size: 13px !important;
  flex: 1;
  gap: 2px;
  background: transparent !important;
}
.row-summary .summary-edit-cell {
  flex: 0 0 78px;
  align-items: flex-start;
  justify-content: center;
  text-align: left;
  padding-left: 0 !important;
  padding-right: 2px !important;
}
#sum-duration::before {
  content: "DUR";
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #8a94a7 !important;
  opacity: 1 !important;
}
#sum-actual::before {
  content: "TOT";
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #8a94a7 !important;
  opacity: 1 !important;
}
#sum-timer::before {
  content: "TIMER";
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #8a94a7 !important;
  opacity: 1 !important;
}
#sum-duration,
#sum-actual,
#sum-timer {
  font-weight: 800 !important;
  font-variant-numeric: tabular-nums;
}
#sum-timer.timer-early::before {
  content: "TIMER";
}
.parts-table tfoot {
  position: sticky;
  bottom: 0;
  z-index: 20;
}
.parts-table tfoot td {
  padding: 12px;
  border-top: none;
  background: var(--bg-card);
  font-size: 13px;
  position: relative;
}
.summary-edit-cell {
  min-width: 78px;
}

.edit-switch-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  width: 100%;
}

.edit-switch-label {
  display: none;
}

.edit-lock-switch {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  cursor: pointer;
  flex: 0 0 auto;
  min-width: 72px;
}

.edit-lock-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.edit-lock-track {
  display: block;
  position: relative;
  flex: 0 0 auto;
  width: 72px;
  min-width: 72px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid #3a3f4e;
  background: linear-gradient(145deg, #1a1c24, #12141b);
  box-shadow:
    inset 2px 2px 6px rgba(0, 0, 0, 0.45),
    inset -2px -2px 5px rgba(255, 255, 255, 0.04);
}

.edit-lock-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: #8892a8;
}

.edit-lock-closed {
  left: 11px;
}

.edit-lock-open {
  right: 11px;
}

.edit-lock-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(145deg, #f2f4f8, #c7d0de);
  box-shadow:
    0 3px 8px rgba(0, 0, 0, 0.45),
    inset -1px -1px 2px rgba(0, 0, 0, 0.18);
  transform: translateX(0);
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.edit-lock-switch input:checked + .edit-lock-track {
  border-color: rgba(34, 197, 94, 0.55);
}

.edit-lock-switch input:checked + .edit-lock-track .edit-lock-thumb {
  transform: translateX(38px);
}

.edit-lock-switch input:checked + .edit-lock-track .edit-lock-open {
  color: var(--success);
}

.edit-lock-switch input:checked + .edit-lock-track .edit-lock-closed {
  color: #64748b;
}

body.edit-mode-unlocked .parts-table .title-cell,
body.edit-mode-unlocked .parts-table .dur-cell {
  cursor: text;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent-a);
}
.row-summary #sum-duration {
  color: #ffffff !important;
  font-weight: 700;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  min-width: 6ch;
  line-height: 1.05;
}
.row-summary #sum-actual {
  color: #ffffff !important;
  font-weight: 700;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  min-width: 6ch;
  line-height: 1.05;
}
.row-summary #sum-timer {
  color: var(--accent-a);
  font-weight: 600;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  min-width: 6ch;
  line-height: 1.05;
}
.row-summary #sum-timer.timer-negative {
  color: var(--danger) !important;
}
.row-summary td:not(.summary-edit-cell) {
  flex: 1 1 0;
  min-width: 72px;
}

.row-current {
  background: rgba(168, 85, 247, 0.06);
}
/* ── Prestart row: smooth slide-in from top ──────────────────── */
#prestart-part-row {
  display: grid !important;
  grid-template-areas: "idx title timer";
  grid-template-columns: 32px 1fr auto;
  width: 100%;
  padding: 6px 8px 6px 0px;
  gap: 1px 8px;
  align-items: center;
}
#prestart-part-row td {
  display: flex !important;
  align-items: center;
  min-height: 28px !important;
  height: auto;
}
#prestart-part-row .idx-cell {
  grid-area: idx;
}
#prestart-part-row .title-cell {
  grid-area: title;
}
#prestart-part-row .dur-cell {
  display: none !important;
}
#prestart-part-row .cum-cell {
  display: none !important;
}
#prestart-part-row .timer-col {
  grid-area: timer;
  justify-content: flex-end;
  align-self: center;
  min-width: 5ch;
}
#prestart-part-row .title-main {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#prestart-part-row .timer-cell {
  font-size: 16px !important;
  letter-spacing: -0.3px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 5ch;
  text-align: right;
}
#prestart-part-row .dur-cell::before,
#prestart-part-row .cum-cell::before {
  content: none !important;
}
.prestart-row-enter {
  animation: prestart-row-slide-in 0.36s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.prestart-row-leave {
  animation: prestart-row-slide-out 0.28s cubic-bezier(0.4, 0, 1, 1) both;
  pointer-events: none;
}

@keyframes prestart-row-slide-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
    max-height: 0;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    max-height: 50px;
  }
}
@keyframes prestart-row-slide-out {
  from {
    opacity: 1;
    transform: translateY(0);
    max-height: 50px;
  }
  to {
    opacity: 0;
    transform: translateY(-6px);
    max-height: 0;
  }
}
.row-done {
  opacity: 0.5;
}

.parts-table tr.drag-over > td {
  background: rgba(168, 85, 247, 0.08);
  box-shadow: inset 0 2px 0 var(--accent-a);
}
.parts-table tr.drag-over.drag-over-after > td {
  box-shadow: inset 0 -2px 0 var(--accent-a);
}
.parts-table tr.dragging {
  opacity: 0.38;
  background: rgba(168, 85, 247, 0.06);
}

.parts-table tr[data-id] {
  will-change: transform;
}

.parts-table tbody.drag-active tr[data-id] {
  backface-visibility: hidden;
}

.drag-ghost-proxy {
  position: fixed;
  top: -9999px;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.drag-mirror {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 24px);
  padding: 7px 10px;
  border-radius: 11px;
  border: 1px solid rgba(168, 85, 247, 0.45);
  background: linear-gradient(
    180deg,
    rgba(12, 16, 28, 0.96),
    rgba(10, 13, 24, 0.96)
  );
  box-shadow:
    0 10px 22px rgba(3, 6, 14, 0.46),
    0 0 0 1px rgba(82, 101, 147, 0.12);
  color: var(--text);
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  transform: translate(-9999px, -9999px);
}

.drag-mirror-title {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
}

.drag-mirror-duration {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.idx-cell {
  position: relative;
  overflow: visible !important;
  grid-area: idx;
  width: auto !important;
  color: var(--text-dim);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  justify-content: center;
  align-items: center;
  text-align: center;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  align-self: stretch;
  opacity: 0.75;
}

body.edit-mode-unlocked .idx-cell {
  opacity: 1;
}
.title-cell {
  grid-area: title;
  font-weight: 800 !important;
  font-size: 15px !important;
  color: var(--text);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 0px !important;
}
.title-main,
.title-cell .bulk-edit-title {
  flex: 1;
  min-width: 0;
  white-space: normal;
  line-height: 1.16;
}

/* Keep table rows visually stable in mobile edit mode while adding a bit more inner space */
.parts-table .title-cell .bulk-edit-title,
.parts-table .dur-cell .bulk-edit-duration {
  min-height: 26px;
  height: 26px !important;
  padding: 2px 9px;
  font-size: 14px;
  box-sizing: border-box;
  border-radius: 8px;
  line-height: 1.18;
}

.parts-table .dur-cell .bulk-edit-duration {
  text-align: center;
  min-width: 72px;
  flex: 1 1 72px;
}

.dur-display {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: auto;
}

.dur-display .dur-value {
  display: inline-block;
}

.dur-display .flex-indicator {
  position: relative !important;
  display: inline-flex !important;
  align-items: center;
  margin-left: 6px;
  flex-shrink: 0;
  opacity: 0.6;
  top: auto !important;
  right: auto !important;
  transform: none !important;
}
.dur-display .flex-indicator svg {
  width: 13px;
  height: 13px;
  display: block;
}

.dur-cell {
  grid-area: dur;
  width: auto !important;
  min-width: 92px;
  color: var(--text-muted);
  font-size: 14px !important;
  justify-content: flex-start;
}
.dur-cell::before {
  content: "DUR: ";
  color: #8a94a7 !important;
  opacity: 0.5 !important;
  margin-right: 2px;
  font-weight: 400;
}
body.edit-mode-unlocked .dur-cell::before {
  display: none !important;
}
.cum-cell {
  grid-area: cum;
  width: auto !important;
  color: var(--text-muted);
  font-size: 14px !important;
  justify-content: center;
  opacity: 0.8;
}
.cum-cell::before {
  content: "TOT: ";
  color: #8a94a7 !important;
  opacity: 0.5 !important;
  margin-right: 2px;
  font-weight: 400;
}
.timer-col {
  grid-area: timer;
  width: auto !important;
  justify-content: flex-end;
  text-align: right;
}
.timer-cell {
  font-size: 17px !important;
  font-weight: 600 !important;
}
.timer-pending {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
}
.timer-done {
  color: var(--success);
}
.timer-late {
  color: var(--danger);
  font-size: 13px;
  font-weight: 400;
}
.timer-early {
  color: var(--success);
  font-size: 13px;
  font-weight: 400;
}
.timer-negative {
  color: var(--danger) !important;
  animation: blink-red 2s ease-in-out infinite;
}
@keyframes blink-red {
  0%,
  100% {
    opacity: 1;
  }
  12.5% {
    opacity: 0.35;
  }
  25% {
    opacity: 1;
  }
}

.ping-badge {
  font-size: 10px;
  vertical-align: middle;
  opacity: 0.6;
}

.ping-cell-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #737d8f;
  cursor: pointer;
  transition:
    color 0.2s ease,
    background 0.2s ease,
    border-color 0.2s ease,
    opacity 0.2s ease;
  align-self: flex-start;
  flex-shrink: 0;
  margin-left: 8px;
  margin-right: 0;
  margin-top: 1px;
  opacity: 0.55;
  pointer-events: none;
}

body.edit-mode-unlocked .ping-cell-button {
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

body.edit-mode-unlocked .ping-cell-button:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
}

.ping-cell-button.active {
  color: #ffb200;
  opacity: 1;
}

body.edit-mode-unlocked .ping-cell-button.active {
  background: rgba(255, 178, 0, 0.1);
  border-color: rgba(255, 178, 0, 0.2);
}

body.edit-mode-unlocked .ping-cell-button.active:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* Flex & Settings UI */
.btn-part-settings {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.btn-part-settings svg {
  width: 14px;
  height: 14px;
}

.btn-part-settings:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text);
}

body.edit-mode-unlocked .ping-cell-button.active:hover {
  background: rgba(255, 178, 0, 0.15);
  border-color: rgba(255, 178, 0, 0.3);
}

.ping-cell-button:hover {
  color: #8a94a7;
  opacity: 0.8;
}

.ping-cell-button.active:hover {
  color: #ffc133;
}

.action-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 3px 5px;
  border-radius: 5px;
  opacity: 0.5;
}
.action-btn:hover {
  opacity: 1;
}

.parts-table tbody tr.empty-row {
  display: table-row !important;
  width: 100%;
}
.parts-table tbody tr.empty-row td {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  text-align: center;
  min-height: 300px;
  padding: 86px 16px 88px;
  color: var(--text-dim);
  font-size: 13px;
  grid-area: auto !important;
  border: none !important;
}
.empty-state-wrap {
  display: flex !important;
  flex-direction: column !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}
.empty-state-text {
  order: 2 !important;
  max-width: 320px;
  line-height: 1.7;
  margin-top: 0;
  margin-bottom: 28px;
}
.empty-add-part-btn {
  order: 1 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  margin-top: 28px !important;
  margin-bottom: 6px !important;
  border: 1px solid rgba(168, 85, 247, 0.56);
  border-radius: 999px;
  background: radial-gradient(
    circle at 30% 30%,
    rgba(183, 112, 255, 0.98),
    rgba(111, 76, 255, 0.8)
  );
  box-shadow:
    0 12px 26px rgba(129, 86, 255, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  color: #fff;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.empty-add-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}
.empty-add-meta {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
.empty-icon-img {
  display: none !important;
}

@keyframes icon-float-mobile {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-8px) rotate(1deg);
  }
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 20px 16px 24px;
  width: 100%;
  max-width: 380px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-shadow: 0 -8px 40px rgba(168, 85, 247, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.06);
  animation: modalPop 0.22s ease;
  position: relative;
}
@keyframes slideUp {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
@keyframes modalPop {
  from {
    transform: translateY(14px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}
.modal-box h2 {
  font-size: 18px;
  font-weight: 800;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 16px;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.modal-room-id {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.modal-room-id code {
  background: var(--bg-input);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-a);
}
#qrcode-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 228px;
  margin: 14px 0;
  padding: 14px;
  background: var(--bg-input);
  border-radius: 14px;
}
#qrcode-container canvas,
#qrcode-container img {
  display: block;
  width: min(200px, 100%);
  height: auto;
  border-radius: 10px;
}
.qr-fallback-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
  text-align: center;
}
.modal-url {
  font-size: 11px;
  color: var(--text-dim);
  word-break: break-all;
  margin: 6px 0 12px;
  text-align: center;
}
.modal-hint {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  margin-top: 10px;
}
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-group-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.duration-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkbox-input {
  width: 20px;
  height: 20px;
  accent-color: var(--accent-a);
}
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.modal-actions .btn {
  flex: 1;
}

/* Part settings modal */
#modal-part-settings {
  padding: max(12px, env(safe-area-inset-top, 0px)) 12px
    max(16px, env(safe-area-inset-bottom, 0px));
}

#modal-part-settings .modal-box {
  width: min(100%, 420px);
  max-width: 420px;
  max-height: calc(100vh - 24px);
  padding: 20px 16px 18px;
}

#modal-part-settings .modal-box h2 {
  margin: 0 40px 14px 0 !important;
  font-size: clamp(22px, 6vw, 26px) !important;
  line-height: 1.12;
}

#modal-part-settings .settings-group {
  margin-top: 12px !important;
}

#modal-part-settings .settings-group > div:first-child {
  gap: 12px;
  width: 100%;
  align-items: center !important;
  justify-content: space-between !important;
}

#modal-part-settings .edit-lock-switch {
  display: inline-flex;
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: 72px;
  margin-left: auto;
  padding-right: 0 !important;
}

#modal-part-settings .edit-lock-track {
  width: 72px;
  min-width: 72px;
}

#modal-part-settings
  .settings-group
  > div:first-child
  > label:not(.edit-lock-switch) {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 18px !important;
  font-weight: 700 !important;
  line-height: 1.25;
  padding-right: 8px;
}

#modal-part-settings p {
  margin: 0 0 16px !important;
  font-size: 16px !important;
  line-height: 1.55 !important;
}

#modal-part-settings #flex-options {
  margin-top: 2px;
  padding: 12px !important;
  border-radius: 14px !important;
  background: rgba(255, 255, 255, 0.03) !important;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

#modal-part-settings #flex-options > div {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px !important;
}

#modal-part-settings #flex-options > div > div {
  min-width: 0;
  padding: 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

#modal-part-settings #flex-options label {
  margin-bottom: 6px !important;
  font-size: 12px !important;
  font-weight: 800 !important;
  line-height: 1.3 !important;
  letter-spacing: 0.02em;
}

#modal-part-settings #flex-options label span {
  display: inline-block;
  margin-top: 3px;
  font-size: 11px !important;
}

#modal-part-settings .num-spin {
  width: 100% !important;
  max-width: none;
}

#modal-part-settings .num-input {
  width: 100% !important;
  min-height: 42px;
  padding: 8px 10px !important;
  font-size: 18px !important;
  text-align: center;
}

#modal-part-settings .num-spin-btns {
  width: 44px !important;
}

#modal-part-settings .num-spin-up,
#modal-part-settings .num-spin-dn {
  padding: 8px 6px !important;
}

#modal-part-settings .num-spin-up svg,
#modal-part-settings .num-spin-dn svg {
  width: 18px !important;
  height: 18px !important;
}

#modal-part-settings .modal-actions {
  margin-top: 18px !important;
}

#modal-part-settings #btn-save-part-settings {
  min-height: 50px !important;
  font-size: 18px;
  font-weight: 800;
  border-radius: 14px;
}

@media (max-width: 380px) {
  #modal-part-settings .modal-box {
    padding: 18px 14px 16px;
  }

  #modal-part-settings #flex-options > div {
    grid-template-columns: 1fr;
  }
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 8px 12px max(8px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  font-size: 10.5px;
  color: var(--text-dim);
  background: linear-gradient(
    180deg,
    rgba(19, 20, 23, 0.94),
    rgba(26, 27, 30, 0.98)
  );
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  display: flex;
  justify-content: center;
  align-items: center;
}
.app-footer span {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 8px;
  line-height: 1.4;
}
.footer-hidden {
  transform: translateY(100%);
}
.footer-contact {
  color: var(--accent-mid);
  text-decoration: none;
  white-space: nowrap;
}

/* Dual screen */
.dual-screen-body {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.dual-screen {
  text-align: center;
  padding: 24px 16px;
}
.dual-part-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}
.dual-part-index {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}
.dual-timer {
  font-size: 72px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(168, 85, 247, 0.4));
  line-height: 1;
  margin-bottom: 16px;
}
.dual-timer.timer-negative {
  background: none;
  -webkit-text-fill-color: var(--danger);
  -webkit-background-clip: unset;
  background-clip: unset;
  filter: drop-shadow(0 0 15px rgba(239, 68, 68, 0.6));
  animation: blink-red 0.8s ease-in-out infinite;
}
.dual-status-bar {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.dual-expected {
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  display: inline-block;
}
.dual-expected.positive {
  color: var(--danger);
}
.dual-expected.negative {
  color: var(--success);
}

/* Viewer mode */
.is-viewer .app-main {
  display: block;
}
.viewer-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--accent-b);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Custom Notification Modal */
.notification-container {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.notification-container.show {
  opacity: 1;
  pointer-events: all;
}

/* Toast (senza azioni): non blocca i click su elementi sottostanti */
.notification-container.notification-toast {
  pointer-events: none;
  background: transparent;
  backdrop-filter: none;
}
.notification-container.notification-toast.show .notification-modal {
  pointer-events: auto;
}

.notification-modal {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 18px;
  box-shadow:
    0 10px 36px rgba(0, 0, 0, 0.5),
    0 0 24px rgba(168, 85, 247, 0.1),
    inset 1px 1px 1px rgba(255, 255, 255, 0.04);
  animation: slideUp 0.25s ease;
}

.notification-modal.success {
  border-color: rgba(34, 197, 94, 0.4);
}

.notification-modal.error {
  border-color: rgba(239, 68, 68, 0.4);
}

.notification-modal.warning {
  border-color: rgba(245, 158, 11, 0.4);
}

.notification-icon {
  font-size: 26px;
  margin-bottom: 10px;
}

.notification-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.notification-message {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 16px;
}

.notification-actions {
  display: flex;
  gap: 10px;
}

.notification-btn {
  flex: 1;
  border: none;
  border-radius: var(--radius-btn);
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font);
}

.notification-btn.primary {
  background: var(--accent-grad);
  color: #fff;
}

.notification-btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--control-text);
  border: 1px solid var(--border);
}

/* Notification message rich text */
.notification-message strong {
  color: var(--accent-a);
  font-weight: 700;
}

.notification-message a {
  color: var(--accent-b);
  text-decoration: none;
  transition: color 0.2s;
}

.notification-message a:hover {
  color: var(--accent-a);
  text-decoration: underline;
}

.notification-message .permission-guide {
  text-align: left;
}

.notification-message .permission-guide p {
  margin: 0 0 10px;
}

.notification-message .permission-guide ul {
  margin: 0 0 12px;
  padding-left: 18px;
}

.notification-message .permission-guide li {
  margin-bottom: 6px;
}

.notification-message .permission-guide-path {
  color: var(--control-text);
  word-break: break-word;
}

/* ─── Template Loader ──────────────────────────────────────── */
.template-loader-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding-left: 12px;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
  border-radius: 8px;
}

.template-loader-overlay.show {
  opacity: 1;
}

.loader {
  width: 18px;
  height: 18px;
  display: inline-block;
  position: relative;
}

.loader::after,
.loader::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid #ffffff;
  position: absolute;
  left: 0;
  top: 0;
  box-sizing: border-box;
  animation: rotation 2s ease-in-out infinite;
}

.loader::after {
  border-color: var(--accent-a);
  animation-delay: 1s;
}

@keyframes rotation {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ─── Custom Template Dropdown ─────────────────────────────── */
.tpl-dropdown {
  position: relative;
  width: 100%;
}

.tpl-trigger {
  width: 100%;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  gap: 8px;
  cursor: pointer;
  text-align: left;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  color: var(--control-text);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.tpl-trigger:hover {
  border-color: var(--accent-a);
}

.tpl-trigger-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--control-text);
}

.tpl-trigger-text.selected {
  color: var(--control-text);
}

.tpl-chevron {
  flex-shrink: 0;
  color: var(--text-dim);
  transition: transform 0.2s ease;
}

.tpl-dropdown.open .tpl-chevron {
  transform: rotate(180deg);
}

.tpl-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-input);
  z-index: 1000;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: panelIn 0.15s ease-out;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tpl-panel[hidden] {
  display: none;
}

.tpl-panel-group-label {
  padding: 8px 12px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}

.tpl-panel-item {
  padding: 11px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background 0.12s;
}

.sound-control-row .btn {
  width: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
}

.tpl-panel-item:hover {
  background: rgba(168, 85, 247, 0.12);
  color: var(--accent-a);
}

.tpl-panel-empty {
  padding: 14px 16px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

/* Small phones: keep controls readable and easy to tap */
@media (max-width: 420px) {
  .topbar {
    height: 62px;
    padding: 0 12px;
  }

  #connectivity-badge {
    font-size: 13px;
  }

  .icon-btn,
  .lang-trigger {
    width: 44px;
    height: 44px;
  }

  .control-panel {
    padding: 14px 10px 18px;
    gap: 12px;
  }

  .card {
    padding: 16px 14px;
  }

  .card-label {
    font-size: 13px;
    margin-bottom: 10px;
  }

  .summary-row {
    gap: 12px;
    padding: 12px 0;
  }

  .summary-label {
    font-size: 15px;
  }

  .summary-value {
    font-size: 18px;
  }

  .summary-card .time-input {
    width: 114px !important;
    min-width: 114px;
    min-height: 44px;
    font-size: 16px;
  }

  .time-input {
    width: 100px;
    min-height: 44px;
    font-size: 16px;
  }

  .text-input,
  .select-input,
  .tpl-trigger {
    min-height: 48px;
    font-size: 17px;
  }

  .num-input {
    min-height: 46px;
    font-size: 22px;
  }

  .num-spin-btns {
    width: 34px;
  }

  .btn {
    min-height: 50px;
    font-size: 16px;
  }

  .btn-large {
    min-height: 56px;
    font-size: 18px;
  }

  .main-controls {
    gap: 12px;
  }

  .main-controls.is-waiting #btn-start,
  .main-controls.is-waiting #btn-reset-timer {
    font-size: 18px;
    padding-top: 18px;
    padding-bottom: 18px;
  }

  .template-actions-top {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .template-actions .btn {
    min-height: 50px;
    font-size: 16px;
  }

  .add-part-time-labels span {
    font-size: 12px;
  }

  .ping-button-toggle {
    width: 40px;
    height: 40px;
  }

  .sound-control-row .btn {
    width: 50px;
    min-width: 50px;
    min-height: 50px;
  }
}

@media (max-width: 360px) {
  .topbar-brand {
    gap: 8px;
  }

  .brand-name {
    font-size: 17px;
  }

  .summary-row {
    gap: 10px;
  }

  .summary-label {
    font-size: 14px;
  }

  .summary-card .time-input {
    width: 108px !important;
    min-width: 108px;
  }

  .template-actions .btn {
    font-size: 15px;
  }

  .add-part-time-labels,
  .add-part-row {
    gap: 8px;
  }
}

/* Phone landscape: maximize workspace by hiding fixed top/bottom bars */
@media (hover: none) and (pointer: coarse) and (orientation: landscape) and (max-height: 540px) {
  .topbar,
  .app-footer {
    display: none !important;
  }

  .app-main {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    min-height: 100vh !important;
    height: 100vh !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden !important;
  }

  .control-panel {
    order: 1 !important; /* Torna a sinistra in orizzontale */
    flex: 0 0 min(42vw, 360px);
    width: min(42vw, 360px);
    max-width: min(42vw, 360px);
    min-width: 300px;
    height: 100vh;
    padding: 14px 12px 16px;
    border-right: 1px solid var(--border);
    border-bottom: none;
    overflow-y: auto;
    overflow-x: hidden;
  }

  .parts-section {
    order: 2 !important; /* Torna a destra in orizzontale */
    flex: 1 1 auto;
    min-width: 0;
    height: 100vh;
    padding: 10px 8px;
    overflow: hidden;
  }

  .table-wrapper {
    height: 100%;
    max-height: 100%;
  }

  .card {
    padding: 14px 12px;
  }

  .control-panel .card-label {
    margin-bottom: 10px;
  }

  .summary-card .time-input,
  .summary-card #expected-end,
  .summary-card #actual-end-val,
  .summary-card #total-measured-val {
    font-size: 15px !important;
  }

  .summary-card .time-input {
    width: 108px !important;
    min-width: 108px;
  }

  .add-part-time-labels,
  .add-part-row,
  .template-actions-top,
  .sound-control-row {
    gap: 8px;
  }
}

/* ─── Meeting Log – Mobile ─────────────────────────────────── */
.log-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent-grad);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
  line-height: 1;
  flex-shrink: 0;
}

.modal-log-box {
  max-width: 100% !important;
  width: 100% !important;
  max-height: 90vh;
  overflow-y: auto;
}

#modal-log-detail .modal-log-box {
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#log-detail-parts {
  display: flex !important;
  flex-direction: column !important;
  grid-template-columns: none !important;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-right: 3px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  flex: 1 1 auto;
  min-height: 0;
}

#log-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  margin-bottom: 8px;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

#log-list li:active {
  background: rgba(168, 85, 247, 0.08);
}

.log-item-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(168, 85, 247, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--accent-a);
}

.log-item-body {
  flex: 1;
  min-width: 0;
}

.log-item-date {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.log-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.log-item-duration {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-a);
  white-space: nowrap;
  flex-shrink: 0;
}

.log-part-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  width: 100%;
  margin: 0 0 6px;
}

.log-part-num {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  min-width: 14px;
  text-align: right;
  flex-shrink: 0;
}

.log-part-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Times inline: Prev → Actual su una riga */
.log-part-times {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.log-part-sched {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
}

.log-part-actual {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.log-part-actual.on-time { color: var(--success); }
.log-part-actual.late    { color: var(--danger); }
.log-part-actual.early   { color: var(--accent-b); }

