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

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 2rem 0;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.logo-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
}

.tagline {
    opacity: 0.9;
    font-size: 1.1rem;
}

/* Main Content */
main {
    flex: 1;
    padding: 2rem 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Calculator Cards */
.calculator-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.calculator-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.calculator-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.calculator-card .description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

/* Input Groups */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.input-row.stacked {
    flex-direction: column;
    align-items: stretch;
}

.labeled-input {
    flex: 1;
    min-width: 0;
}

.labeled-input label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--card-bg);
}

input[type="number"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input[type="number"]::placeholder {
    color: var(--text-secondary);
    opacity: 0.6;
}

.operator {
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Buttons */
button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

button:hover {
    background: var(--primary-hover);
}

button:active {
    transform: scale(0.98);
}

/* Quick Select Buttons */
.quick-tips,
.quick-discounts {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.quick-tip,
.quick-discount {
    flex: 1;
    min-width: 60px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    background: var(--background);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.quick-tip:hover,
.quick-discount:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Results */
.result {
    margin-top: 1.25rem;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.result-row:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.tip-result,
.discount-result {
    flex-direction: column;
}

.result-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.result-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.result-value.increase {
    color: var(--success-color);
}

.result-value.decrease {
    color: var(--danger-color);
}

.result-value.savings {
    color: var(--success-color);
}

/* Footer */
footer {
    background: var(--text-primary);
    color: white;
    padding: 1.5rem 0;
    text-align: center;
    margin-top: auto;
}

footer a {
    color: #93c5fd;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

footer a:hover {
    color: white;
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        padding: 1.5rem 0;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .logo-img {
        width: 40px;
        height: 40px;
    }

    .tagline {
        font-size: 1rem;
    }

    main {
        padding: 1rem 0;
        grid-template-columns: 1fr;
    }

    .calculator-card {
        padding: 1.25rem;
    }

    .input-row:not(.stacked) {
        flex-direction: column;
        align-items: stretch;
    }

    .operator {
        text-align: center;
        padding: 0.25rem 0;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 0.75rem;
    }

    header h1 {
        font-size: 1.25rem;
    }

    .quick-tip,
    .quick-discount {
        min-width: 50px;
        padding: 0.5rem;
        font-size: 0.8rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.calculator-card {
    animation: fadeIn 0.3s ease-out;
}

.calculator-card:nth-child(2) { animation-delay: 0.1s; }
.calculator-card:nth-child(3) { animation-delay: 0.2s; }
.calculator-card:nth-child(4) { animation-delay: 0.3s; }
.calculator-card:nth-child(5) { animation-delay: 0.4s; }

/* Hide number input spinners */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}
