/* ===== Design Tokens ===== */
:root {
    --bg-page: #f4f5f7;
    --bg-white: #ffffff;
    --bg-subtle: #f9fafb;
    --bg-muted: #eef0f3;

    --text-primary: #1a1a2e;
    --text-secondary: #4a4a68;
    --text-muted: #7c7c96;
    --text-label: #5c5c78;

    --accent: #2c5282;
    --accent-light: #3b6daa;
    --accent-soft: #ebf1f9;
    --accent-border: #c4d5e8;

    --success: #2f7d5e;
    --success-soft: #e8f5ef;
    --warning: #b8860b;
    --warning-soft: #fdf6e3;
    --info: #4a6fa1;
    --info-soft: #edf2f9;
    --danger: #b04040;

    --border: #dcdee3;
    --border-light: #e8eaef;

    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.03);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

/* ===== Reset ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
.header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1360px;
    margin: 0 auto;
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.logo-icon svg {
    width: 20px;
    height: 20px;
}

.header-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.header-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.header-right {
    display: flex;
    gap: 6px;
}

.badge {
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid var(--accent-border);
    letter-spacing: 0.01em;
}

.badge-accent {
    background: var(--success-soft);
    color: var(--success);
    border-color: #b5d5c5;
}

/* ===== Main ===== */
.main-content {
    max-width: 1360px;
    margin: 0 auto;
    padding: 20px 28px;
}

/* ===== Panel Base ===== */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.panel-header h2 {
    font-size: 0.95rem;
    font-weight: 650;
    color: var(--text-primary);
}

/* ===== Simulation Section ===== */
.simulation-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* ===== Tank Panel ===== */
.tank-panel {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
}

.status-dot.running {
    animation: pulse 1.2s ease-in-out infinite;
    background: var(--accent);
}

.status-dot.finished {
    background: var(--warning);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.tank-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 12px 0;
}

#tankCanvas {
    border-radius: var(--radius-sm);
    max-width: 100%;
    height: auto;
}

.tank-dimensions {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

.dim-label {
    position: absolute;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.85);
    padding: 1px 6px;
    border-radius: 3px;
    white-space: nowrap;
}

.dim-width {
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
}

.dim-height {
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent);
    font-weight: 600;
}

.dim-depth {
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
}

.timer-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.timer-icon {
    font-size: 1.2rem;
}

.timer-value {
    font-family: var(--font-mono);
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.04em;
}

/* ===== Controls Panel ===== */
.controls-panel {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.controls-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 14px;
}

.control-group {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 3px 10px;
    align-items: center;
}

.control-label {
    grid-column: 1 / -1;
    font-size: 0.76rem;
    color: var(--text-label);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

.label-icon {
    font-size: 0.82rem;
}

.control-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
    min-width: 65px;
    text-align: right;
}

/* ===== Slider ===== */
.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: var(--bg-muted);
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-white);
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-white);
    box-shadow: var(--shadow-sm);
}

.slider-accent::-webkit-slider-thumb {
    background: var(--info);
}

.slider-accent::-moz-range-thumb {
    background: var(--info);
}

/* ===== Calculated Values ===== */
.calc-section {
    margin-bottom: 14px;
}

.calc-title {
    font-size: 0.72rem;
    font-weight: 650;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.calc-card {
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}

.calc-label {
    font-size: 0.66rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 1px;
}

.calc-value {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-highlight {
    border-color: var(--accent-border);
    background: var(--accent-soft);
}

.card-highlight .calc-value {
    color: var(--accent);
}

/* ===== Buttons ===== */
.action-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.btn {
    padding: 9px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
    flex: 1;
    justify-content: center;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-icon {
    font-size: 0.85rem;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-light);
}

.btn-secondary {
    background: var(--bg-muted);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border-light);
}

.btn-outline {
    background: var(--bg-white);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-outline:hover:not(:disabled) {
    background: var(--bg-subtle);
    color: var(--text-primary);
}

.btn-small {
    padding: 5px 12px;
    font-size: 0.72rem;
    flex: none;
}

/* ===== Equation Card ===== */
.equation-card {
    background: var(--bg-subtle);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 14px;
    border-left: 3px solid var(--accent);
}

.equation-title {
    font-size: 0.7rem;
    font-weight: 650;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.equation-display {
    margin-bottom: 6px;
}

.equation-main {
    font-family: var(--font-mono);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    padding: 6px;
}

.equation-solution {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--text-secondary);
    text-align: center;
}

.solution-label {
    color: var(--accent);
    font-weight: 600;
}

/* ===== Charts ===== */
.charts-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.chart-panel {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.chart-panel canvas {
    width: 100% !important;
    height: auto !important;
    border-radius: var(--radius-sm);
}

.legend {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.legend-theo { background: #2c5282; }
.legend-sim  { background: #d97706; }
.legend-exp  { background: #b04040; }
.legend-vel  { background: #2f7d5e; }

/* ===== Data Section ===== */
.data-section {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.data-panel, .summary-panel {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.table-container {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.76rem;
}

.data-table th {
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-weight: 650;
    padding: 9px 10px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border-light);
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--text-secondary);
}

.data-table tbody tr:hover {
    background: var(--bg-subtle);
}

/* ===== Summary Cards ===== */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.summary-card {
    border-radius: var(--radius-md);
    padding: 14px;
    text-align: center;
    transition: transform 0.2s ease;
}

.summary-card:hover {
    transform: translateY(-1px);
}

.card-blue {
    background: var(--accent-soft);
    border: 1px solid var(--accent-border);
}

.card-green {
    background: var(--success-soft);
    border: 1px solid #b5d5c5;
}

.card-purple {
    background: var(--info-soft);
    border: 1px solid #c4d0e4;
}

.card-orange {
    background: var(--warning-soft);
    border: 1px solid #e0d0a8;
}

.summary-icon {
    font-size: 1.3rem;
    margin-bottom: 4px;
}

.summary-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 3px;
}

.summary-value {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1px;
}

.card-blue .summary-value   { color: var(--accent); }
.card-green .summary-value  { color: var(--success); }
.card-purple .summary-value { color: var(--info); }
.card-orange .summary-value { color: var(--warning); }

.summary-detail {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* ===== Info Section ===== */
.info-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.info-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    border-top: 3px solid var(--accent);
}

.info-card h3 {
    font-size: 0.88rem;
    font-weight: 650;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.info-card p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.65;
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 20px 28px;
    color: var(--text-muted);
    font-size: 0.72rem;
    border-top: 1px solid var(--border);
    background: var(--bg-white);
}

/* ===== Responsive ===== */
@media (max-width: 1100px) {
    .simulation-section,
    .charts-section,
    .data-section,
    .info-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header-content { padding: 10px 14px; }
    .main-content { padding: 14px; }
    .header-right { display: none; }
    .calc-grid, .summary-grid { grid-template-columns: 1fr; }
    .action-buttons { flex-direction: column; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-page); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
