:root {
    --primary-dark: #0f172a;
    --primary-navy: #1e3a8a;
    --primary-slate: #1e293b;
    --primary-border: #334155;
    --bg-light: #f8fafc;
    --bg-card: #ffffff;
    --bg-surface: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #ffffff;
    --color-success: #10b981;
    --color-success-bg: #ecfdf5;
    --color-warning: #f59e0b;
    --color-warning-bg: #fffbeb;
    --color-danger: #ef4444;
    --color-danger-bg: #fef2f2;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --touch-target: 48px;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08);
    --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.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    background-color: var(--bg-light);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Header */
.app-header {
    background-color: var(--primary-dark);
    color: var(--text-light);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: 8px;
    border-bottom: 2px solid #2563eb;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
    min-height: 54px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-badge {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-icon {
    font-size: 1.4rem;
}

.brand-title {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0;
    line-height: 1.2;
    white-space: nowrap;
}

.facility-tag {
    font-size: 0.68rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    display: block;
}

.header-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    row-gap: 6px;
}

.shift-badge-pill {
    background-color: rgba(37, 99, 235, 0.25);
    border: 1px solid #3b82f6;
    color: #93c5fd;
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.live-dot {
    width: 7px;
    height: 7px;
    background-color: #10b981;
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.9); opacity: 0.8; }
    50% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.8; }
}

/* Nav tabs */
.app-nav {
    display: flex;
    background-color: var(--primary-slate);
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: 1px solid var(--primary-border);
    position: sticky;
    top: 54px;
    z-index: 90;
}

.app-nav::-webkit-scrollbar { display: none; }

.nav-tab {
    flex: 1;
    min-width: 64px;
    min-height: 48px;
    padding: 8px 4px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
    white-space: normal;
    overflow: hidden;
    text-align: center;
    line-height: 1.15;
    word-break: keep-all;
    overflow-wrap: break-word;
}

.nav-tab:hover {
    color: #f1f5f9;
    background-color: rgba(255, 255, 255, 0.04);
}

.nav-tab.active {
    color: #ffffff;
    border-bottom-color: #38bdf8;
    background-color: rgba(56, 189, 248, 0.12);
}

.tab-icon { font-size: 1.1rem; }

/* Main container */
.app-main {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 12px;
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Cards */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    box-shadow: var(--shadow-sm);
    padding: 16px;
    margin-bottom: 14px;
}

.card-header {
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f1f5f9;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary-dark);
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Steps */
.form-step {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
}

.form-step:last-of-type { border-bottom: none; }

.step-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 0.95rem;
    margin-bottom: 10px;
    color: var(--primary-slate);
}

.step-number {
    background-color: var(--primary-navy);
    color: #fff;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.required-badge {
    font-size: 0.72rem;
    font-weight: 700;
    color: #dc2626;
    margin-left: auto;
}

/* Input styles */
.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.form-control {
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    background-color: #fff;
    font-size: 0.95rem;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.input-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-search-wrapper .form-control {
    padding-right: 44px;
}

.btn-clear-search {
    position: absolute;
    right: 4px;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-clear-search:hover { color: #475569; }

/* Machine Auto-Suggestions & Search Results */
.machine-results-container {
    max-height: 280px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    margin-top: 6px;
    box-shadow: var(--shadow-md);
}

.machine-result-item {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.15s;
}

.machine-result-item:hover, .machine-result-item:focus {
    background-color: #eff6ff;
}

.machine-result-item:last-child { border-bottom: none; }

.btn-select-machine {
    min-height: 48px;
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: center;
    cursor: pointer;
    color: var(--text-main);
    font-family: inherit;
}

.btn-select-machine .m-code {
    font-weight: 800;
    color: #1d4ed8;
    font-size: 0.95rem;
}

.btn-select-machine .m-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-main);
}

.btn-select-machine .m-area {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Selected Machine Card */
.selected-card {
    background-color: #f0fdf4;
    border: 1.5px solid #22c55e;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}

.selected-card-info strong {
    display: block;
    font-size: 1rem;
    color: #15803d;
}

.selected-card-info span {
    font-size: 0.82rem;
    color: #166534;
}

/* Category Buttons (12 Categories) */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.btn-cat {
    min-height: 48px;
    padding: 8px 10px;
    background-color: var(--bg-surface);
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: all 0.15s;
}

.btn-cat:hover { background-color: #e2e8f0; }

.btn-cat.active {
    background-color: var(--primary-navy);
    color: #ffffff;
    border-color: var(--primary-dark);
    box-shadow: var(--shadow-sm);
}

/* Failure Types Chips */
.failure-types-chips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin-top: 8px;
    max-height: 250px;
    overflow-y: auto;
    padding: 4px;
}

.chip-failure-type {
    min-height: 48px;
    padding: 8px 10px;
    background-color: #ffffff;
    border: 1.5px solid #94a3b8;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--primary-slate);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    transition: all 0.15s;
}

.chip-failure-type:hover {
    background-color: #f1f5f9;
    border-color: #64748b;
}

.chip-failure-type.active {
    background-color: #2563eb;
    color: #ffffff;
    border-color: #1d4ed8;
    box-shadow: var(--shadow-sm);
}

/* Toggles and Duration Buttons */
.toggle-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.btn-toggle {
    min-height: 48px;
    padding: 8px;
    background-color: var(--bg-surface);
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-weight: 800;
    font-size: 0.88rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s;
}

.btn-toggle.active {
    background-color: #10b981;
    color: #ffffff;
    border-color: #059669;
}

.btn-toggle.danger-toggle.active {
    background-color: #ef4444;
    color: #ffffff;
    border-color: #dc2626;
}

.durations-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.btn-duration {
    min-height: 48px;
    background-color: var(--bg-surface);
    border: 1.5px solid #cbd5e1;
    border-radius: var(--radius-sm);
    font-weight: 800;
    font-size: 0.88rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.btn-duration:hover { background-color: #e2e8f0; }

.btn-duration.active {
    background-color: #2563eb;
    color: #ffffff;
    border-color: #1d4ed8;
}

/* Submit Button */
.btn-submit-lg {
    width: 100%;
    min-height: 52px;
    padding: 12px 16px;
    background-color: #16a34a;
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 6px -1px rgba(22, 163, 74, 0.3);
    transition: background-color 0.15s, transform 0.1s;
}

.btn-submit-lg:hover:not(:disabled) {
    background-color: #15803d;
}

.btn-submit-lg:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Standard Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-sm {
    min-height: 38px;
    padding: 4px 10px;
    font-size: 0.8rem;
}

.btn-primary { background-color: #1e3a8a; color: #fff; }
.btn-secondary { background-color: #e2e8f0; color: #1e293b; }
.btn-danger { background-color: #ef4444; color: #fff; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 700;
}
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #ffedd5; color: #9a3412; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* Excel Görünümü tablosu */
.excel-view-scroll {
    overflow-x: auto;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    max-height: 60vh;
    overflow-y: auto;
}

.excel-view-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.76rem;
    white-space: nowrap;
}

.excel-view-table th,
.excel-view-table td {
    border: 1px solid #cbd5e1;
    padding: 4px 8px;
    text-align: left;
}

.excel-view-table thead th {
    position: sticky;
    top: 0;
    background-color: #1e3a8a;
    color: #ffffff;
    font-weight: 700;
    z-index: 1;
}

.excel-view-table tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

.excel-view-table tbody tr:hover {
    background-color: #eff6ff;
}

/* Responsive Media Queries */
@media (max-width: 360px) {
    .durations-grid { grid-template-columns: repeat(2, 1fr); }
    .categories-grid { grid-template-columns: repeat(2, 1fr); }
    .app-header { padding: 6px 8px; }
    .brand-title { font-size: 0.9rem; }
}

@media (max-width: 480px) {
    .app-main { padding: 8px; }
    .card { padding: 12px; }
}

@media (min-width: 768px) {
    .durations-grid { grid-template-columns: repeat(8, 1fr); }
    .categories-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Modal Overlay */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}
.modal.open {
    display: flex !important;
}
.modal-content {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    background: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid #cbd5e1;
    animation: modalIn 0.2s ease-out;
}
@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
