:root {
    --brand-green: #008c46;
    --brand-green-dark: #006d36;
    --brand-green-light: #e6f5ec;
    --brand-orange: #f0a01e;
    --brand-orange-light: #fef3e0;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #dbe7df;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: linear-gradient(180deg, #f0fdf4 0%, #f8fafc 100%);
    font-size: 14px;
}
body:not(.app) main { max-width: none; padding: 0; }
main { max-width: 1320px; margin: 0 auto; padding: 24px 20px; }
a { color: inherit; text-decoration: none; }
input, select, textarea, button { font: inherit; }
input, select, textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    padding: 10px 12px;
    background: white;
}
textarea { min-height: 90px; resize: vertical; }
label { display: grid; gap: 6px; color: #334155; font-weight: 650; font-size: 12px; }

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #e6f5ec 0%, #f0fdf4 50%, #fef3e0 100%);
}
.login-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 140, 70, 0.15), 0 0 0 1px rgba(0,140,70,0.05);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}
.login-head { text-align: center; padding: 32px 28px 20px; background: linear-gradient(135deg, var(--brand-green-light), white); }
.login-head img { height: 70px; margin-bottom: 12px; object-fit: contain; }
.login-head h1 { margin: 0 0 4px; font-size: 19px; font-weight: 700; color: #0c4a6e; letter-spacing: -0.01em; }
.login-head p { margin: 0; color: #64748b; font-size: 12px; }
.login-body { padding: 24px 28px 28px; }
.login-body label { display: block; font-size: 12px; font-weight: 600; color: #334155; margin-bottom: 6px; }
.login-body input { width: 100%; padding: 11px 14px; font-size: 14px; border: 1px solid #cbd5e1; border-radius: 10px; background: white; transition: all 0.15s; font-family: inherit; }
.login-body input:focus { outline: none; border-color: var(--brand-green); box-shadow: 0 0 0 3px rgba(0,140,70,0.12); }
.login-body .field { margin-bottom: 14px; }
.login-error { background: #fef2f2; color: #991b1b; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; border: 1px solid #fecaca; }
.login-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--brand-green), var(--brand-green-dark));
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,140,70,0.25);
    transition: all 0.15s;
    font-family: inherit;
}
.login-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,140,70,0.35); }
.login-hint { margin-top: 18px; padding: 12px; background: #fafbff; border: 1px solid #e0e7ff; border-radius: 8px; font-size: 11px; color: #475569; line-height: 1.5; }
.login-hint strong { color: var(--brand-green-dark); }
.btn-primary { background: linear-gradient(135deg, var(--brand-green), var(--brand-green-dark)); color: white; border: 0; box-shadow: 0 2px 8px rgba(0,140,70,0.25); }

header {
    background: white;
    border-bottom: 2px solid var(--brand-green);
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: 0 2px 8px rgba(0, 140, 70, 0.08);
}
.header-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo-img { height: 50px; width: auto; object-fit: contain; }
.brand-text { display: grid; gap: 2px; color: var(--brand-green-dark); }
.brand-text small { color: var(--muted); }
.tabs { display: flex; gap: 2px; background: #f1f5f9; padding: 3px; border-radius: 8px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 6px; color: var(--muted); font-weight: 650; font-size: 13px; }
.tab.active { background: white; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.tab.primary.active, .tab.primary:hover { background: linear-gradient(135deg, var(--brand-green), var(--brand-green-dark)); color: white; }
.role-info { display: flex; align-items: center; gap: 10px; }
.user-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; background: var(--brand-green-light); color: var(--brand-green-dark); border-radius: 20px; font-size: 12px; font-weight: 700; }
.user-pill.admin { background: var(--brand-orange-light); color: #92400e; }
.user-avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--brand-green); color: white; display: grid; place-items: center; }
.logout-btn, .btn, .link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 700;
}
.btn:disabled, .icon-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }
.logout-btn, .btn-secondary { background: white; color: #475569; border-color: #cbd5e1; }
.btn-success { background: var(--brand-green); color: white; }
.btn-orange { background: var(--brand-orange); color: white; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.link-btn { border: 0; background: transparent; color: #dc2626; padding: 0; }

.notice { border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; border: 1px solid; }
.notice.success { color: var(--brand-green-dark); background: var(--brand-green-light); border-color: #a7f3d0; }
.notice.error { color: #991b1b; background: #fef2f2; border-color: #fecaca; }
.empty, .card, .table-card, .form-card {
    background: white;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,140,70,0.04);
}
.empty { padding: 60px 20px; text-align: center; }
.empty-icon { width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 18px; background: linear-gradient(135deg, var(--brand-green-light), var(--brand-orange-light)); color: var(--brand-green); display: grid; place-items: center; font-size: 32px; font-weight: 900; }
.empty p, .muted { color: var(--muted); }
.card { padding: 20px; margin-bottom: 16px; }
.card-title { margin: 0 0 16px; color: var(--brand-green-dark); font-size: 16px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { display: grid; gap: 8px; border-radius: 16px; padding: 20px; color: white; }
.kpi span { text-transform: uppercase; letter-spacing: .07em; font-size: 11px; font-weight: 800; opacity: .9; }
.kpi strong { font-size: 24px; }
.kpi.green { background: linear-gradient(135deg, var(--brand-green), var(--brand-green-dark)); }
.kpi.orange { background: linear-gradient(135deg, var(--brand-orange), #d97706); }
.kpi.blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.kpi.slate { background: linear-gradient(135deg, #475569, #1e293b); }
.proj-grid, .master-grid, .split-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.proj-card { display: grid; gap: 8px; border: 1px solid #b7ead0; border-radius: 12px; padding: 16px; background: #fbfffd; }
.proj-card strong { color: var(--brand-green-dark); }
.toolbar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: white; border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 14px; }
.filter-form, .inline-grid { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.filter-form input { min-width: 240px; flex: 1; }
.filter-form select, .inline-grid > * { width: auto; min-width: 150px; }
.table-card { overflow: hidden; margin-bottom: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 12px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--brand-green-dark); background: var(--brand-green-light); border-bottom: 2px solid var(--brand-green); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pill { display: inline-flex; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; background: var(--brand-green-light); color: var(--brand-green-dark); }
.pill.green { background: var(--brand-green-light); color: var(--brand-green-dark); }
.pill.orange { background: var(--brand-orange-light); color: #92400e; }
.pill.danger { color: #991b1b; background: #fee2e2; }
.actions { display: flex; gap: 10px; align-items: center; }
.empty-row { text-align: center; color: var(--muted); padding: 24px; }
.icon-btn {
    border: 1px solid #cbd5e1;
    background: white;
    color: #475569;
    border-radius: 7px;
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 11px;
    cursor: pointer;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-btn i { font-size: 13px; line-height: 1; }
.icon-btn.danger { color: #dc2626; border-color: #fecaca; background: #fff7f7; }
.icon-btn.success { color: var(--brand-green-dark); border-color: #a7f3d0; background: #f0fdf4; }
.form-card { overflow: hidden; }
.form-header { padding: 20px 26px; border-bottom: 1px solid var(--brand-green-light); background: linear-gradient(135deg, var(--brand-green-light), white); }
.form-header h2 { margin: 0; color: var(--brand-green-dark); }
.form-header p { margin: 4px 0 0; color: var(--muted); }
.form-body { padding: 26px; display: grid; gap: 20px; }
.form-body h3 { margin: 0; color: var(--brand-green); text-transform: uppercase; letter-spacing: .08em; font-size: 11px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.form-footer { display: flex; justify-content: flex-end; gap: 8px; padding-top: 10px; border-top: 1px solid var(--brand-green-light); }
.form-stack { display: grid; gap: 10px; align-content: start; }
.form-stack h2, .form-stack h3 { margin: 0; color: var(--brand-green-dark); }

.master-shell { border-radius: 14px; }
.master-intro { color: #64748b; font-size: 13px; margin: 0 0 16px; }
.master-tabs { display: flex; gap: 2px; background: #f1f5f9; padding: 3px; border-radius: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.master-tab { padding: 8px 14px; font-size: 12px; font-weight: 600; border: none; background: transparent; border-radius: 7px; cursor: pointer; color: #64748b; transition: all 0.15s; font-family: inherit; }
.master-tab.active { background: white; color: var(--brand-green-dark); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.master-add-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 14px; background: linear-gradient(135deg, var(--brand-green-light), white); border-radius: 10px; margin-bottom: 12px; border: 1px solid rgba(0,140,70,0.15); }
.master-add-row input, .master-add-row select { flex: 1; min-width: 160px; padding: 9px 13px; border: 1px solid #cbd5e1; border-radius: 7px; font-size: 13px; font-family: inherit; }
.master-add-row input:focus, .master-add-row select:focus, .master-tools input:focus { outline: none; border-color: var(--brand-green); box-shadow: 0 0 0 3px rgba(0,140,70,0.1); }
.master-list { max-height: 500px; overflow-y: auto; border: 1px solid #e6f5ec; border-radius: 10px; }
.master-item { display: flex; align-items: center; justify-content: space-between; padding: 11px 16px; border-bottom: 1px solid #f1f5f9; gap: 8px; flex-wrap: wrap; }
.master-item:last-child { border-bottom: none; }
.master-item:hover { background: var(--brand-green-light); }
.master-item-main { flex: 1; min-width: 260px; }
.master-item-name { flex: 1; font-size: 13px; }
.master-item-code { color: #94a3b8; font-size: 11px; font-weight: 500; }
.master-item-meta { font-size: 11px; color: #94a3b8; margin-top: 4px; }
.master-item-meta.orange { color: var(--brand-orange); font-weight: 600; }
.master-section-bar { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 10px; gap: 10px; flex-wrap: wrap; }
.master-section-bar > div:first-child { font-size: 13px; font-weight: 700; color: var(--brand-green-dark); }
.master-section-bar span { color: #94a3b8; font-weight: 500; }
.master-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.master-tools input { padding: 7px 11px; font-size: 12px; border: 1px solid #cbd5e1; border-radius: 7px; width: 220px; }
.master-note { background: #f0fdf4; border: 1px solid #a7f3d0; border-radius: 8px; padding: 10px 14px; font-size: 12px; color: #065f46; margin-bottom: 14px; }
.master-inline-edit { width: 100%; display: flex; gap: 8px; padding-top: 10px; }
.master-inline-edit[hidden] { display: none; }
.master-inline-edit input, .master-inline-edit select { flex: 1; min-width: 150px; padding: 8px 11px; border: 1px solid #cbd5e1; border-radius: 7px; font-size: 13px; background: white; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; width: auto; min-width: max-content; font-size: 12px; font-weight: 700; color: #334155; }
.inline-check input { width: auto; min-width: 0; }
.bulk-title { margin: 14px 0 8px; font-size: 12px; color: #64748b; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.bulk-area { border: 1px dashed #b7ead0; border-radius: 10px; padding: 12px; background: #fbfffd; }
.bulk-area textarea { width: 100%; min-height: 92px; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; resize: vertical; font-family: inherit; }
.bulk-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.bulk-actions span { font-size: 11px; color: #94a3b8; }
.vendor-po-panel { margin-top: 16px; padding: 16px; border: 1px solid #e6f5ec; border-radius: 12px; background: #fff; }
.vendor-po-panel h3 { margin: 0 0 12px; color: var(--brand-green-dark); font-size: 16px; }
.vendor-po-panel table input, .vendor-po-panel table select { width: 100%; min-width: 110px; padding: 7px 9px; border: 1px solid #cbd5e1; border-radius: 7px; background: white; font-size: 12px; }
.vendor-po-panel table input.num { text-align: right; }
.table-actions { display: flex; gap: 6px; align-items: center; }
.table-actions form { margin: 0; }
.po-row { background: linear-gradient(135deg, #fff7ed, white); border-color: rgba(240,160,30,0.25); }
.master-subtle { font-size: 11px; color: #94a3b8; margin-bottom: 12px; }
.project-budget-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.project-budget-row input { width: 160px; padding: 7px 11px; border: 1px solid #cbd5e1; border-radius: 7px; font-size: 13px; background: #f8fafc; color: #64748b; }
.rental-add-box { background: linear-gradient(135deg, var(--brand-green-light), white); border: 1px solid rgba(0,140,70,0.2); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.rental-add-box h3 { margin: 0 0 12px; font-size: 14px; font-weight: 700; color: var(--brand-green-dark); }
.rental-actions { margin-top: 14px; text-align: right; }
.rental-amount { font-weight: 700; font-size: 13px; color: var(--brand-green-dark); }

@media (max-width: 760px) {
    main { padding: 16px 12px; }
    .header-inner { align-items: stretch; }
    .tabs, .role-info, .brand { width: 100%; }
    .filter-form, .inline-grid, .master-add-row, .master-tools, .bulk-actions, .master-inline-edit { display: grid; width: 100%; }
    .filter-form input, .filter-form select, .inline-grid > *, .master-add-row > *, .master-tools input { width: 100%; min-width: 0; }
}
