/* Forge ERP — SAP Fiori-inspired stylesheet */
:root {
    --shell-bg: #223548;
    --shell-h: 48px;
    --sidebar-w: 224px;
    --primary: #0070f2;
    --primary-d: #0054ba;
    --success: #107e3e;
    --warning: #e9730c;
    --danger: #bb0000;
    --border: #d9d9d9;
    --text: #32363a;
    --muted: #6a6d70;
    --bg: #f5f6fa;
    --card: #fff;
    --shadow: 0 1px 4px rgba(0,0,0,.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }

/* ── Shell Bar ───────────────────────────────────────────────────────────── */
.shell {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    height: var(--shell-h);
    background: var(--shell-bg);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.shell-left, .shell-right { display: flex; align-items: center; gap: 12px; }
.shell-toggle {
    background: none; border: none; color: #fff;
    font-size: 20px; cursor: pointer; padding: 4px 8px;
    border-radius: 4px; line-height: 1; display: flex; align-items: center;
}
.shell-toggle:hover { background: rgba(255,255,255,.12); }
.shell-brand {
    display: flex; align-items: center; gap: 9px;
    text-decoration: none; color: #fff;
}
.brand-icon { font-size: 22px; color: #4db8ff; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: .6px; }
.shell-sep { width: 1px; height: 22px; background: rgba(255,255,255,.22); }
.shell-sub { color: rgba(255,255,255,.55); font-size: 13px; }
.shell-user { display: flex; align-items: center; gap: 7px; color: rgba(255,255,255,.85); font-size: 13px; }
.shell-role {
    background: rgba(255,255,255,.15); padding: 2px 8px; border-radius: 10px;
    font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #fff;
}
.shell-logout {
    color: rgba(255,255,255,.75); text-decoration: none; font-size: 13px;
    padding: 5px 12px; border: 1px solid rgba(255,255,255,.22); border-radius: 4px;
    display: flex; align-items: center; gap: 5px; transition: .15s;
}
.shell-logout:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.layout {
    display: flex;
    margin-top: var(--shell-h);
    min-height: calc(100vh - var(--shell-h));
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--card);
    border-right: 1px solid var(--border);
    position: fixed;
    top: var(--shell-h); left: 0; bottom: 0;
    overflow-y: auto;
    transition: width .2s ease;
    z-index: 200;
}
.sidebar.collapsed { width: 52px; }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-section { display: none; }
.sidebar.collapsed .nav-link { padding: 11px 14px; justify-content: center; }

.nav-list { list-style: none; padding: 6px 0; }
.nav-section {
    padding: 14px 16px 4px;
    font-size: 10px; font-weight: 700;
    color: var(--muted); letter-spacing: 1.2px; text-transform: uppercase;
}
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 16px; color: var(--text); text-decoration: none;
    border-left: 3px solid transparent;
    transition: background .12s, color .12s;
    font-size: 13.5px;
}
.nav-link i { font-size: 16px; color: var(--muted); min-width: 18px; flex-shrink: 0; }
.nav-link:hover { background: #eef3ff; color: var(--primary); }
.nav-link:hover i { color: var(--primary); }
.nav-link.active { background: #e3ecff; color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.nav-link.active i { color: var(--primary); }

/* ── Content ─────────────────────────────────────────────────────────────── */
.content {
    margin-left: var(--sidebar-w);
    flex: 1; padding: 24px 28px;
    transition: margin-left .2s ease;
    min-width: 0;
}
.sidebar.collapsed ~ .content { margin-left: 52px; }

/* ── Page Header ─────────────────────────────────────────────────────────── */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 22px; font-weight: 300; color: var(--text); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Breadcrumb ──────────────────────────────────────────────────────────── */
.breadcrumb {
    display: flex; align-items: center; gap: 5px;
    margin-bottom: 14px; font-size: 12.5px; color: var(--muted);
}
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

/* ── Stat Tiles ──────────────────────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px; margin-bottom: 24px;
}
.stat-tile {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 6px; padding: 16px 14px;
    box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.stat-tile .s-icon { font-size: 22px; color: var(--primary); margin-bottom: 8px; }
.stat-tile .s-val { font-size: 30px; font-weight: 300; line-height: 1; }
.stat-tile .s-label { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.stat-tile.warn .s-val { color: var(--warning); }
.stat-tile.ok .s-val { color: var(--success); }
.stat-tile.err .s-val { color: var(--danger); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 6px; box-shadow: var(--shadow); margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 13px 16px; border-bottom: 1px solid var(--border);
    background: #fafafa;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text); }
.card-body { padding: 16px; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.toolbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; border-bottom: 1px solid var(--border);
    background: #fafafa; gap: 10px; flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }
.search-box {
    display: flex; align-items: center; gap: 7px;
    background: #fff; border: 1px solid var(--border);
    border-radius: 4px; padding: 5px 10px;
}
.search-box input { border: none; outline: none; font-size: 13px; background: none; width: 200px; }
.search-box i { color: var(--muted); font-size: 14px; }

.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
    background: #f5f6fa; padding: 9px 12px;
    text-align: left; font-weight: 600; font-size: 11.5px;
    color: var(--muted); text-transform: uppercase; letter-spacing: .5px;
    border-bottom: 2px solid var(--border); white-space: nowrap;
}
.tbl td { padding: 9px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.tbl tbody tr:hover td { background: #f6f9ff; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl-empty { text-align: center; color: var(--muted); padding: 40px !important; }
.tbl-number { font-family: 'Consolas', 'Courier New', monospace; font-size: 12.5px; }
.tbl-amount { font-family: 'Consolas', 'Courier New', monospace; font-weight: 600; text-align: right; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px; border-radius: 4px; font-size: 13px;
    font-weight: 500; cursor: pointer; border: 1px solid transparent;
    text-decoration: none; transition: .15s; line-height: 1.3; white-space: nowrap;
    vertical-align: middle;
}
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: #f0f1f2; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.9); }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover { filter: brightness(.9); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover  { filter: brightness(.9); }
.btn-ghost { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-ghost:hover { background: #e3ecff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 7px; font-size: 11px; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block; padding: 3px 9px; border-radius: 12px;
    font-size: 11px; font-weight: 600; letter-spacing: .2px; white-space: nowrap;
}
.b-draft     { background: #f0f0f0; color: #6a6d70; }
.b-confirmed { background: #dceeff; color: #0070f2; }
.b-production{ background: #fff0e0; color: #c05700; }
.b-delivered { background: #dff5e6; color: #107e3e; }
.b-cancelled { background: #fde8e8; color: #aa0000; }
.b-open      { background: #dceeff; color: #0070f2; }
.b-converted { background: #f0f0f0; color: #6a6d70; }
.b-sent      { background: #fff0e0; color: #c05700; }
.b-partial   { background: #fff0e0; color: #c05700; }
.b-received  { background: #dff5e6; color: #107e3e; }
.b-planned   { background: #f0f0f0; color: #6a6d70; }
.b-progress  { background: #fff0e0; color: #c05700; }
.b-completed { background: #dff5e6; color: #107e3e; }
.b-active    { background: #dff5e6; color: #107e3e; }
.b-on-hold   { background: #fff0e0; color: #c05700; }
.b-todo      { background: #f0f0f0; color: #6a6d70; }
.b-done      { background: #dff5e6; color: #107e3e; }
.b-pending   { background: #f0f0f0; color: #6a6d70; }
.b-inprogress{ background: #fff0e0; color: #c05700; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-wrap { max-width: 820px; }
.form-section { margin-bottom: 28px; }
.form-section-title {
    font-size: 13px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .5px; color: var(--muted); margin-bottom: 12px;
    padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.form-group { margin-bottom: 14px; }
.form-label {
    display: block; font-size: 12.5px; font-weight: 600;
    margin-bottom: 5px; color: var(--text);
}
.form-label.req::after { content: ' *'; color: var(--danger); }
.form-control {
    width: 100%; padding: 7px 10px;
    border: 1px solid var(--border); border-radius: 4px;
    font-size: 13px; color: var(--text); background: #fff;
    transition: border-color .15s;
    appearance: none;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0,112,242,.15); }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236a6d70' d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Line Items Editor ───────────────────────────────────────────────────── */
.lines-table { width: 100%; border-collapse: collapse; }
.lines-table th {
    background: #f5f6fa; padding: 8px 10px;
    font-size: 11.5px; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .4px;
    border-bottom: 2px solid var(--border); text-align: left;
}
.lines-table td { padding: 5px 6px; border-bottom: 1px solid #f0f0f0; }
.lines-table input, .lines-table select {
    width: 100%; padding: 5px 8px; border: 1px solid var(--border);
    border-radius: 3px; font-size: 13px; background: #fff;
}
.lines-table input:focus, .lines-table select:focus {
    outline: none; border-color: var(--primary);
}
.lines-table .del-btn {
    background: none; border: none; color: #bb0000; cursor: pointer;
    font-size: 18px; line-height: 1; padding: 2px 5px; border-radius: 3px;
}
.lines-table .del-btn:hover { background: #fde8e8; }
.add-line { margin-top: 10px; }

/* ── Detail View ─────────────────────────────────────────────────────────── */
.detail-grid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 14px 24px; margin-bottom: 20px;
}
.detail-item .dl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }
.detail-item .dv { font-size: 14px; font-weight: 500; }
.detail-item .dv.mono { font-family: 'Consolas', monospace; font-size: 13px; }
.detail-item .dv.big { font-size: 18px; }

/* ── Progress ────────────────────────────────────────────────────────────── */
.progress { width: 100%; height: 8px; background: #e0e0e0; border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 4px; transition: width .4s; }
.progress-bar.green { background: var(--success); }

/* ── Phase Row ───────────────────────────────────────────────────────────── */
.phase-row {
    display: flex; align-items: center; gap: 14px;
    padding: 11px 0; border-bottom: 1px solid #f0f0f0;
}
.phase-row:last-child { border-bottom: none; }
.phase-dot {
    width: 34px; height: 34px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; flex-shrink: 0;
}
.phase-dot.pending   { background: #f0f0f0; color: var(--muted); }
.phase-dot.progress  { background: #fff0e0; color: var(--warning); }
.phase-dot.completed { background: #dff5e6; color: var(--success); }
.phase-info { flex: 1; }
.phase-name { font-weight: 500; font-size: 13.5px; }
.phase-hours { font-size: 12px; color: var(--muted); margin-top: 2px; }
.phase-actions { display: flex; gap: 6px; align-items: center; }
.phase-actions input[type=number] { width: 70px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 3px; font-size: 12px; }

/* ── Flash Messages ──────────────────────────────────────────────────────── */
.flashes { margin-bottom: 16px; }
.flash {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 4px; margin-bottom: 7px; font-size: 13px;
}
.flash button { margin-left: auto; background: none; border: none; cursor: pointer; font-size: 18px; line-height: 1; opacity: .55; }
.flash-success { background: #dff5e6; color: #107e3e; border: 1px solid #a8d8b4; }
.flash-danger  { background: #fde8e8; color: #aa0000; border: 1px solid #e8a0a0; }
.flash-warning { background: #fff0e0; color: #9a4500; border: 1px solid #f5c88a; }
.flash-info    { background: #dceeff; color: #0058c4; border: 1px solid #a0c8f0; }

/* ── Login Page ──────────────────────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a2a3a 0%, #223548 60%, #182330 100%);
    display: flex; align-items: center; justify-content: center;
}
.login-card {
    background: #fff; border-radius: 8px; padding: 40px 36px;
    width: 100%; max-width: 380px;
    box-shadow: 0 8px 40px rgba(0,0,0,.35);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .icon { font-size: 42px; color: var(--primary); }
.login-logo h1 { font-size: 21px; font-weight: 700; letter-spacing: .8px; margin-top: 8px; }
.login-logo p { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ── Helpers ─────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.mono { font-family: 'Consolas', 'Courier New', monospace; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.gap-8 { gap: 8px; }
.d-flex { display: flex; } .ai-center { align-items: center; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.mobile-open { transform: translateX(0); }
    .content { margin-left: 0 !important; }
    .detail-grid { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2, .form-grid .span-3 { grid-column: span 1; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }
