:root {
    --primary: #009688;
    --primary-hover: #00796b;
    --primary-dark: #004d40;
    --primary-light: #e0f2f1;
    --primary-accent: #26a69a;
    --bg-main: #f4f6f8;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-light: #fef2f2;
    --warning: #f59e0b;
    --success: #10b981;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px 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);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

input::placeholder,
textarea::placeholder,
select::placeholder {
    color: transparent;
    opacity: 0;
}

body {
    font-family: var(--font);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    padding: 24px 16px;
}

.app-container {
    max-width: 900px;
    margin: 0 auto;
}

.app-header {
    background: var(--primary-dark);
    background: linear-gradient(135deg, #004d40 0%, #009688 100%);
    border-radius: var(--radius-lg);
    padding: 24px;
    color: #ffffff;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.header-icon {
    font-size: 40px;
    background: rgba(255, 255, 255, 0.15);
    padding: 10px;
    border-radius: 12px;
}

.header-brand h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.header-brand p {
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: 300;
}

.app-nav {
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.15);
    padding: 6px;
    border-radius: var(--radius-md);
    overflow-x: auto;
}

.nav-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.8);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    box-shadow: none;
}

.nav-tab:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.nav-tab.active {
    background: #ffffff;
    color: var(--primary-dark);
    box-shadow: var(--shadow-sm);
}

.nav-tab .material-icons {
    font-size: 20px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.card-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    color: var(--primary-dark);
}

.card-title-row h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.card-title-row .material-icons {
    color: var(--primary);
    font-size: 24px;
}

.section-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.input-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-field label {
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-field input,
.input-field select {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--text-primary);
    background: #ffffff;
    transition: all 0.2s ease;
    outline: none;
}

.input-field input:focus,
.input-field select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 24px 0 16px 0;
}

.title-left {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.title-left h3 {
    font-size: 1.15rem;
    font-weight: 600;
}

.title-left .material-icons {
    color: var(--primary);
}

.match-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s ease;
}

.match-card:hover {
    border-color: #cbd5e1;
}

.match-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 14px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}

.match-tag-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.match-badge {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 4px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.match-badge .material-icons {
    font-size: 16px;
}

.opponent-input {
    border: 1px solid transparent;
    background: #f8fafc;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.opponent-input:focus {
    background: #ffffff;
    border-color: var(--primary);
    outline: none;
}

.live-match-nrr {
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}

.btn-delete-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: none;
}

.btn-delete-icon:hover {
    color: var(--danger);
    background: var(--danger-light);
}

.innings-block {
    background: #f8fafc;
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 14px;
}

.innings-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.innings-header .material-icons {
    font-size: 18px;
    color: var(--primary);
}

.runs-overs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.checkbox-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.check-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.check-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.dls-toggle-block {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border-color);
}

.dls-inputs-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 10px;
    background: #ffffff;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid #cbd5e1;
}

.add-match-wrapper {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.action-bar {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

button {
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    border: none;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    flex: 1;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
    background: #f8fafc;
    color: var(--text-primary);
    border-color: #cbd5e1;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 10px 24px;
}

.btn-outline:hover {
    background: var(--primary-light);
}

.btn-small-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn-small-outline:hover {
    background: var(--primary-light);
}

.result-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 24px;
    margin-top: 24px;
    box-shadow: var(--shadow-md);
    display: none;
}

.result-card.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.result-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--primary-dark);
}

.result-title h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.result-title .material-icons {
    color: var(--primary);
}

.nrr-display {
    text-align: center;
    background: linear-gradient(135deg, #f8fafc 0%, #e0f2f1 100%);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    border: 1px solid var(--primary-light);
}

.nrr-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nrr-value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-hover);
    line-height: 1.2;
    margin-top: 4px;
}

.nrr-value.negative {
    color: var(--danger);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.metric-item {
    background: #f8fafc;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.metric-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.dls-cards-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.dls-stat-card {
    padding: 20px;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.dls-stat-card.primary {
    background: var(--primary-light);
    border: 1px solid var(--primary-accent);
}

.dls-stat-card.secondary {
    background: #f1f5f9;
    border: 1px solid var(--border-color);
}

.dls-stat-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.dls-stat-val {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin: 6px 0;
}

.dls-stat-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.table-wrapper {
    overflow-x: auto;
}

.table-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.dls-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.dls-table th,
.dls-table td {
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.dls-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-secondary);
}

.scenarios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.scenario-card {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.scenario-badge {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    align-self: flex-start;
}

.scenario-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.scenario-result {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary-dark);
    background: #ffffff;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--primary);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    max-width: 440px;
    width: 100%;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.modal-icon {
    font-size: 28px;
    color: var(--primary);
}

.modal-icon.warning { color: var(--warning); }
.modal-icon.danger { color: var(--danger); }
.modal-icon.info { color: var(--primary); }

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-body {
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-modal {
    padding: 8px 16px;
    font-size: 0.875rem;
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text-primary);
    color: #ffffff;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1100;
    font-size: 0.9rem;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast .material-icons {
    color: var(--success);
}

@media (max-width: 640px) {
    body {
        padding: 12px 8px;
    }

    .app-header {
        padding: 16px 12px;
    }

    .header-brand {
        gap: 10px;
    }

    .header-icon {
        font-size: 32px;
        padding: 6px;
    }

    .header-brand h1 {
        font-size: 1.35rem;
    }

    .app-nav {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
        padding: 4px;
        overflow: hidden;
    }

    .nav-tab {
        flex-direction: column;
        gap: 4px;
        padding: 8px 2px;
        font-size: 0.725rem;
        text-align: center;
        white-space: normal;
        word-break: break-word;
        line-height: 1.15;
    }

    .nav-tab .material-icons {
        font-size: 20px;
    }

    .runs-overs-grid {
        grid-template-columns: 1fr;
    }

    .action-bar {
        flex-direction: column;
    }

    .dls-cards-row {
        grid-template-columns: 1fr;
    }

    .dls-inputs-row {
        grid-template-columns: 1fr;
    }
}