:root {
  --bg: #0f1416;
  --bg-elev: #171e21;
  --bg-elev-2: #1f282c;
  --border: #2a3438;
  --text: #eef2f3;
  --text-dim: #9aa8ac;
  --accent: #33c9a3;
  --accent-dim: #1f8f74;
  --accent-soft: rgba(51, 201, 163, 0.14);
  --warn: #e0a53e;
  --warn-soft: rgba(224, 165, 62, 0.14);
  --danger: #e0603e;
  --danger-soft: rgba(224, 96, 62, 0.14);
  --radius: 14px;
  --radius-sm: 9px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: inherit; text-decoration: none; }

button {
  font-family: inherit;
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  font-size: 16px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }

label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin: 14px 0 6px;
  font-weight: 500;
}
label:first-child { margin-top: 0; }

.field { margin-bottom: 2px; }

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 100px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .2px;
}
.brand .logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 600;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  transition: transform .1s, opacity .15s, background .15s;
  width: 100%;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #06231b;
  border: none;
}
.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(224,96,62,.3);
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
}
.btn-sm {
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
}
.btn-row {
  display: flex;
  gap: 10px;
}
.btn-row .btn { flex: 1; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.big-choice {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 24px;
}
.big-choice a, .big-choice button {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  width: 100%;
  text-align: left;
}
.big-choice .icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.big-choice small {
  display: block;
  font-weight: 400;
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 3px;
}
.big-choice button.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 100px;
}
.badge-pending { background: var(--warn-soft); color: var(--warn); }
.badge-verified { background: rgba(90, 150, 220, 0.16); color: #6ea8e6; }
.badge-confirmed { background: var(--accent-soft); color: var(--accent); }
.badge-rejected { background: var(--danger-soft); color: var(--danger); }

.tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 4px;
  margin-bottom: 16px;
}
.tab {
  position: relative;
  flex: 1;
  text-align: center;
  padding: 9px 8px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  border: none;
  background: transparent;
}
.tab.active {
  background: var(--accent);
  color: #06231b;
}
.tab-badge {
  position: absolute;
  top: -6px;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
}

.stat-row {
  display: flex;
  gap: 10px;
}
.stat {
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.stat .value {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}
.stat.warn .value { color: var(--warn); }
.stat .label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.report-item {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}
.report-item .top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.report-item .addr {
  font-weight: 600;
  font-size: 15px;
}
.report-item .meta {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 4px;
}
.report-item .amount {
  font-weight: 700;
  font-size: 16px;
  color: var(--accent);
  margin-top: 8px;
}

.work-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.work-row:last-child { border-bottom: none; }
.work-name {
  font-size: 14px;
  font-weight: 500;
}
.work-price {
  font-size: 12px;
  color: var(--text-dim);
}
.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.qty-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.qty-value {
  width: 48px;
  flex-shrink: 0;
  padding: 6px 2px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  -moz-appearance: textfield;
}
.qty-value::-webkit-outer-spin-button,
.qty-value::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
}
.check-row input[type=checkbox], .check-row input[type=radio] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.check-row .name { font-weight: 600; font-size: 14px; }
.check-row .sub { font-size: 12px; color: var(--text-dim); }

.radio-toggle {
  display: flex;
  gap: 8px;
}
.radio-toggle label {
  flex: 1;
  margin: 0;
  text-align: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
}
.radio-toggle input { display: none; }
.radio-toggle input:checked + span { color: inherit; }
.radio-toggle label.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.calc-preview {
  background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.calc-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
  color: var(--text-dim);
}
.calc-row.total {
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 8px;
}
.calc-row .v { color: var(--text); font-weight: 600; }
.calc-row.total .v { color: var(--accent); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}
.empty-state .icon { font-size: 40px; margin-bottom: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 100px;
  font-size: 14px;
  font-weight: 600;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  max-width: 90vw;
}
.toast.error { border-color: rgba(224,96,62,.4); color: var(--danger); }
.toast.success { border-color: rgba(51,201,163,.4); color: var(--accent); }

.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(15,20,22,.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.who-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  max-width: 640px;
  margin: 0 auto;
}
.who-badge .avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex-shrink: 0;
}
.who-badge .name { font-weight: 700; font-size: 15px; }
.who-badge .rank { font-size: 12px; color: var(--text-dim); }
.who-badge .switch {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 100px;
  background: transparent;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 20px 0 12px;
}
.section-title:first-child { margin-top: 0; }

.hr { height: 1px; background: var(--border); margin: 14px 0; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.text-dim { color: var(--text-dim); }
.text-sm { font-size: 13px; }
.mt-0 { margin-top: 0; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.modal-sheet {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-sheet .modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.close-x {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 16px;
}

table.simple {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.simple th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 600;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
table.simple td {
  padding: 10px 6px;
  border-bottom: 1px solid var(--border);
}
table.simple tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-box {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pill-select {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pill-select .pill {
  padding: 8px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
}
.pill-select .pill.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.schedule-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 6px; }
.schedule-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(112px, 1fr));
  gap: 8px;
  min-width: 800px;
}
.schedule-day { display: flex; flex-direction: column; gap: 6px; }
.schedule-day-head {
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.3;
  padding: 6px 0;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--border);
}
.schedule-day.today .schedule-day-head { border-color: var(--accent); color: var(--accent); }
.schedule-cell {
  aspect-ratio: 1 / 1;
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  border-left-width: 4px;
  background: var(--bg-elev);
  padding: 6px 7px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 2px;
  overflow: hidden;
  color: var(--text);
  font-family: inherit;
}
.schedule-cell.empty {
  color: var(--text-dim);
  font-size: 22px;
  font-weight: 300;
  border-left-width: 1px;
}
.schedule-cell.filled {
  align-items: flex-start;
  text-align: left;
  justify-content: flex-start;
  font-size: 11px;
  line-height: 1.3;
  cursor: grab;
  touch-action: none;
}
.schedule-cell.dragging-source { opacity: 0.35; }
.schedule-cell.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--bg-hover, var(--bg-elev)); }
.schedule-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  margin: 0;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  opacity: 0.92;
  transition: none;
}
.schedule-cell-time { font-weight: 800; font-size: 12px; }
.schedule-cell-addr {
  font-weight: 600;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.schedule-cell-type, .schedule-cell-brigade { color: var(--text-dim); width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schedule-cell.status-new { border-left-color: var(--warn); }
.schedule-cell.status-assigned { border-left-color: #6ea8e6; }
.schedule-cell.status-done { border-left-color: var(--accent); opacity: 0.8; }
.schedule-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
