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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
    min-height: 100vh;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

nav {
    background-color: #252525;
    border-bottom: 2px solid #333;
    padding: 0 24px;
}

nav ul {
    list-style: none;
    display: flex;
    gap: 0;
    max-width: 1200px;
    margin: 0 auto;
}

nav li a {
    display: block;
    padding: 14px 24px;
    color: #999;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

nav li a:hover {
    color: #e0e0e0;
    background-color: #2a2a2a;
}

nav li a.active {
    color: #f5d623;
    border-bottom-color: #f5d623;
}

.page-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 24px;
    color: #fff;
}

.card {
    background-color: #252525;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 24px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background-color: #f5d623;
    color: #1a1a1a;
}

.btn-primary:hover {
    background-color: #e5c613;
}

.btn-primary:disabled {
    background-color: #555;
    color: #999;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #333;
    color: #e0e0e0;
}

.btn-secondary:hover {
    background-color: #444;
}

.btn-danger {
    background-color: #c0392b;
    color: #fff;
}

.btn-danger:hover {
    background-color: #a93226;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 13px;
    color: #999;
    margin-bottom: 6px;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background-color: #333;
    border: 1px solid #444;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: 16px;
    font-weight: 600;
}

.form-input:focus {
    outline: none;
    border-color: #f5d623;
}

.upload-zone {
    border: 2px dashed #444;
    border-radius: 8px;
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: #f5d623;
    background-color: #2a2a2a;
}

.upload-zone p {
    color: #999;
    margin-top: 8px;
}

.upload-zone .upload-icon {
    font-size: 48px;
    color: #555;
}

.image-preview {
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid #333;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.flex-row {
    display: flex;
    gap: 16px;
    align-items: center;
}

.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }

.frame-card {
    background-color: #2a2a2a;
    border: 1px solid #333;
    border-radius: 8px;
    overflow: hidden;
}

.frame-card img {
    width: 100%;
    height: 160px;
    object-fit: contain;
    background-color: #1a1a1a;
    padding: 4px;
}

.frame-card-body {
    padding: 12px;
}

.success-badge {
    display: inline-block;
    background-color: #27ae60;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.measurement-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px);
    margin: -24px;
}

.measurement-image-container {
    position: relative;
    background-color: #111;
    overflow: auto;
    cursor: crosshair;
    flex: 1;
    min-height: 0;
}

.measurement-image-container img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.marker {
    position: absolute;
    width: 24px;
    height: 24px;
    transform: translate(-50%, -50%);
    cursor: grab;
    z-index: 10;
    user-select: none;
    touch-action: none;
}

.marker:active {
    cursor: grabbing;
}

.iris-circle {
    position: absolute;
    border: 2px solid rgba(68, 221, 102, 0.7);
    border-radius: 50%;
    cursor: grab;
    z-index: 8;
    user-select: none;
    touch-action: none;
    box-shadow: 0 0 6px rgba(68, 221, 102, 0.3);
}

.iris-circle:active {
    cursor: grabbing;
}

.iris-circle:hover {
    border-color: rgba(68, 221, 102, 1);
    box-shadow: 0 0 10px rgba(68, 221, 102, 0.5);
}

.iris-resize-handle {
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    background-color: #44dd66;
    border-radius: 50%;
    cursor: nwse-resize;
    z-index: 9;
    opacity: 0;
    transition: opacity 0.15s;
}

.iris-circle:hover .iris-resize-handle {
    opacity: 1;
}

.marker-pupil-left,
.marker-pupil-right {
    width: 6px;
    height: 6px;
    background-color: #ff4444;
    border-radius: 50%;
    box-shadow: 0 0 3px rgba(0,0,0,0.8), 0 0 4px rgba(255,68,68,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.marker-oc {
    color: #44aaff;
    font-size: 20px;
    font-weight: 900;
    text-shadow: 0 0 4px rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}


.marker-nose {
    color: #f5d623;
    font-size: 16px;
    font-weight: 900;
    text-shadow: 0 0 4px rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.center-line {
    position: absolute;
    width: 13px;
    margin-left: -6px;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    background-color: rgba(245, 214, 35, 0.5);
    background-clip: padding-box;
    z-index: 4;
    box-sizing: border-box;
}

.oc-line {
    position: absolute;
    height: 1px;
    background-color: rgba(68, 170, 255, 0.4);
    z-index: 4;
}

.oc-line-vertical {
    position: absolute;
    width: 1px;
    background-color: rgba(68, 170, 255, 0.4);
    z-index: 4;
}

.pd-ruler {
    position: absolute;
    height: 30px;
    z-index: 6;
    cursor: grab;
}

.pd-ruler:active {
    cursor: grabbing;
}

.pd-ruler-tick {
    position: absolute;
    top: 0;
    width: 1px;
    background-color: rgba(245, 214, 35, 0.7);
}

.pd-ruler-label {
    position: absolute;
    top: -14px;
    font-size: 9px;
    color: rgba(245, 214, 35, 0.8);
    transform: translateX(-50%);
    white-space: nowrap;
}

.oc-ruler {
    position: absolute;
    width: 30px;
    z-index: 6;
    cursor: grab;
}

.oc-ruler:active {
    cursor: grabbing;
}

.oc-ruler-tick {
    position: absolute;
    height: 1px;
    background-color: rgba(68, 170, 255, 0.7);
}

.oc-ruler-label {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 9px;
    color: rgba(68, 170, 255, 0.8);
    white-space: nowrap;
}

.marker-label {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    white-space: nowrap;
    padding: 1px 4px;
    border-radius: 3px;
    background-color: rgba(0,0,0,0.7);
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
}
.marker:hover .marker-label,
.marker.dragging .marker-label {
    opacity: 1;
}

.marker-label-left { color: #ff4444; }
.marker-label-right { color: #ff6666; }
.marker-label-oc { color: #44aaff; }
.marker-label-nose { color: #f5d623; }

.top-bar {
    background-color: #252525;
    border-bottom: 1px solid #333;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-shrink: 0;
}

.color-selector-buttons {
    display: flex;
    gap: 6px;
}

.color-target-btn {
    padding: 4px 12px;
    border: 1px solid #555;
    background: #333;
    color: #ccc;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
}

.color-target-btn:hover {
    border-color: #888;
}

.color-target-btn.active {
    border-color: #fff;
    color: #fff;
    background: #444;
}

.color-palette {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
}

.color-swatch {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-radius: 3px;
    cursor: pointer;
    padding: 0;
    transition: border-color 0.15s;
}

.color-swatch:hover {
    border-color: #888;
}

.color-swatch.active {
    border-color: #fff;
}

.bottom-bar {
    position: relative;
    background-color: #252525;
    border-top: 1px solid #333;
    padding: 4px 8px;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.bottom-bar-controls {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.bottom-bar-inputs {
    display: flex;
    gap: 6px;
}

.bottom-bar-field {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.bottom-bar-field label {
    font-size: 9px;
    color: #777;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}

.bottom-bar-field input {
    width: 56px;
    height: 30px;
    padding: 0 4px;
    background-color: #333;
    border: 1px solid #444;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    box-sizing: border-box;
}

.bottom-bar-field input:focus {
    outline: none;
    border-color: #f5d623;
}

.frame-scale-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 30px;
}

.frame-scale-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    background-color: #333;
    border: 1px solid #444;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.frame-scale-btn:hover {
    background-color: #444;
    border-color: #f5d623;
}

.frame-scale-btn:active {
    background-color: #555;
}

#frame-scale-value {
    font-size: 11px;
    color: #e0e0e0;
    font-weight: 600;
    min-width: 32px;
    text-align: center;
}

.bottom-bar-calc-btn {
    height: 30px;
    min-width: 56px;
    padding: 0 10px;
    font-size: 12px !important;
    font-weight: 600;
    white-space: nowrap;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.frame-picker-popup {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    background-color: #2a2a2a;
    border: 1px solid #444;
    border-radius: 8px;
    width: 280px;
    max-height: 400px;
    overflow: hidden;
    z-index: 100;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.5);
}

.frame-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #444;
    font-size: 13px;
    font-weight: 600;
    color: #ccc;
}

.frame-picker-header button {
    background: none;
    border: none;
    color: #999;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
}

.frame-picker-header button:hover {
    color: #fff;
}

.frame-picker-list {
    overflow-y: auto;
    max-height: 350px;
}

.frame-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.15s;
    border-bottom: 1px solid #333;
}

.frame-picker-item:last-child {
    border-bottom: none;
}

.frame-picker-item:hover {
    background-color: #333;
}

.frame-picker-item.selected {
    background-color: #3a3520;
    border-left: 3px solid #f5d623;
}

.frame-picker-item img {
    width: 60px;
    height: 36px;
    object-fit: contain;
    border-radius: 4px;
    border: 1px solid #444;
    background-color: #1a1a1a;
}

.frame-picker-none-icon {
    width: 60px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    border: 1px solid #444;
    background-color: #1a1a1a;
    color: #888;
    font-size: 18px;
    flex-shrink: 0;
}

.frame-picker-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.frame-picker-name {
    font-size: 13px;
    color: #e0e0e0;
    font-weight: 500;
}

.frame-picker-depth {
    font-size: 11px;
    color: #888;
}

.bottom-bar-results {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    margin-left: auto;
}

.bottom-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.bottom-result-label {
    font-size: 9px;
    color: #777;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}

.bottom-result-value {
    width: 56px;
    height: 30px;
    padding: 0 4px;
    background-color: #333;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    text-align: center;
    box-sizing: border-box;
    line-height: 28px;
}

.mode-toggle {
    display: flex;
    background-color: #333;
    border-radius: 4px;
    overflow: hidden;
    height: 30px;
    box-sizing: border-box;
}

.mode-toggle button {
    flex: 1;
    padding: 0 10px;
    border: none;
    background: transparent;
    color: #999;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    height: 30px;
    box-sizing: border-box;
}

.mode-toggle button.active {
    background-color: #f5d623;
    color: #1a1a1a;
}

.no-image-message {
    text-align: center;
    padding: 80px 24px;
    color: #666;
}

.no-image-message p {
    margin-top: 8px;
}

.bottom-bar-center {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 4px;
}

.zoom-btn {
    padding: 0 10px;
    border: 1px solid #555;
    background: #333;
    color: #999;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    height: 30px;
    border-radius: 4px;
    box-sizing: border-box;
}

.zoom-btn.active {
    background-color: #f5d623;
    color: #1a1a1a;
}

.btn-ruler {
    position: relative;
}

.btn-ruler.active {
    background-color: #f5d623;
    color: #1a1a1a;
}

.btn-line.active {
    background-color: #f5d623;
    color: #1a1a1a;
}

.pupil-crosshair-h {
    position: absolute;
    height: 1px;
    z-index: 4;
    pointer-events: none;
    opacity: 0.6;
}

.pupil-crosshair-v {
    position: absolute;
    width: 1px;
    z-index: 4;
    pointer-events: none;
    opacity: 0.6;
}

@media (max-width: 768px) {
    .grid-3 {
        grid-template-columns: 1fr;
    }
    nav ul {
        flex-direction: column;
    }
    .bottom-bar-controls {
        flex-wrap: wrap;
    }
    .bottom-bar-results {
        flex-wrap: wrap;
    }
}
