:root {
  --primary: #122941;
  --primary-light: #1a3a5c;
  --accent: #c87a00;
  --accent-dark: #a56400;
  --bg: #f1f3f4;
  --bg-card: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #52647c;
  --text-light: #8a9bb5;
  --border: #dce3eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(18, 41, 65, 0.08);
  --shadow-lg: 0 4px 16px rgba(18, 41, 65, 0.12);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.app-header {
  background: var(--primary);
  color: white;
  box-sizing: border-box;
  padding: 0 16px;
  padding-top: constant(safe-area-inset-top);
  padding-top: env(safe-area-inset-top);
  height: calc(56px + constant(safe-area-inset-top));
  height: calc(56px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}

.app-header h1 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-title-wrap {
  flex: 1;
  min-width: 0;
}

.subtitle {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-btn {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s;
}

.header-btn:hover {
  background: rgba(255,255,255,0.1);
}

.back-btn {
  margin-right: 8px;
}

.brand-btn {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  margin-right: 10px;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-badge {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}

.content {
  padding: 16px;
  padding-bottom: 98px;
  padding-bottom: calc(80px + constant(safe-area-inset-bottom));
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
  max-width: 600px;
  margin: 0 auto;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
  box-shadow: 0 -6px 18px rgba(0,0,0,0.06);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 10px;
  border: none;
  background: none;
  transition: color 0.2s;
  position: relative;
}

.nav-item.active,
.nav-item.nav-btn-active {
  color: var(--accent);
}

.nav-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 3px;
  font-size: 20px;
}

.nav-badge {
  position: absolute;
  top: -5px;
  right: -10px;
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  box-shadow: 0 0 0 2px #fff;
}

.view-section {
  display: none;
}

.view-section-active {
  display: block;
}

.login-container {
  min-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.login-logo {
  text-align: center;
  color: var(--primary);
}

.login-logo h1 {
  font-size: 34px;
  margin: 0 0 8px;
}

.login-logo p {
  margin: 0;
  color: var(--text-secondary);
}

.login-box {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.hero-card,
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.kw-header {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.kw-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.kw-nav-btn {
  background: none;
  border: none;
  font-size: 26px;
  color: var(--text);
  cursor: pointer;
  padding: 2px 8px;
}

.kw-title {
  font-weight: 700;
  text-align: center;
  font-size: 15px;
}

.kw-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 2px;
}

.kw-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.kw-day {
  text-align: center;
  padding: 8px 2px;
  border-radius: 8px;
  cursor: pointer;
}

.kw-day.today .kw-day-num {
  font-weight: 700;
}

.kw-day.selected .kw-day-num {
  background: var(--accent);
  color: white;
}

.kw-day-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.kw-day-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  margin: 0 auto;
}

.kw-day-dot {
  height: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
}

.kw-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2563eb;
}

.hero-card h3,
.card h2 {
  margin: 0 0 10px;
}

.hero-copy {
  margin: 0;
  line-height: 1.6;
  color: var(--text-secondary);
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.btn {
  border: 0;
  border-radius: 8px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

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

.btn-secondary {
  background: #f8fafc;
  color: var(--text);
  border: 1px solid var(--border);
}

.stack-form {
  display: grid;
  gap: 14px;
}

.stack-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.stack-form input,
.stack-form select,
.stack-form textarea {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: var(--text);
}

.stack-form input:focus,
.stack-form select:focus,
.stack-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200,122,0,0.15);
}

.stack-form textarea {
  min-height: 100px;
  resize: vertical;
}

.section-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.stack-list {
  display: grid;
  gap: 12px;
}

.mini-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

.ticket-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform 0.15s;
}

.ticket-card:active {
  transform: scale(0.98);
}

.ticket-card-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 6px;
  gap: 10px;
}

.ticket-card-title {
  font-weight: 700;
  font-size: 15px;
}

.ticket-card-nr {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-secondary);
}

.ticket-card-address {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.ticket-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: end;
}

.ticket-card-plan {
  font-size: 12px;
}

.ticket-card-plan span {
  display: block;
}

.ticket-card-plan .plan-label {
  color: var(--text-light);
  font-weight: 600;
}

.ticket-card-sla .sla-val {
  color: var(--danger);
  font-weight: 600;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success {
  background: #f0fdf4;
  color: #16a34a;
}

.badge-warning {
  background: #fffbeb;
  color: #d97706;
}

.badge-danger {
  background: #fef2f2;
  color: var(--danger);
}

.badge-info {
  background: #eff6ff;
  color: #2563eb;
}

.mini-card h4 {
  margin: 0 0 8px;
}

.mini-card p {
  margin: 4px 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.mini-card button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.status-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.status-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
}

.status-btn.active-ok {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
  color: var(--success);
}

.status-btn.active-missing {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--danger);
}

.photo-preview {
  display: block;
  width: 100%;
  max-width: 320px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-top: 10px;
}

.signature-pad {
  width: 100%;
  max-width: 360px;
  height: 160px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #fff;
  touch-action: none;
}

.json-preview {
  margin: 0;
  padding: 16px;
  min-height: 180px;
  border-radius: 14px;
  background: #0f172a;
  color: #dbeafe;
  overflow: auto;
  font-size: 13px;
  line-height: 1.55;
}

.detail-section {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.detail-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.track-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.track-btn {
  flex: 1;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
}

.track-btn .track-icon {
  font-size: 15px;
  flex-shrink: 0;
}

.track-btn .track-text {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.track-btn .track-label {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 600;
  line-height: 1.15;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-btn .track-value {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.15;
  flex-shrink: 0;
  white-space: nowrap;
}

.track-btn.active {
  border-color: var(--success);
  background: #f0fdf4;
}

.checklist-section {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.checklist-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.svc-row {
  display: flex;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg);
  gap: 10px;
}

.svc-row:last-child {
  border-bottom: 0;
}

.svc-row-label {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.svc-row-btns {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.svc-btn {
  min-width: 74px;
  padding: 9px 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: white;
  color: var(--text);
}

.svc-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.svc-btn.active-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.svc-input,
.svc-select {
  min-width: 120px;
}

.compact-preview {
  min-height: 140px;
}

.info-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.info-list div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.info-list dt {
  color: var(--text-secondary);
}

.info-list dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.module-pill {
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-weight: 600;
}

.module-pill .pill-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.module-pill .pill-value {
  display: block;
  font-size: 16px;
  color: var(--text);
}

.plain-list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.8;
  color: var(--text-secondary);
}

.status-ok {
  color: var(--success);
}

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

.status-copy {
  margin: 14px 0 0;
  color: var(--text-secondary);
  line-height: 1.5;
}

@media (min-width: 700px) {
  .two-col {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 820px) {
  .info-list div {
    flex-direction: column;
    align-items: flex-start;
  }

  .info-list dd {
    text-align: left;
  }
}
