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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    padding-bottom: 100px;
}

/* ===== HEADER ===== */
.app-header {
    background: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header img {
    height: 36px;
}

.app-header .date {
    font-size: 12px;
    color: #999;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    position: fixed;
    bottom: 16px;
    left: 16px;
    right: 16px;
    background: white;
    display: flex;
    border: 1px solid #eee;
    border-radius: 20px;
    z-index: 200;
    padding-bottom: 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    background: none;
    color: #999;
    font-size: 10px;
    gap: 3px;
}

.nav-item .nav-icon {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    transition: transform 0.2s;
}
.nav-item .nav-label { font-size: 10px; }

.nav-item.active {
    color: #667eea;
}

.nav-item.active .nav-icon {
    transform: scale(1.1);
    stroke: #667eea;
}

/* ===== PAGE ===== */
.page { display: none; }
.page.active { display: block; }

/* ===== PERIOD SELECTOR ===== */
.period-selector {
    display: flex;
    gap: 8px;
    padding: 12px 15px;
    background: white;
    overflow-x: auto;
    white-space: nowrap;
    border-bottom: 1px solid #f0f0f0;
}

.period-btn {
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    white-space: nowrap;
}

.period-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* ===== LOADING / ERROR ===== */
.loading {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 14px;
}

.stale-banner {
    background: #fff9e6;
    border-left: 3px solid #fdcb6e;
    padding: 8px 15px;
    font-size: 12px;
    color: #856404;
    display: flex;
    align-items: center;
    gap: 6px;
}

.error-msg {
    text-align: center;
    padding: 40px;
    color: #d63031;
    font-size: 14px;
}

/* ===== METRICS GRID ===== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 12px 15px;
}

.metric-card {
    background: white;
    padding: 14px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.metric-card .label {
    font-size: 11px;
    color: #888;
    margin-bottom: 6px;
}

.metric-card .value {
    font-size: 26px;
    font-weight: bold;
    color: #222;
    line-height: 1.2;
}

.metric-card .subtext {
    font-size: 11px;
    color: #aaa;
    margin-top: 4px;
    line-height: 1.4;
}

.metric-card .subtext-amount {
    font-size: 12px;
    color: #555;
    margin-top: 3px;
    font-weight: 500;
}

/* ===== SECTION ===== */
.section {
    padding: 12px 15px;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== SIGNAL CARDS ===== */
.signal-card {
    background: white;
    padding: 12px 15px;
    border-radius: 10px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.signal-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.signal-card.alert { background: #fff5f5; border-left: 3px solid #d63031; }
.signal-card.warning { background: #fffbeb; border-left: 3px solid #fdcb6e; }

.signal-card .sig-title { font-size: 13px; color: #333; font-weight: 500; }
.signal-card .sig-sub { font-size: 11px; color: #888; margin-top: 2px; }
.signal-card .sig-count { font-size: 28px; font-weight: bold; color: #d63031; }
.signal-card.warning .sig-count { color: #e6a817; }

/* ===== PRODUCTION GRID ===== */
.production-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.production-card {
    background: white;
    padding: 14px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.production-card.clickable { cursor: pointer; transition: box-shadow 0.2s; }
.production-card.clickable:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.12); }

.production-card .label { font-size: 11px; color: #888; margin-bottom: 6px; }
.production-card .value { font-size: 30px; font-weight: bold; color: #333; }

/* ===== CHART SECTION ===== */
.chart-section {
    background: white;
    margin: 0 15px 15px;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.chart-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    overflow-x: auto;
}

.chart-btn {
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: white;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    transition: all 0.2s;
}

.chart-btn.active { background: #667eea; color: white; border-color: #667eea; }

/* ===== ORDER LIST (modal) ===== */
.order-item {
    background: #f9f9f9;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    border-left: 3px solid #d63031;
}

.order-item.warning { border-left-color: #fdcb6e; }

.order-item .order-id { font-weight: bold; color: #333; margin-bottom: 4px; font-size: 13px; }
.order-item .order-detail { font-size: 12px; color: #666; margin-bottom: 3px; }

.order-link {
    display: inline-block;
    margin-top: 8px;
    padding: 5px 12px;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 12px;
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    overflow-y: auto;
}

.modal.active { display: block; }

.modal-content {
    background: white;
    margin: 20px auto;
    padding: 20px;
    border-radius: 14px;
    max-width: 500px;
    width: 90%;
}

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

.modal-header h3 { font-size: 17px; color: #333; }

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

/* ===== PRODUCTION PAGE TABLE ===== */
.orders-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.orders-table th {
    background: #f8f8f8;
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    color: #888;
    font-weight: 600;
    border-bottom: 1px solid #eee;
}

.orders-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f5f5f5;
    color: #333;
    vertical-align: top;
}

.orders-table tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}

.badge-overdue { background: #ffe0e0; color: #d63031; }
.badge-today { background: #fff3cd; color: #856404; }
.badge-ok { background: #e0f5ee; color: #00b894; }

/* ===== PLACEHOLDER PAGES ===== */
.placeholder {
    text-align: center;
    padding: 60px 20px;
    color: #ccc;
}

.placeholder .icon { font-size: 60px; margin-bottom: 16px; }
.placeholder p { font-size: 14px; }

/* ===== SIDEBAR (admin only) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 300;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background: white;
    z-index: 301;
    transition: left 0.3s cubic-bezier(0.4,0,0.2,1);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0,0,0,0.12);
}
.sidebar.open { left: 0; }

.sidebar-header {
    padding: 20px 20px 12px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: 700;
}
.sidebar-name { font-size: 15px; font-weight: 700; color: #2c3e50; }
.sidebar-role { font-size: 11px; color: #999; }

.sidebar-close {
    width: 32px; height: 32px;
    border: none; background: #f8f9fa;
    border-radius: 50%; cursor: pointer;
    font-size: 16px; color: #666;
    display: flex; align-items: center; justify-content: center;
}

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.sidebar-section {
    padding: 6px 16px 2px;
    font-size: 10px;
    font-weight: 700;
    color: #bbb;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    color: #444;
    border-radius: 0;
    transition: background 0.15s;
}
.sidebar-item:hover { background: #f8f9fa; }
.sidebar-item.active { color: #667eea; background: #f0f0ff; }
.sidebar-item .s-icon { font-size: 20px; width: 28px; text-align: center; }

.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid #f0f0f0;
    font-size: 11px;
    color: #bbb;
    text-align: center;
}

/* Кнопка відкриття sidebar */
.sidebar-toggle {
    position: fixed;
    top: 12px;
    left: 12px;
    width: 38px;
    height: 38px;
    background: white;
    border: 1px solid #eee;
    border-radius: 12px;
    cursor: pointer;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    font-size: 18px;
}
.sidebar-toggle.visible { display: flex; }
