/* TBM Mobile Styles */
* { box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
    background: #f3f4f6;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;
}
button, .m-tbm-row, .m-tab, .m-new-btn, .m-detail-btn, .m-load-more,
.picker-item, .split-radio-item, .split-session-item, .pull-btn,
.de-save-btn, .de-group-btn, .de-split-btn, .pill-btn, .worker-card,
[onclick] {
    touch-action: manipulation;
}
@media (min-width: 480px) {
    body { max-width: 480px; margin: 0 auto; min-height: 100vh; }
}

/* Header */
.m-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    padding: 0.875rem 1rem;
    padding-top: calc(0.875rem + env(safe-area-inset-top));
}
.m-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.m-header h1 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
}
.m-header .m-date {
    font-size: 0.75rem;
    opacity: 0.8;
}
.m-new-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1.5px solid rgba(255,255,255,0.4);
    border-radius: 2rem;
    font-size: 0.8125rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.m-new-btn:active { background: rgba(255,255,255,0.3); }

/* Tabs */
.m-tabs {
    display: flex;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 90;
}
.m-tab {
    flex: 1;
    padding: 0.75rem;
    text-align: center;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #9ca3af;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    -webkit-tap-highlight-color: transparent;
}
.m-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}
.m-tab .tab-count {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    border-radius: 9px;
    background: #e5e7eb;
    color: #6b7280;
    font-size: 0.6875rem;
    font-weight: 700;
    text-align: center;
    margin-left: 0.25rem;
    padding: 0 0.25rem;
}
.m-tab.active .tab-count {
    background: #dbeafe;
    color: #1d4ed8;
}

/* Content area */
.m-content {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
    min-height: 60vh;
}

/* Date group */
.m-date-group {
    padding: 0.5rem 1rem 0.25rem;
}
.m-date-label {
    font-size: 0.6875rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* TBM list row */
.m-tbm-row {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background: white;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.m-tbm-row:active { background: #f9fafb; }
.m-tbm-row:first-child { border-top: 1px solid #e5e7eb; }

.m-row-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-right: 0.75rem;
}
.m-row-status.draft { background: #f59e0b; }
.m-row-status.completed { background: #10b981; }
.m-row-status.cancelled { background: #ef4444; }

.m-row-body {
    flex: 1;
    min-width: 0;
}
.m-row-main {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.m-row-sub {
    font-size: 0.6875rem;
    color: #9ca3af;
    margin-top: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.m-row-right {
    flex-shrink: 0;
    text-align: right;
    margin-left: 0.75rem;
}
.m-row-count {
    font-size: 0.8125rem;
    font-weight: 700;
    color: #1f2937;
}
.m-row-count-label {
    font-size: 0.625rem;
    color: #9ca3af;
}
.m-row-time {
    font-size: 0.625rem;
    color: #9ca3af;
    margin-top: 0.125rem;
}

/* TBM detail expanded */
.m-tbm-detail {
    display: none;
    background: #f9fafb;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border-bottom: 1px solid #e5e7eb;
}
.m-tbm-row.expanded + .m-tbm-detail { display: block; }
.m-detail-row {
    display: flex;
    padding: 0.25rem 0;
    font-size: 0.75rem;
}
.m-detail-label {
    color: #6b7280;
    width: 50px;
    flex-shrink: 0;
}
.m-detail-value {
    color: #1f2937;
    font-weight: 500;
    flex: 1;
}
.m-detail-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #e5e7eb;
}
.m-detail-btn {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background: white;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}
.m-detail-btn:active { background: #f3f4f6; }
.m-detail-btn.primary {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}
.m-detail-btn.primary:active { background: #1d4ed8; }
.m-detail-btn.danger {
    color: #ef4444;
    border-color: #fca5a5;
}

/* Empty state */
.m-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #9ca3af;
}
.m-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}
.m-empty-text {
    font-size: 0.875rem;
}
.m-empty-sub {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Load more */
.m-load-more {
    display: block;
    width: calc(100% - 2rem);
    margin: 0.75rem 1rem;
    padding: 0.75rem;
    border: 1px dashed #d1d5db;
    border-radius: 0.75rem;
    background: white;
    font-size: 0.8125rem;
    color: #6b7280;
    cursor: pointer;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}
.m-load-more:active { background: #f3f4f6; }

/* Loading skeleton */
.m-skeleton {
    height: 56px;
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-bottom: 1px solid #f3f4f6;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Bottom nav */
.m-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 68px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    display: flex;
    align-items: center;
    justify-content: space-around;
}
@media (min-width: 480px) {
    .m-bottom-nav { max-width: 480px; margin: 0 auto; }
}
.m-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    text-decoration: none;
    color: #9ca3af;
    font-family: inherit;
    cursor: pointer;
    padding: 0.5rem 0.25rem;
    -webkit-tap-highlight-color: transparent;
    border: none;
    background: none;
}
.m-nav-item.active { color: #2563eb; }
.m-nav-item svg {
    width: 26px;
    height: 26px;
    margin-bottom: 4px;
}
.m-nav-item.active svg { stroke-width: 2.5; }
.m-nav-label {
    font-size: 0.6875rem;
    font-weight: 500;
}
.m-nav-item.active .m-nav-label { font-weight: 700; }

/* Detail badge */
.m-detail-badge {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    margin-left: 0.375rem;
    vertical-align: middle;
}
.m-detail-badge.incomplete {
    background: #fef3c7;
    color: #92400e;
}
.m-detail-badge.complete {
    background: #d1fae5;
    color: #065f46;
}

/* Worker card status indicator */
.de-worker-card.filled {
    background: #f0fdf4;
    border-left: 3px solid #10b981;
    padding-left: calc(0.625rem - 3px);
}
.de-worker-card.unfilled {
    border-left: 3px solid #f59e0b;
    padding-left: calc(0.625rem - 3px);
}
.de-worker-status {
    font-size: 0.625rem;
    font-weight: 600;
    margin-left: 0.375rem;
}
.de-worker-status.ok { color: #059669; }
.de-worker-status.missing { color: #d97706; }

/* Group select */
.de-worker-check {
    width: 20px;
    height: 20px;
    accent-color: #2563eb;
    margin-right: 0.5rem;
    flex-shrink: 0;
}
.de-group-bar {
    display: none;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 0.5rem;
    padding: 0.5rem 0.625rem;
    margin: 0 1rem 0.5rem;
    font-size: 0.75rem;
    color: #1e40af;
}
.de-group-bar.visible { display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; }
.de-group-btn {
    padding: 0.25rem 0.5rem;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    cursor: pointer;
}
.de-select-all-row {
    display: flex;
    align-items: center;
    padding: 0.375rem 1rem;
    font-size: 0.75rem;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
}

/* Detail edit bottom sheet */
.detail-edit-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9000;
}
.detail-edit-sheet {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9001;
    background: white;
    border-radius: 1rem 1rem 0 0;
    max-height: 90vh;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
}
.de-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 1rem 1rem 0;
    border-radius: 1rem 1rem 0 0;
    z-index: 1;
}
.de-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.de-header h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.de-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
}
/* Picker popup */
.picker-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9100;
}
.picker-sheet {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9101;
    background: white;
    border-radius: 1rem 1rem 0 0;
    max-height: 70vh;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
}
.picker-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 0.875rem 1rem 0.5rem;
    border-radius: 1rem 1rem 0 0;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.picker-header h4 { margin: 0; font-size: 0.9375rem; font-weight: 700; }
.picker-close {
    background: none;
    border: none;
    font-size: 1.125rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
}
.picker-list { padding: 0.25rem 0; }
.picker-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: #1f2937;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    -webkit-tap-highlight-color: transparent;
}
.picker-item:active { background: #f3f4f6; }
.picker-item.selected { background: #eff6ff; color: #1d4ed8; font-weight: 600; }
.picker-item-sub { font-size: 0.6875rem; color: #9ca3af; margin-left: 0.375rem; }
.picker-divider {
    padding: 0.375rem 1rem;
    font-size: 0.6875rem;
    font-weight: 700;
    color: #6b7280;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}
.picker-add-row {
    display: flex;
    gap: 0.375rem;
    padding: 0.625rem 1rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    position: sticky;
    bottom: 0;
}
.picker-add-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
}
.picker-add-btn {
    padding: 0.5rem 0.75rem;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.de-worker-list { padding: 0 1rem; }
.de-worker-card {
    padding: 0.625rem 0;
    border-bottom: 1px solid #f3f4f6;
}
.de-worker-card:last-child { border-bottom: none; }
.de-worker-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1f2937;
}
.de-worker-job {
    font-size: 0.75rem;
    color: #6b7280;
}
.de-worker-fields {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-top: 0.375rem;
}
.de-field-row {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}
.de-field-label {
    font-size: 0.6875rem;
    color: #6b7280;
    width: 32px;
    flex-shrink: 0;
}
.de-field-row select {
    flex: 1;
    padding: 0.4375rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    background: white;
}
.de-save-area {
    padding: 0.75rem 1rem 1rem;
    position: sticky;
    bottom: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
}
.de-save-btn {
    width: 100%;
    padding: 0.75rem;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    font-weight: 700;
    cursor: pointer;
}
.de-save-btn:disabled { opacity: 0.5; }

/* My TBM highlight */
.m-tbm-row.my-tbm {
    border-left: 3px solid #2563eb;
}
.m-leader-badge {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    margin-left: 0.25rem;
    background: #eff6ff;
    color: #1d4ed8;
}
.m-transfer-badge {
    display: inline-block;
    font-size: 0.5625rem;
    font-weight: 600;
    padding: 0.0625rem 0.3125rem;
    border-radius: 0.25rem;
    margin-left: 0.25rem;
    background: #fef3c7;
    color: #92400e;
}
.m-work-hours-tag {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.0625rem 0.25rem;
    border-radius: 0.25rem;
    margin-left: 0.25rem;
    background: #dbeafe;
    color: #1d4ed8;
}

/* Split sheet */
.split-sheet {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9201;
    background: white;
    border-radius: 1rem 1rem 0 0;
    max-height: 85vh;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
}
.split-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9200;
}
.split-header {
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
}
.split-header h4 { margin: 0 0 0.25rem; font-size: 0.9375rem; font-weight: 700; }
.split-header p { margin: 0; font-size: 0.75rem; color: #6b7280; }
.split-body { padding: 0.75rem 1rem; }
.split-field { margin-bottom: 0.75rem; }
.split-field label { display: block; font-size: 0.75rem; font-weight: 600; color: #374151; margin-bottom: 0.25rem; }
.split-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}
.split-radio-group { display: flex; gap: 0.5rem; margin-top: 0.25rem; }
.split-radio-item {
    flex: 1;
    padding: 0.5rem;
    border: 1.5px solid #d1d5db;
    border-radius: 0.5rem;
    text-align: center;
    font-size: 0.8125rem;
    cursor: pointer;
    background: white;
}
.split-radio-item.active {
    border-color: #2563eb;
    background: #eff6ff;
    color: #1d4ed8;
    font-weight: 600;
}
.split-session-list { margin-top: 0.5rem; }
.split-session-item {
    padding: 0.625rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    margin-bottom: 0.375rem;
    cursor: pointer;
    font-size: 0.8125rem;
}
.split-session-item:active, .split-session-item.active {
    border-color: #2563eb;
    background: #eff6ff;
}
.split-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid #e5e7eb;
}
.split-btn {
    width: 100%;
    padding: 0.75rem;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
}
.split-btn:disabled { opacity: 0.5; }

/* Pull sheet */
.pull-sheet {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9101;
    background: white;
    border-radius: 1rem 1rem 0 0;
    max-height: 85vh;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
}
.pull-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9100;
}
.pull-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    border-radius: 1rem 1rem 0 0;
    z-index: 1;
}
.pull-header h4 { margin: 0; font-size: 0.9375rem; font-weight: 700; }
.pull-header p { margin: 0.25rem 0 0; font-size: 0.75rem; color: #6b7280; }
.pull-member-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f3f4f6;
}
.pull-member-info { flex: 1; }
.pull-member-name { font-size: 0.875rem; font-weight: 600; color: #1f2937; }
.pull-member-sub { font-size: 0.6875rem; color: #9ca3af; margin-top: 0.125rem; }
.pull-btn {
    padding: 0.375rem 0.75rem;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
}
.pull-btn:disabled {
    background: #d1d5db;
    color: #9ca3af;
    cursor: default;
}

/* de-split-btn in detail edit */
.de-split-btn {
    padding: 0.25rem 0.5rem;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    margin-left: auto;
}
.de-split-btn:active { background: #e5e7eb; }

/* Toast */
.toast-container {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}
@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}

/* Loading overlay */
.m-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(255,255,255,0.75);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}
.m-loading-overlay.active { display: flex; }
.m-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.m-loading-text {
    font-size: 0.875rem;
    color: #6b7280;
}
