/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; }
body { font-family: Segoe UI, Arial, sans-serif; background: #f6f7fb; margin: 0; color: #111827; }

/* ===== LAYOUT ===== */
header { position: sticky; top: 0; background: #fff; border-bottom: 1px solid #e5e7eb; padding: 12px 16px; z-index: 10; }
.wrap { display: flex; gap: 16px; padding: 16px; min-height: calc(100vh - 120px); }
nav { width: 220px; flex-shrink: 0; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 8px; align-self: flex-start; position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; }
main { flex: 1; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
footer { text-align: center; font-size: 11px; color: #94a3b8; padding: 12px; }

/* ===== NAV ===== */
nav button { width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: 8px; margin-bottom: 2px; cursor: pointer; font-size: 13px; color: #374151; transition: background .12s; }
nav button.active { background: #0f172a; color: #fff; font-weight: 600; }
nav button:hover:not(.active) { background: #f1f5f9; }
nav .nav-section { font-size: 10px; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: .08em; padding: 8px 12px 2px; margin-top: 4px; }

/* ===== CARDS ===== */
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 16px; }
h2 { margin: 0 0 14px 0; font-size: 16px; font-weight: 700; color: #0f172a; }
h3 { margin: 12px 0 8px; font-size: 14px; font-weight: 600; }

/* ===== FORMS ===== */
label { display: block; font-size: 12px; color: #475569; margin-bottom: 10px; }
label > span { display: block; margin-bottom: 4px; font-weight: 500; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 13px; background: #fff; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
input:disabled, select:disabled { background: #f8fafc; color: #94a3b8; cursor: not-allowed; }
textarea { resize: vertical; min-height: 60px; }

/* ===== GRID HELPERS ===== */
.grid { display: grid; gap: 10px; }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g5 { grid-template-columns: repeat(5, 1fr); }
.g6 { grid-template-columns: repeat(6, 1fr); }

/* ===== BUTTONS ===== */
.btn { padding: 8px 14px; border-radius: 8px; border: 1px solid #e5e7eb; cursor: pointer; font-size: 12px; font-weight: 500; transition: background .12s, box-shadow .12s; background: #fff; color: #374151; }
.btn:hover { background: #f8fafc; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.btn-primary { background: #0f172a; color: #fff; border-color: #0f172a; }
.btn-primary:hover { background: #1e293b; }
.btn-danger { background: #fff; color: #dc2626; border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: #f1f5f9; }
.btn-sm { padding: 5px 10px; font-size: 11px; }

/* ===== TOOLBAR ===== */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ===== MISC ===== */
.logo { width: 36px; height: 36px; border-radius: 10px; background: #0f172a; color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; margin-right: 8px; flex-shrink: 0; }
.muted { color: #64748b; font-size: 12px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eef2ff; font-size: 11px; color: #1e1b4b; border: 1px solid #e0e7ff; margin-left: 4px; }
.pill.green { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.pill.red { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.pill.yellow { background: #fffbeb; color: #92400e; border-color: #fde68a; }

/* ===== TABLES ===== */
.tbl-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid #e5e7eb; margin-top: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { border-bottom: 1px solid #e5e7eb; text-align: left; padding: 8px 10px; vertical-align: middle; white-space: nowrap; }
th { background: #f8fafc; font-weight: 600; color: #374151; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f9fafb; }
td.wrap-cell { white-space: normal; min-width: 120px; }

/* ===== PAGINARE ===== */
.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 8px; }
.pager button { padding: 4px 10px; font-size: 12px; border-radius: 6px; border: 1px solid #e5e7eb; background: #fff; cursor: pointer; }
.pager button.active { background: #0f172a; color: #fff; border-color: #0f172a; }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .pager-info { font-size: 12px; color: #64748b; margin: 0 4px; }

/* ===== STATUS BADGES ===== */
.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.badge-draft { background: #f1f5f9; color: #475569; }
.badge-in_lucru { background: #eff6ff; color: #1d4ed8; }
.badge-finalizat { background: #f0fdf4; color: #166534; }
.badge-anulat { background: #fef2f2; color: #991b1b; }

/* ===== SERVER STATUS ===== */
#serverStatus { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: #f1f5f9; cursor: pointer; border: 1px solid #e5e7eb; }
#serverStatus .dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; }
#serverStatus.connected .dot { background: #22c55e; }
#serverStatus.error .dot { background: #ef4444; }

/* ===== MODAL ===== */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: none; align-items: center; justify-content: center; z-index: 100; backdrop-filter: blur(2px); }
.modal.show { display: flex; }
.modal .box { background: #fff; border-radius: 14px; padding: 20px; width: min(860px, 96vw); max-height: 90vh; overflow: auto; border: 1px solid #e5e7eb; box-shadow: 0 20px 60px rgba(0,0,0,.18); }
.modal .box h3 { margin: 0 0 6px; font-size: 15px; font-weight: 700; }

/* ===== GANTT ===== */
.gantt-wrap { overflow: auto; border: 1px solid #e5e7eb; border-radius: 12px; }
.gantt { position: relative; min-height: 200px; }
.gantt .time-header { position: sticky; top: 0; background: #fafafa; border-bottom: 1px solid #e5e7eb; z-index: 2; }
.gantt .time-scale { display: flex; }
.gantt .time-cell { flex: 0 0 var(--pxh, 60px); border-left: 1px dashed #e5e7eb; text-align: center; font-size: 11px; color: #64748b; padding: 2px 0; }
.gantt .day-sep { background: #f1f5f9; border-left: 1px solid #cbd5e1; }
.gantt .labels { width: 220px; border-right: 1px solid #e5e7eb; background: #fff; position: sticky; left: 0; z-index: 1; }
.gantt .labels .cell { padding: 6px 10px; border-bottom: 1px solid #e5e7eb; font-size: 12px; height: 44px; display: flex; align-items: center; }
.gantt .grid-area { position: relative; flex: 1; }
.gantt .grid-row { height: 44px; border-bottom: 1px solid #f1f5f9; position: relative; }
.gantt .row { display: flex; }
.task { position: absolute; top: 7px; height: 30px; background: #6366f1; color: #fff; border-radius: 6px; display: flex; align-items: center; padding: 0 8px; cursor: grab; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: box-shadow .1s; }
.task:hover { box-shadow: 0 3px 8px rgba(0,0,0,.25); }
.task.dragging { opacity: .85; cursor: grabbing; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.task.conflict { outline: 2px solid #ef4444; }
.task.seqbad { outline: 2px solid #f59e0b; }
.task .label { pointer-events: none; white-space: nowrap; font-size: 11px; font-weight: 600; text-shadow: 0 1px 0 rgba(0,0,0,.2); }
.legend { font-size: 12px; color: #64748b; }

/* ===== PROGRESS BARS ===== */
.progress-bar { height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; margin-top: 4px; }
.progress-bar .fill { height: 100%; background: #22c55e; border-radius: 3px; transition: width .3s; }

/* ===== TOAST ===== */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 10px; color: #fff; font-size: 13px; font-weight: 500; opacity: 0; transform: translateY(10px); transition: opacity .25s, transform .25s; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }
.toast.info { background: #2563eb; }

details summary { cursor: pointer; user-select: none; }

/* ===== LOGIN SCREEN ===== */
#loginScreen { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #f6f7fb; }
.login-box { background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 32px 28px; width: min(380px, 92vw); box-shadow: 0 8px 30px rgba(0,0,0,.08); }
.login-logo { width: 52px; height: 52px; border-radius: 14px; background: #0f172a; color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; margin: 0 auto 16px; }
