:root {
    --bg: #0f1012;
    --surface: #1a1b1e;
    --surface-2: #232428;
    --text: #ffffff;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    --green: #22c55e;
    --red: #ef4444;
    --blue: #3b82f6;
    --amber: #f59e0b;
    --border-radius: 12px;
  }
  
  * { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }
  
  body {
    background-color: var(--bg);
    color: var(--text);
    padding: 30px 20px;
    display: flex;
    justify-content: center;
    min-height: 100vh;
  }
  
  .container {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  
  /* Header */
  .header { text-align: center; margin-bottom: 5px; margin-top: 28px; }
  .header h1 { font-size: 26px; font-weight: 800; letter-spacing: 0.5px; }
  .header p { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-top: 6px; text-transform: uppercase; letter-spacing: 1px; }
  
  /* Cards */
  .card {
    background-color: var(--surface);
    border-radius: var(--border-radius);
    padding: 16px 18px;
  }
  
  /* Time/Date */
  .time-card {
    display: flex; justify-content: center; align-items: center; gap: 10px;
  }
  .time-card .time { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
  .time-card .sep { color: var(--text-muted); }
  .time-card .date { font-size: 15px; font-weight: 500; }
  
  /* Site match card */
  .site-card {
    padding: 14px 18px;
    cursor: pointer;
    transition: background-color 0.2s;
    border: 1px solid transparent;
  }
  .site-card:active { background-color: var(--surface-2); }
  .site-card.matched { border-color: rgba(34, 197, 94, 0.3); }
  .site-card.no-match { border-color: rgba(239, 68, 68, 0.3); }
  .site-card.locating { border-color: rgba(59, 130, 246, 0.3); }
  
  .site-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 6px;
  }
  .site-status {
    display: flex; align-items: center; gap: 8px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  }
  .site-status.matched { color: var(--green); }
  .site-status.no-match { color: var(--red); }
  .site-status.locating { color: var(--blue); }
  
  .site-status .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: currentColor;
  }
  .site-status.locating .dot { animation: pulse 1.2s ease-in-out infinite; }
  @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
  
  .site-refresh {
    background: rgba(59, 130, 246, 0.15);
    border-radius: 50%; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    border: none;
  }
  .site-refresh:active { transform: scale(0.9); }
  .site-refresh.spinning svg { animation: spin 1s linear infinite; }
  .site-refresh svg { width: 16px; height: 16px; color: var(--blue); }
  @keyframes spin { 100% { transform: rotate(360deg); } }
  
  .site-name {
    font-size: 16px; font-weight: 700; color: var(--text);
    margin-bottom: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .site-meta {
    font-size: 12px; color: var(--text-muted);
    display: flex; gap: 8px; align-items: center;
  }
  .site-distance {
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
  }
  
  /* Team selector */
  .team-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 13px 16px;
    background: var(--surface);
    border-radius: var(--border-radius);
  }
  .team-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .team-select {
    width: 100%; padding: 14px 18px;
    background-color: var(--surface-2);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: var(--text); font-size: 16px; font-weight: 500;
    outline: none; transition: border-color 0.2s;
  }
  .team-select:focus { border-color: rgba(255,255,255,0.25); }
  .team-display {
    width: 100%; padding: 14px 18px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    background-color: var(--surface-2);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: var(--text); font-size: 16px; font-weight: 600;
    outline: none; cursor: pointer; text-align: left;
  }
  .team-display:active { border-color: rgba(255,255,255,0.25); }
  .team-chevron { color: var(--text-muted); font-size: 14px; }
  
  /* Buttons */
  .button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; margin-bottom: 16px; }
  .btn {
    padding: 32px 12px; border: none; border-radius: 16px;
    color: white; font-size: 17px; font-weight: 800; cursor: pointer;
    transition: transform 0.1s, opacity 0.2s, box-shadow 0.2s;
    letter-spacing: 0.3px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex; flex-direction: column; align-items: center; gap: 4px;
  }
  .btn:active:not(:disabled) { transform: scale(0.96); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
  .btn:disabled { 
    opacity: 0.35; 
    pointer-events: none; 
    background-color: var(--surface-2) !important;
    color: var(--text-dim) !important;
  }
  .btn-sub { font-size: 11px; font-weight: 600; opacity: 0.85; }
  .btn-start { background-color: var(--green); }
  .btn-end { background-color: var(--red); }
  
  .block-msg {
    text-align: center; font-size: 12px; color: var(--amber);
    margin-bottom: 14px; padding: 10px;
    background: rgba(245, 158, 11, 0.08);
    border-radius: 8px;
    display: none;
  }
  .block-msg.show { display: block; }
  
  /* Records */
  .records-section { margin-top: 6px; }
  .records-title { 
    font-size: 12px; font-weight: 700; color: var(--text-muted); 
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px;
    display: flex; justify-content: space-between; align-items: center;
  }
  .records-summary { display: flex; align-items: center; gap: 8px; }
  .sync-status {
    display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
    border-radius: 4px; background: rgba(34, 197, 94, 0.14);
    color: var(--green); font-size: 10px; font-weight: 700;
  }
  .sync-status.pending { background: rgba(245, 158, 11, 0.14); color: var(--amber); }
  .sync-status.syncing { background: rgba(59, 130, 246, 0.14); color: var(--blue); }
  .records-total { color: var(--text); font-weight: 800; font-size: 13px; }
  .records-list { display: flex; flex-direction: column; gap: 8px; }
  
  .record-item {
    background-color: var(--surface);
    border-radius: var(--border-radius);
    padding: 12px 14px;
    position: relative;
    overflow: hidden;
  }
  .record-item::before {
    content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0;
  }
  .record-item.start::before { background-color: var(--green); }
  .record-item.end::before { background-color: var(--red); }
  
  .record-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; padding-left: 10px; }
  .record-type { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; }
  .record-type.start { color: var(--green); }
  .record-type.end { color: var(--red); }
  .record-time { font-size: 13px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
  .record-site { font-size: 13px; color: var(--text); padding-left: 10px; font-weight: 500; margin-bottom: 2px; }
  .record-duration { font-size: 11px; color: var(--text-muted); padding-left: 10px; }
  .record-note { font-size: 11px; font-weight: 700; color: var(--red); padding-left: 10px; margin-top: 3px; }
  
  .empty-state { text-align: center; color: var(--text-dim); font-size: 13px; padding: 16px 0; }
  
  /* Overlay */
  .overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.85);
    display: none; flex-direction: column; align-items: center; justify-content: center;
    z-index: 100; opacity: 0; transition: opacity 0.3s;
  }
  .overlay.active { display: flex; opacity: 1; }
  .overlay-content {
    background: var(--surface); padding: 28px; border-radius: 20px;
    text-align: center; width: 90%; max-width: 320px;
  }
  .overlay-icon { font-size: 42px; margin-bottom: 12px; }
  .overlay-title { font-size: 21px; font-weight: 800; margin-bottom: 8px; }
  .overlay-site { font-size: 14px; color: var(--text); margin-bottom: 4px; font-weight: 600; }
  .overlay-desc { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 22px; }
  .overlay-btn {
    width: 100%; padding: 14px; background: rgba(255,255,255,0.1); border: none;
    border-radius: 12px; color: white; font-size: 15px; font-weight: 600; cursor: pointer;
  }
  
  /* Loading indicator for sites */
  .sites-loading {
    font-size: 11px; color: var(--text-dim);
    text-align: center; padding: 4px;
  }
  
  /* Warning modal (auto-end countdown) */
  .warning-modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.92);
    display: none; flex-direction: column; align-items: center; justify-content: center;
    z-index: 200; padding: 20px;
  }
  .warning-modal.active { display: flex; }
  .warning-content {
    background: var(--surface);
    border: 2px solid var(--amber);
    padding: 26px 22px; border-radius: 18px;
    text-align: center; width: 100%; max-width: 340px;
    animation: warning-pulse 1.2s ease-in-out infinite;
  }
  @keyframes warning-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    50% { box-shadow: 0 0 0 12px rgba(245, 158, 11, 0); }
  }
  .warning-icon { font-size: 44px; margin-bottom: 10px; }
  .warning-title { 
    font-size: 19px; font-weight: 800; color: var(--amber);
    margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
  }
  .warning-msg { font-size: 14px; color: var(--text); margin-bottom: 4px; line-height: 1.4; }
  .warning-site { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; font-weight: 600; }
  
  .countdown {
    font-size: 56px; font-weight: 800; color: var(--amber);
    font-variant-numeric: tabular-nums; line-height: 1;
    margin: 8px 0 18px;
  }
  
  .warning-buttons {
    display: flex; flex-direction: column; gap: 10px;
  }
  .warning-btn {
    padding: 16px; border: none; border-radius: 12px;
    font-size: 15px; font-weight: 700; cursor: pointer;
    color: white;
  }
  .warning-btn-continue { background-color: var(--green); }
  .warning-btn-end { background-color: var(--red); }
  .warning-btn:active { transform: scale(0.97); }
  
  /* Time picker modal (after auto-end) */
  .time-modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.9);
    display: none; flex-direction: column; align-items: center; justify-content: center;
    z-index: 200; padding: 20px;
  }
  .time-modal.active { display: flex; }
  .time-content {
    background: var(--surface);
    padding: 24px 20px; border-radius: 18px;
    width: 100%; max-width: 340px;
  }
  .time-title {
    font-size: 17px; font-weight: 800; margin-bottom: 6px; text-align: center;
  }
  .time-subtitle {
    font-size: 12px; color: var(--text-muted); margin-bottom: 18px; text-align: center;
  }
  .time-option {
    display: flex; flex-direction: column; gap: 2px;
    padding: 14px 16px; background: var(--surface-2);
    border-radius: 10px; cursor: pointer; margin-bottom: 8px;
    border: 1px solid transparent;
    transition: border-color 0.15s;
  }
  .time-option:active { border-color: var(--blue); }
  .time-option-label { font-size: 13px; color: var(--text-muted); font-weight: 600; }
  .time-option-value { font-size: 16px; color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
  .time-option-detail { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
  
  .time-input-row {
    display: flex; gap: 8px; align-items: center; margin-top: 10px;
  }
  .time-input {
    flex: 1; padding: 12px; background: var(--bg);
    border: 1px solid var(--surface-2); border-radius: 8px;
    color: var(--text); font-size: 15px; font-weight: 600;
    text-align: center; font-variant-numeric: tabular-nums;
  }
  .time-confirm-btn {
    padding: 12px 18px; background: var(--blue); border: none;
    border-radius: 8px; color: white; font-weight: 700; cursor: pointer;
  }
  .site-change { margin-top: 12px; width: 100%; padding: 10px; background: var(--surface-2); border: 1px solid var(--surface-2); border-radius: 8px; color: var(--blue); font-size: 13px; font-weight: 600; cursor: pointer; }
  .site-change:active { background: var(--surface); }
  .picker-modal { display: none; position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,0.7); padding: 40px 16px; justify-content: center; align-items: flex-start; }
  .picker-modal.show { display: flex; }
  .picker-content { width: 100%; max-width: 440px; background: var(--surface); border-radius: var(--border-radius); overflow: hidden; display: flex; flex-direction: column; max-height: 80vh; }
  .picker-header { display: flex; justify-content: space-between; align-items: center; padding: 16px; font-size: 15px; font-weight: 700; border-bottom: 1px solid var(--surface-2); }
  .picker-close { background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; padding: 4px 8px; }
  .picker-search { margin: 12px 16px; padding: 12px; background: var(--bg); border: 1px solid var(--surface-2); border-radius: 8px; color: var(--text); font-size: 15px; }
  .picker-list { overflow-y: auto; padding: 0 8px 12px; }
  .picker-item { padding: 12px; border-radius: 8px; cursor: pointer; border-bottom: 1px solid var(--surface-2); }
  .picker-item:active { background: var(--surface-2); }
  .picker-item-name { font-size: 15px; font-weight: 600; color: var(--text); }
  .picker-item-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; display: flex; justify-content: space-between; gap: 8px; }
  .picker-item-dist { color: var(--green); white-space: nowrap; }
  .picker-empty { padding: 24px; text-align: center; color: var(--text-dim); }
  .picker-manual { border-top: 1px solid var(--surface-2); padding: 14px 16px 16px; }
  .picker-manual-label { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
  .picker-manual-row { display: flex; gap: 8px; align-items: stretch; }
  .picker-manual-row .picker-search { margin: 0; flex: 1; }
  .picker-manual-hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
