/* ============================================================
   Cosmic Work Order — Brand stylesheet
   Warna utama: #29ABE2 (Cosmic Blue)
   ============================================================ */
:root {
    --cosmic:        #29ABE2;
    --cosmic-dark:   #1B8FC4;
    --cosmic-darker: #157aa8;
    --cosmic-tint:   #e8f6fc;
    --cosmic-tint-2: #d3ecf8;
    --navy:          #12303f;
    --navy-soft:     #395060;
    --ink:           #1f2d35;
    --muted:         #6b7d88;
    --line:          #e4ebef;
    --bg:            #f3f7f9;
    --white:         #ffffff;
    --green:         #1f9d57;  --green-bg:#e5f6ec;
    --amber:         #c98a00;  --amber-bg:#fdf2d9;
    --blue:          #1673b6;  --blue-bg:#e4f1fb;
    --gray:          #64757f;  --gray-bg:#eceff1;
    --red:           #cf3b3b;  --red-bg:#fbeaea;
    --shadow:        0 1px 2px rgba(18,48,63,.06), 0 4px 16px rgba(18,48,63,.06);
    --shadow-sm:     0 1px 2px rgba(18,48,63,.08);
    --radius:        12px;
    --radius-sm:     8px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    font-size: 14.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--cosmic-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; flex-shrink: 0; background: var(--navy);
    color: #cfdde5; display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px; }
.brand-mark { width: 40px; height: 40px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 800; letter-spacing: .5px; color: #fff; font-size: 17px; }
.brand-name .dot { color: var(--cosmic); }
.brand-sub { font-size: 11px; color: #8fa9b6; text-transform: uppercase; letter-spacing: 2px; margin-top: 3px; }

.nav { display: flex; flex-direction: column; padding: 8px; gap: 2px; flex: 1; }
.nav-item {
    display: flex; align-items: center; gap: 11px; padding: 11px 13px;
    color: #b9cbd5; border-radius: var(--radius-sm); font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--cosmic); color: #fff; box-shadow: var(--shadow-sm); }
.nav-ic { width: 18px; text-align: center; opacity: .95; font-size: 15px; }

.sidebar-foot { padding: 16px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.sf-name { font-weight: 700; color: #fff; font-size: 13px; }
.sf-sub { font-size: 11px; color: #7f97a3; margin-top: 2px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    display: flex; align-items: center; gap: 14px;
    background: var(--white); border-bottom: 1px solid var(--line);
    padding: 14px 24px; position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 18px; font-weight: 700; margin: 0; flex: 1; color: var(--navy); }
.hamburger { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--navy); }
.content { padding: 24px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 500; border: 1px solid transparent; }
.flash-success { background: var(--green-bg); color: #157a41; border-color: #bfe6cf; }
.flash-error   { background: var(--red-bg); color: var(--red); border-color: #f2c9c9; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px; justify-content: center;
    padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line);
    background: var(--white); color: var(--ink); font-weight: 600; font-size: 14px;
    cursor: pointer; transition: all .12s ease; text-decoration: none; line-height: 1;
}
.btn:hover { border-color: #cdd8de; text-decoration: none; box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--cosmic); border-color: var(--cosmic); color: #fff; }
.btn-primary:hover { background: var(--cosmic-dark); border-color: var(--cosmic-dark); }
.btn-dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-dark:hover { background: #0b2230; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--navy-soft); }
.btn-ghost:hover { background: var(--cosmic-tint); color: var(--cosmic-dark); }
.btn-danger { color: var(--red); border-color: #f0d0d0; background: #fff; }
.btn-danger:hover { background: var(--red-bg); border-color: #e6b3b3; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #178a49; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card {
    background: var(--white); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.card-head h2 { font-size: 15px; margin: 0; color: var(--navy); font-weight: 700; flex: 1; }
.card-body { padding: 20px; }
.card-pad { padding: 20px; }

/* ---------- Stat tiles ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat {
    background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--cosmic); }
.stat.s-green::before { background: var(--green); }
.stat.s-amber::before { background: var(--amber); }
.stat.s-blue::before  { background: var(--blue); }
.stat.s-gray::before  { background: var(--gray); }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.stat-value { font-size: 24px; font-weight: 800; color: var(--navy); margin-top: 6px; letter-spacing: -.5px; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data thead th {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
    font-weight: 700; background: #fafcfd; border-bottom: 1px solid var(--line);
}
table.data tbody tr:hover { background: var(--cosmic-tint); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.center, table.data th.center { text-align: center; }
.row-link { cursor: pointer; }
.muted { color: var(--muted); }
.strong { font-weight: 700; color: var(--navy); }
.wo-num { font-weight: 700; color: var(--cosmic-dark); font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px;
    border-radius: 20px; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-blue  { background: var(--blue-bg); color: var(--blue); }
.badge-gray  { background: var(--gray-bg); color: var(--gray); }

/* ---------- Forms ---------- */
.form-row { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; }
label.lbl { display: block; font-weight: 600; font-size: 13px; color: var(--navy-soft); margin-bottom: 6px; }
.req { color: var(--red); }
input[type=text], input[type=date], input[type=number], input[type=tel], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid #d4dee4; border-radius: var(--radius-sm);
    font-size: 14px; font-family: var(--font); color: var(--ink); background: #fff; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--cosmic); box-shadow: 0 0 0 3px rgba(41,171,226,.15);
}
textarea { resize: vertical; min-height: 76px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.search { position: relative; }
.search input { padding-left: 34px; min-width: 240px; }
.search::before { content: "⌕"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 16px; }
.filter-tabs { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.filter-tabs a { padding: 7px 13px; border-radius: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.filter-tabs a:hover { background: var(--cosmic-tint); text-decoration: none; }
.filter-tabs a.active { background: var(--cosmic); color: #fff; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .em-ic { font-size: 40px; opacity: .35; }
.empty h3 { color: var(--navy-soft); margin: 12px 0 6px; }

/* ---------- WO detail ---------- */
.detail-head { display: flex; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.detail-head .dh-main { flex: 1; min-width: 240px; }
.detail-head h2 { margin: 0 0 6px; font-size: 24px; color: var(--navy); }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.meta-item .mi-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
.meta-item .mi-value { font-weight: 600; color: var(--navy); margin-top: 3px; }

/* Timeline / status stepper */
.stepper { display: flex; gap: 0; margin: 4px 0 8px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 130px; position: relative; padding: 4px 0; }
.step .dot {
    width: 30px; height: 30px; border-radius: 50%; background: var(--gray-bg); color: var(--muted);
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex-shrink: 0; z-index: 1;
}
.step .st-txt { font-size: 12px; }
.step .st-name { font-weight: 700; color: var(--muted); }
.step .st-time { color: var(--muted); font-size: 11px; }
.step.done .dot { background: var(--cosmic); color: #fff; }
.step.done .st-name { color: var(--navy); }
.step.current .dot { background: var(--cosmic); color: #fff; box-shadow: 0 0 0 4px var(--cosmic-tint-2); }
.step:not(:last-child)::after {
    content: ""; position: absolute; left: 30px; right: -6px; top: 19px; height: 3px; background: var(--gray-bg);
}
.step.done:not(:last-child)::after { background: var(--cosmic); }

/* Action bar */
.action-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* Line item editor */
.items-table { width: 100%; border-collapse: collapse; }
.items-table th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; text-align: left; padding: 8px; }
.items-table th.num { text-align: right; }
.items-table td { padding: 6px; vertical-align: top; }
.items-table input, .items-table select { padding: 8px 9px; font-size: 13.5px; }
.items-table .qty { width: 78px; text-align: right; }
.items-table .price { text-align: right; }
.items-table .unit { width: 96px; }
.it-total { text-align: right; font-weight: 700; color: var(--navy); white-space: nowrap; padding-top: 16px; font-variant-numeric: tabular-nums; }
.it-remove { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 18px; padding: 8px; border-radius: 6px; }
.it-remove:hover { background: var(--red-bg); color: var(--red); }
.totals-box { display: flex; justify-content: flex-end; margin-top: 8px; }
.totals-box .tb { min-width: 260px; }
.tb-row { display: flex; justify-content: space-between; padding: 8px 4px; }
.tb-row.grand { border-top: 2px solid var(--line); margin-top: 4px; font-size: 18px; font-weight: 800; color: var(--navy); }

.sticky-actions { position: sticky; bottom: 0; background: var(--white); border-top: 1px solid var(--line); padding: 14px 20px; display: flex; gap: 10px; justify-content: flex-end; border-radius: 0 0 var(--radius) var(--radius); }

/* Mini chart */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 130px; padding-top: 10px; }
.bars .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar { width: 100%; max-width: 46px; background: linear-gradient(180deg, var(--cosmic), var(--cosmic-dark)); border-radius: 6px 6px 0 0; min-height: 4px; }
.bars .bar-label { font-size: 11px; color: var(--muted); }
.bars .bar-val { font-size: 10.5px; color: var(--navy-soft); font-weight: 600; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .sidebar { position: fixed; left: -240px; z-index: 50; transition: left .2s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
    .sidebar.open { left: 0; }
    .hamburger { display: block; }
    .two-col { grid-template-columns: 1fr; }
    .content { padding: 16px; }
}
