* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #7c3aed;
    --success-color: #059669;
    --danger-color: #dc2626;
    --info-color: #0891b2;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 5px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.95;
    font-weight: 300;
    margin-bottom: 10px;
}

.header .instructions {
    font-size: 0.9em;
    opacity: 0.9;
    font-style: italic;
}

/* Instructions Section */
.instructions-section {
    background: var(--surface);
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--info-color);
}

.instructions-section h2 {
    color: var(--info-color);
    margin-bottom: 15px;
}

.instructions-section ol {
    margin-left: 20px;
}

.instructions-section li {
    margin: 10px 0;
    line-height: 1.7;
}

/* Theory Section */
.theory-section {
    background: var(--surface);
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.theory-section h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.formula {
    background: #f0f9ff;
    border-left: 4px solid var(--primary-color);
    padding: 15px;
    margin: 15px 0;
    font-size: 1.2em;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    color: var(--primary-color);
    border-radius: 5px;
}

.formula-explain {
    list-style: none;
    margin-top: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 10px;
}

.formula-explain li {
    padding: 10px;
    background: #fafafa;
    border-radius: 5px;
    border-left: 3px solid var(--secondary-color);
}

/* Micrometer Readings Section */
.micrometer-section {
    background: var(--surface);
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.micrometer-section h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.micrometer-section .instruction {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-style: italic;
}

.micrometer-readings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.micrometer-reading {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    background: #fafafa;
}

.micrometer-reading h3 {
    color: var(--primary-color);
    margin-bottom: 10px;
    text-align: center;
}

.micrometer-image {
    width: 100%;
    height: 200px;
    background: white;
    border-radius: 6px;
    margin: 10px 0;
    border: 1px solid var(--border-color);
}

.reading-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 15px;
}

.reading-input label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9em;
}

.reading-input input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 0.95em;
}

.reading-input input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.diameter-summary {
    background: #f0f9ff;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.diameter-summary h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: white;
    border-radius: 6px;
}

.summary-item label {
    font-weight: 600;
    color: var(--text-primary);
}

.summary-item span {
    color: var(--primary-color);
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

/* Setup Section */
.setup-section {
    background: var(--surface);
    padding: 25px;
    border-radius: 10px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.setup-section h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
}

.setup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.setup-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setup-item label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95em;
}

.setup-item input {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 0.95em;
}

.setup-item input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Main Grid */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 30px;
}

@media (max-width: 1024px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
}

/* Panel Styling */
.panel {
    background: var(--surface);
    padding: 25px;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.panel h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.4em;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.panel h3 {
    color: var(--text-primary);
    margin-top: 20px;
    margin-bottom: 12px;
    font-size: 1.1em;
}

.instruction {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-style: italic;
}

/* Apparatus Visualization */
.apparatus-section {
    margin-bottom: 25px;
}

.apparatus-visual {
    width: 100%;
    height: 500px;
    background: #f8f8f8;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
}

/* Vernier Scale */
.vernier-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    margin-top: 10px;
}

.vernier-scale-svg {
    width: 100%;
    height: 200px;
    background: white;
}

/* Vernier Scale Display */
.vernier-scale-section {
    background: linear-gradient(to right, #f0f9ff, #f5f3ff);
    padding: 20px;
    border-radius: 8px;
    border: 2px solid var(--info-color);
    margin-bottom: 25px;
}

.vernier-scale-section h3 {
    color: var(--info-color);
    margin-bottom: 10px;
}

.vernier-reading-display {
    background: white;
    padding: 20px;
    border-radius: 6px;
    text-align: center;
}

.reading-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

.reading-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.reading-value {
    font-size: 32px;
    font-weight: bold;
    color: var(--info-color);
    padding: 10px 20px;
    background: #ecf9ff;
    border-radius: 6px;
    border: 2px solid var(--info-color);
    min-width: 150px;
}

.reading-note {
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Mass Control */
.mass-control-section {
    background: #f0f9ff;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--info-color);
    margin-bottom: 20px;
}

.mass-control-section h3 {
    margin-top: 0;
    color: var(--info-color);
}

.mass-buttons {
    display: flex;
    gap: 10px;
    margin: 15px 0;
}

.current-mass-display {
    background: white;
    padding: 12px;
    border-radius: 6px;
    font-size: 1.05em;
    color: var(--text-primary);
}

/* Vernier Reading */
.vernier-reading-section {
    background: #f0fdf4;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid var(--success-color);
}

.vernier-reading-section h3 {
    margin-top: 0;
    color: var(--success-color);
}

/* Data Collection */
.data-collection {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.collection-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.collection-table thead {
    background: var(--primary-color);
    color: white;
}

.collection-table th {
    padding: 10px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9em;
}

.collection-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9em;
}

.collection-table tbody tr:nth-child(even) {
    background: #f8f8f8;
}

.collection-table tbody tr:hover {
    background: #f0f9ff;
}

/* Buttons */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95em;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
    margin-top: 15px;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
    flex: 1;
}

.btn-secondary:hover {
    background: #6d28d9;
}

.btn-success {
    background: var(--success-color);
    color: white;
    width: 100%;
    margin-top: 15px;
}

.btn-success:hover {
    background: #047857;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-info {
    background: var(--info-color);
    color: white;
}

.btn-info:hover {
    background: #0e7490;
}

/* Results Panel */
.results-panel {
    margin-top: 30px;
    margin-bottom: 30px;
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

@media (max-width: 1024px) {
    .results-grid {
        grid-template-columns: 1fr;
    }
}

/* Data Summary Section */
.data-summary-section h2 {
    margin-bottom: 20px;
}

.summary-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.summary-table thead {
    background: var(--primary-color);
    color: white;
}

.summary-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9em;
}

.summary-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9em;
}

.summary-table tbody tr:nth-child(even) {
    background: #f8f8f8;
}

.summary-table tbody tr:hover {
    background: #f0f9ff;
}

.summary-table .delete-btn {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
}

.summary-table .delete-btn:hover {
    background: #b91c1c;
}

.no-data {
    text-align: center;
    color: var(--text-secondary);
    padding: 20px;
    font-style: italic;
}

/* Graph Instructions */
.graph-instructions {
    background: #fefce8;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #fbbf24;
}

.graph-instructions h2 {
    color: #92400e;
    margin-bottom: 20px;
    border-bottom: 2px solid #fbbf24;
}

.graph-instructions h3 {
    color: #92400e;
    margin-top: 18px;
    margin-bottom: 10px;
    font-size: 1.05em;
}

.graph-instructions ol, .graph-instructions ul {
    margin-left: 20px;
    line-height: 1.8;
}

.graph-instructions li {
    margin: 8px 0;
}

.instructions-box {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #f59e0b;
}

.formula-box {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 15px;
    margin: 15px 0;
    font-size: 1.1em;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    color: #92400e;
    border-radius: 5px;
}

.working-box {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-family: 'Courier New', monospace;
    margin-top: 15px;
}

.working-box p {
    margin: 10px 0;
    color: var(--text-primary);
}

.working-box hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 15px 0;
}

/* Control Panel */
.control-panel {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.control-panel .btn {
    width: auto;
    min-width: 150px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
}

.footer p {
    margin: 5px 0;
    font-size: 0.9em;
}

/* Micrometer Reading Styles */
.micrometer-readings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.micrometer-reading {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.micrometer-reading:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.micrometer-reading h3 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--primary-color);
}

/* Micrometer placeholder container */
.micrometer-placeholder {
    background: #f8f8f8;
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    padding: 15px;
    text-align: center;
    margin-bottom: 15px;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.micrometer-image {
    width: 100%;
    max-width: 500px;
    height: auto;
    border-radius: 4px;
    background: white;
    padding: 10px;
}

.placeholder-text {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header h1 {
        font-size: 1.8em;
    }

    .main-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .micrometer-readings-grid {
        grid-template-columns: 1fr;
    }

    .formula-explain {
        grid-template-columns: 1fr;
    }

    .mass-buttons {
        flex-direction: column;
    }

    .mass-buttons .btn {
        width: 100%;
    }

    .control-panel .btn {
        width: 100%;
    }
}

/* Print Styles */
@media print {
    .control-panel,
    .mass-buttons,
    .btn {
        display: none;
    }

    .panel {
        page-break-inside: avoid;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.panel, .summary-table, .instructions-box {
    animation: slideIn 0.3s ease-out;
}
