:root {
    --primary-blue: #00447c;
    --primary-blue-dark: #002d52;
    --primary-blue-light: #e6eef4;
    --accent-green: #6cb33f;
    --accent-green-dark: #568f32;
    --light-grey: #f8f9fa;
    --medium-grey: #e9ecef;
    --dark-grey-text: #343a40;
}

/* --- NEW LAYOUT: General, Nav, Main Views --- */
html, body { height: 100%; margin: 0; overflow: hidden; font-family: sans-serif; background-color: #f1f3f5; color: var(--dark-grey-text); }
body { display: flex; flex-direction: column; }
.navbar {
    flex-shrink: 0; display: flex; align-items: center; padding: 0 20px;
    background-color: var(--primary-blue); color: white; box-shadow: 0 2px 4px rgba(0,0,0,0.2); z-index: 100;
}
.navbar-title {
    font-size: 1.5em;
    font-weight: bold;
    margin-right: 20px;
    display: flex;
    align-items: center;
}
.navbar-logo {
    height:45px ;
    width: auto;
    margin-right: 10px;
}
.nav-tabs { display: flex; height: 100%; }
.nav-tab { padding: 15px 20px; cursor: pointer; border-bottom: 3px solid transparent; font-size: 1.1em; }
.nav-tab:hover { background-color: var(--primary-blue-dark); }
.nav-tab.active { border-bottom-color: var(--accent-green); font-weight: bold; }
.nav-actions { margin-left: auto; display: flex; gap: 10px; }
.nav-actions button { margin-top: 0; font-size: 0.9em; background-color: #fff; color: var(--primary-blue); border: 1px solid var(--primary-blue); }
.nav-actions button:hover { background-color: var(--primary-blue-light); }
.main-content { flex-grow: 1; overflow-y: auto; padding: 20px; position: relative; }
.view-container { display: none; }
.view-container.active { display: block; }

/* --- NEW LAYOUT: Card Grid --- */
#card-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.order-card, .add-card {
    background-color: white; border: 1px solid #ddd; border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); cursor: pointer; transition: all 0.2s ease-in-out;
    padding: 15px; display: flex; flex-direction: column;
}
.order-card:hover { border-color: var(--primary-blue); transform: translateY(-3px); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.card-header { font-size: 1.2em; font-weight: bold; color: var(--primary-blue); margin-bottom: 10px; }
.card-detail { font-size: 1.0em; color: var(--accent-green); margin-bottom: 4px; }
.add-card {
    align-items: center; justify-content: center; border: 2px dashed var(--accent-green);
    color: var(--accent-green); background-color: #fafff8;
}
.add-card:hover { border-color: var(--accent-green-dark); color: var(--accent-green-dark); background-color: #f1f8ec; }
.add-card-plus { font-size: 4em; font-weight: 100; line-height: 1; }

/* --- NEW LAYOUT: Modal --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.5); z-index: 1000;
    display: none;
}
.modal-content {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background-color: white; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 95%; max-width: 1050px; height: 90vh; max-height: 800px;
    z-index: 1001; display: flex; flex-direction: column;
}
.modal-header {
    padding: 15px 20px; background-color: var(--primary-blue); color: white;
    display: flex; justify-content: space-between; align-items: center; border-radius: 8px 8px 0 0;
}
.modal-title { font-size: 1.4em; margin: 0; }
.modal-close { font-size: 2em; font-weight: bold; line-height: 1; cursor: pointer; color: white; background: none; border: none; padding: 0; }
.modal-body { flex-grow: 1; overflow-y: auto; padding: 20px; }

/* --- Form Styles (Adapted for Modal) --- */
#orderForm { border: none; padding: 0; margin: 0; background: none; }
#orderForm .form-section { border-color: var(--medium-grey); }
#orderForm .job-section { border-color: var(--primary-blue-light); }
#orderForm .add-op-btn { background-color: var(--accent-green); }
#orderForm .add-op-btn:hover { background-color: var(--accent-green-dark); }
#orderForm .add-job-btn { background-color: var(--primary-blue); }
#orderForm .add-job-btn:hover { background-color: var(--primary-blue-dark); }
#orderForm .form-actions button { margin: 10px 8px; }
#addOrderBtn, #saveOrderBtn { background-color: var(--accent-green); }
#addOrderBtn:hover, #saveOrderBtn:hover { background-color: var(--accent-green-dark); }
#cancelEditBtn { background-color: #6c757d; } #cancelEditBtn:hover { background-color: #5a6268; }
#deleteOrderContainer label { color: red; }
#deleteOrderContainer { display: inline-block; vertical-align: middle; margin-left: 10px; margin-right: 10px; }
#deleteOrderContainer label { font-weight: bold; vertical-align: middle; margin-left: 5px; font-size: 0.9em; display: inline; margin-bottom: 0; }
#deleteOrderContainer input { vertical-align: middle; transform: scale(1.1); margin-right: 0; margin-bottom: 0; }
#orderForm .form-section { margin-bottom: 10px; padding: 8px; border: 1px dashed #eee; }
#orderForm .order-details-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; align-items: start; }
#orderForm .form-column-group > div { margin-bottom: 10px; }
#orderForm .form-column-group > div:last-child { margin-bottom: 0; }
#orderForm label { display: block; margin-bottom: 3px; font-weight: bold; font-size: 0.9em; }
#orderForm input[type="text"], #orderForm input[type="number"], #orderForm input[type="date"], #orderForm textarea, #orderForm select { padding: 6px 8px; margin-bottom: 5px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-size: 1em; width: 100%; }
#orderForm textarea { resize: vertical; width: 100%;}
#orderForm .job-section { border: 1px solid var(--primary-blue-light); background-color: #ffffff; padding: 10px; margin: 10px 0; }
#orderForm .job-header { display: flex; align-items: center; margin-bottom: 10px; }
#orderForm .job-header label { margin-right: 10px; margin-bottom: 0; width: auto; flex-shrink: 0; }
#orderForm .job-header input.job-number { width: 25ch; max-width: 300px; min-width: 150px; }
#orderForm .operation-entry { border: 1px dashed #ccc; padding: 8px; margin-top: 8px; background-color: var(--primary-blue-light); display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 5px 8px; align-items: start; }
#orderForm .operation-entry label { font-size: 0.85em; margin-bottom: 2px;}
#orderForm .operation-entry input, #orderForm .operation-entry textarea { padding: 5px 7px; font-size: 0.95em; width: 100%; }
#orderForm .operation-entry .op-number, #orderForm .operation-entry .op-dept, #orderForm .operation-entry .op-hr-est, #orderForm .operation-entry .op-hrs-actl { width: 10ch; max-width: 130px; }
#orderForm .operation-entry .op-due-by { width: 13ch; max-width: 160px; }
#orderForm .operation-entry .task-container { grid-column: span 2; }
#orderForm .operation-entry .op-task {
    width: 100%;
    min-height: 1.6em;
    resize: none;
    overflow: hidden;
}
#orderForm .op-controls { display: flex; flex-direction: column; gap: 5px; justify-content: center; padding-top: 5px; align-self: center; }
#orderForm .op-controls div { display: flex; align-items: center; }
#orderForm .op-controls label { margin-bottom: 0; margin-left: 5px; font-weight: normal; white-space: nowrap; font-size: 0.85em;}
#orderForm .op-controls input[type="checkbox"] { width: auto; margin-bottom: 0; transform: scale(0.9); }
#orderForm .add-job-btn { background-color: var(--primary-blue); }
#orderForm .add-job-btn:hover { background-color: var(--primary-blue-dark); }


/* --- Live View --- */
#live-view-container { height: 100%; }
#previewFrame { width: 100%; height: 100%; border: none; }
.hidden { display: none; }
