@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root {
  --navy: #071426;
  --navy-2: #0d223e;
  --blue: #0620ed;
  --orange: #f96204;
  --orange-deep: #c94700;
  --ink: #142033;
  --muted: #64748b;
  --line: #dce3ec;
  --soft: #f4f7fb;
  --white: #fff;
  --success: #0b8c64;
  --warning: #bd6900;
  --danger: #c43e35;
  --shadow: 0 18px 50px rgba(24, 39, 65, .08);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--soft); }
body { margin: 0; color: var(--ink); background: var(--soft); font-family: 'Manrope', Arial, sans-serif; font-size: 14px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 264px minmax(0, 1fr); }
.sidebar { min-height: 100vh; position: sticky; top: 0; height: 100vh; padding: 26px 18px 18px; display: flex; flex-direction: column; color: white; background: linear-gradient(180deg, #071426 0%, #091a30 100%); z-index: 30; }
.system-brand { display: block; padding: 4px 10px 25px; border-bottom: 1px solid rgba(255,255,255,.09); }
.system-brand img { width: 166px; display: block; }
.system-brand span { display: block; margin-top: 12px; color: #8293ad; font-size: 10px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.side-nav { padding-top: 24px; display: grid; gap: 6px; }
.side-nav p { margin: 20px 12px 6px; color: #657a99; font-size: 9px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.side-nav a { min-height: 48px; padding: 8px 12px; display: flex; gap: 13px; align-items: center; border-radius: 10px; color: #aebbd0; font-weight: 650; transition: .18s ease; }
.side-nav a:hover { color: white; background: rgba(255,255,255,.06); }
.side-nav a.active { color: white; background: linear-gradient(90deg, rgba(6,32,237,.42), rgba(6,32,237,.12)); box-shadow: inset 3px 0 var(--orange); }
.side-nav i { width: 29px; height: 29px; border: 1px solid rgba(255,255,255,.14); border-radius: 8px; display: grid; place-items: center; color: #9fb0ca; font-size: 11px; font-style: normal; font-weight: 800; }
.side-nav a.active i { color: white; border-color: rgba(255,255,255,.35); }
.sidebar-foot { margin-top: auto; padding: 16px 10px 4px; border-top: 1px solid rgba(255,255,255,.09); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sidebar-foot span, .sidebar-foot small { display: block; }
.sidebar-foot span { font-size: 12px; font-weight: 700; }
.sidebar-foot small { margin-top: 3px; color: #7387a4; font-size: 9px; }
.sidebar-foot button { padding: 7px 9px; border: 1px solid rgba(255,255,255,.15); border-radius: 7px; color: #aebbd0; background: transparent; font-size: 10px; }

.main-panel { min-width: 0; }
.topbar { height: 78px; padding: 0 34px; position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(205,215,228,.75); background: rgba(255,255,255,.9); backdrop-filter: blur(18px); }
.topbar small, .topbar strong { display: block; }
.topbar small { margin-bottom: 2px; color: #8794a6; font-size: 8px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.topbar strong { color: var(--navy); font-size: 15px; }
.site-link { padding: 9px 13px; border: 1px solid var(--line); border-radius: 8px; color: #526178; font-size: 11px; font-weight: 700; background: white; }
.menu-button { display: none; border: 0; background: none; font-size: 20px; }
.page-content { width: min(1450px, 100%); margin: 0 auto; padding: 38px 34px 70px; }
.overline { margin: 0 0 10px; color: var(--orange-deep); font-size: 9px; font-weight: 800; letter-spacing: .17em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 9px; color: var(--navy); font-size: clamp(30px, 3vw, 46px); line-height: 1.06; letter-spacing: -.045em; }
h2 { margin-bottom: 8px; color: var(--navy); font-size: 22px; line-height: 1.16; letter-spacing: -.025em; }
h3 { color: var(--navy); }
.muted { color: var(--muted); }

.welcome-row, .page-heading, .detail-heading { display: flex; justify-content: space-between; gap: 30px; align-items: flex-end; }
.welcome-row { margin-bottom: 32px; }
.welcome-row > div:first-child > p:last-child, .page-heading > div > p:last-child { margin: 0; color: var(--muted); font-size: 14px; }
.quick-actions, .detail-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.button { min-height: 42px; padding: 0 17px; border: 1px solid transparent; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--navy); background: white; font-weight: 750; font-size: 12px; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--blue); box-shadow: 0 10px 24px rgba(6,32,237,.18); }
.button.secondary { border-color: #c9d3df; background: white; }
.button.ghost { color: #55647a; background: #edf1f6; }
.button.small { min-height: 34px; padding: 0 12px; font-size: 10px; }
.button.wide { width: 100%; }

.panel { border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: var(--shadow); }
.metric-grid { display: grid; grid-template-columns: 1.35fr repeat(4, 1fr); gap: 15px; margin-bottom: 20px; }
.metric { min-height: 155px; padding: 24px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--line); border-radius: 13px; background: white; }
.metric small { color: #6e7d91; font-size: 10px; font-weight: 750; letter-spacing: .04em; }
.metric strong { color: var(--navy); font-size: 31px; letter-spacing: -.035em; }
.metric a, .metric span { color: #66758a; font-size: 10px; font-weight: 650; }
.metric.featured { color: white; border: 0; background: linear-gradient(135deg, #061425, #0d2a4e); box-shadow: 0 18px 45px rgba(7,20,38,.2); }
.metric.featured small, .metric.featured span { color: #98a9c1; }
.metric.featured strong { color: white; }
.metric.outcome-metric { border-color: #bfe5d8; background: linear-gradient(145deg, #f7fffc, #edf9f5); }
.metric.outcome-metric strong { color: var(--success); }
.dashboard-columns { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, .7fr); gap: 20px; }
.panel-head { padding: 24px 24px 8px; }
.activity-list { padding: 8px 15px 16px; }
.activity-list > a { min-height: 72px; padding: 11px 9px; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 13px; align-items: center; border-bottom: 1px solid #e8edf3; }
.activity-list > a:last-child { border-bottom: 0; }
.activity-list strong, .activity-list small { display: block; }
.activity-list strong { margin-bottom: 4px; font-size: 12px; }
.activity-list small { color: #758397; font-size: 9px; }
.doc-icon { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 9px; color: white; background: var(--blue); font-size: 11px; font-style: normal; font-weight: 800; text-transform: uppercase; }
.doc-icon.i { background: var(--orange); }
.doc-icon.b { background: var(--navy-2); }
.workflow-panel { padding: 26px; color: white; background: var(--navy); }
.workflow-panel h2 { color: white; font-size: 27px; }
.workflow { margin-top: 25px; display: grid; grid-template-columns: 29px 1fr; gap: 0 13px; }
.workflow > span { width: 29px; height: 29px; position: relative; z-index: 1; display: grid; place-items: center; border-radius: 50%; color: white; background: var(--blue); font-size: 8px; font-weight: 800; }
.workflow > span:nth-of-type(3) { background: var(--orange); }
.workflow > div { min-height: 82px; position: relative; }
.workflow > div:not(:last-child)::before { content: ''; position: absolute; left: -28px; top: 29px; bottom: 0; width: 1px; background: #284260; }
.workflow strong { display: block; margin-bottom: 4px; }
.workflow p { color: #8fa1ba; font-size: 10px; line-height: 1.45; }

.messages { margin-bottom: 16px; }
.message { padding: 13px 16px; border: 1px solid #a8dfc9; border-radius: 9px; color: #096e51; background: #edf9f5; font-size: 12px; font-weight: 650; }
.page-heading { margin-bottom: 24px; }
.back-link { display: inline-block; margin-bottom: 13px; color: #718096; font-size: 11px; font-weight: 700; }
.filterbar { margin-bottom: 14px; padding: 12px; display: flex; gap: 9px; border: 1px solid var(--line); border-radius: 11px; background: white; }
.filterbar input, .filterbar select { min-height: 42px; padding: 0 12px; border: 1px solid #d4dde8; border-radius: 8px; color: var(--ink); background: white; outline: none; }
.filterbar input { flex: 1; }
.filterbar select { min-width: 190px; }
.filterbar input:focus, .filterbar select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(6,32,237,.09); }
.table-panel { overflow: hidden; }
.data-table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { padding: 13px 16px; color: #758398; background: #f5f7fa; font-size: 8px; font-weight: 800; letter-spacing: .11em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { padding: 16px; border-top: 1px solid #e7ecf2; color: #425168; font-size: 11px; vertical-align: top; }
.data-table td > strong, .data-table td > small { display: block; }
.data-table td > strong { color: var(--ink); font-size: 11.5px; }
.data-table td > small { margin-top: 4px; color: #7b899d; font-size: 9px; line-height: 1.4; }
.row-action { padding: 7px 10px; border: 1px solid #d6dee8; border-radius: 7px; color: var(--navy); background: white; font-size: 9px; font-weight: 800; }
.status { display: inline-flex; padding: 5px 8px; border-radius: 20px; color: #59687b; background: #edf1f5; font-size: 8px; font-style: normal; font-weight: 800; letter-spacing: .03em; white-space: nowrap; }
.status.success { color: #087657; background: #e4f7f0; }
.status.info { color: #1737b6; background: #e8edff; }
.status.warning { color: #a25900; background: #fff1dc; }
.status.danger { color: #ae3029; background: #fdebe9; }
.status.large { padding: 7px 11px; font-size: 9px; }
.empty-state { padding: 48px 20px; text-align: center; }
.empty-state.compact { padding: 28px 10px; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--navy); }
.empty-state p { margin: 0; color: var(--muted); font-size: 11px; }

.form-panel { margin-bottom: 18px; padding: 26px; }
.form-section-head { margin-bottom: 22px; display: flex; align-items: flex-start; gap: 14px; }
.form-section-head > span { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 8px; color: white; background: var(--blue); font-size: 9px; font-weight: 800; }
.form-section-head > div { flex: 1; }
.form-section-head h2 { margin: 0 0 4px; font-size: 18px; }
.form-section-head p { margin: 0; color: var(--muted); font-size: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field.wide { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 7px; color: #536278; font-size: 9px; font-weight: 800; letter-spacing: .035em; }
.form-control, .login-card input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #d2dbe6; border-radius: 8px; color: var(--ink); background: white; outline: none; transition: .15s ease; }
textarea.form-control { min-height: 70px; resize: vertical; line-height: 1.45; }
select.form-control { appearance: auto; }
input[type='checkbox'].form-control { width: 18px; min-height: 18px; padding: 0; }
.form-control:focus, .login-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(6,32,237,.09); }
.field > small { display: block; margin-top: 6px; color: #8995a6; font-size: 8.5px; line-height: 1.4; }
.errorlist { margin: 6px 0 0; padding: 0; list-style: none; color: var(--danger); font-size: 9px; }
.form-alert { margin-bottom: 16px; padding: 12px 14px; border: 1px solid #f0bbb8; border-radius: 8px; color: var(--danger); background: #fff1f0; font-size: 11px; }
.form-actions { margin-top: 25px; padding-top: 18px; display: flex; justify-content: flex-end; gap: 9px; border-top: 1px solid var(--line); }
.line-items { display: grid; gap: 12px; }
.line-item { padding: 15px; display: grid; grid-template-columns: 33px minmax(0, 1fr) auto; gap: 13px; align-items: start; border: 1px solid #dce3ec; border-radius: 10px; background: #fbfcfe; }
.line-index { padding-top: 23px; }
.line-index span { width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; color: var(--blue); background: #e9edff; font-size: 8px; font-weight: 800; }
.line-fields { display: grid; grid-template-columns: 76px minmax(260px, 1fr) 100px 110px 160px; gap: 11px; align-items: end; }
.line-fields.scope-fields { grid-template-columns: 76px minmax(280px, 1fr); }
.line-fields.photo-fields { grid-template-columns: 125px minmax(220px, .8fr) minmax(240px, 1fr) 80px; }
.line-fields textarea { min-height: 62px; }
.delete-row { margin-top: 29px; display: flex; gap: 5px; align-items: center; color: #9a5860; font-size: 8px; font-weight: 750; }
.delete-row input { accent-color: var(--danger); }
.line-subtotal { grid-column: 1 / -1; justify-self: end; color: #536278; font-size: 9px; font-weight: 800; }
.sticky-actions { position: sticky; bottom: 16px; z-index: 10; margin-top: 22px; padding: 13px 15px; display: flex; align-items: center; gap: 9px; border: 1px solid #ced8e4; border-radius: 12px; background: rgba(255,255,255,.94); box-shadow: 0 18px 50px rgba(21,37,61,.15); backdrop-filter: blur(15px); }
.sticky-actions > div { flex: 1; color: #728095; font-size: 9px; }
.line-item.deleted { opacity: .45; filter: grayscale(.35); }

.detail-heading { margin-bottom: 22px; }
.detail-number { display: flex; gap: 13px; align-items: center; }
.detail-number p { margin: 0 0 3px; color: #728096; font-size: 9px; font-weight: 750; }
.detail-number h1 { margin: 0; font-size: 30px; }
.detail-heading .status { margin-top: 13px; }
.status-stack { display: flex; gap: 7px; flex-wrap: wrap; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 19px; }
.detail-main { padding: 27px; }
.document-summary { margin-bottom: 28px; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); }
.document-summary > div { min-height: 108px; padding: 18px; border-right: 1px solid var(--line); }
.document-summary > div:last-child { border-right: 0; }
.document-summary small, .document-summary strong, .document-summary span { display: block; }
.document-summary small { margin-bottom: 9px; color: #8190a3; font-size: 8px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.document-summary strong { color: var(--navy); font-size: 12px; }
.document-summary span { margin-top: 5px; color: #66758a; font-size: 9px; line-height: 1.4; }
.item-detail th:nth-child(n+3), .item-detail td:nth-child(n+3) { text-align: right; }
.total-row td { color: var(--navy); background: #edf1ff; font-weight: 800; }
.total-row td:first-child { text-align: right; }
.scope-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.scope-list li { padding: 14px 0; display: grid; grid-template-columns: 38px 1fr; border-bottom: 1px solid var(--line); }
.scope-list span { color: var(--blue); font-size: 9px; font-weight: 800; }
.scope-list p { margin: 0; color: #4f5f74; line-height: 1.5; }
.note-box { margin-top: 20px; padding: 17px; border-left: 3px solid var(--blue); background: #eef2ff; }
.note-box small { color: var(--blue); font-size: 8px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.note-box p { margin: 7px 0 0; color: #405067; font-size: 10px; line-height: 1.5; }
.detail-side { display: grid; gap: 15px; align-content: start; }
.detail-side .panel { padding: 20px; }
.next-step { color: white; background: var(--navy); }
.next-step h3 { color: white; font-size: 18px; }
.next-step a { padding: 13px 0; display: flex; justify-content: space-between; border-top: 1px solid rgba(255,255,255,.12); color: #c6d1df; font-size: 10px; font-weight: 700; }
.metadata h3 { margin-bottom: 16px; font-size: 14px; }
.metadata dl { margin: 0; }
.metadata dl > div { display: contents; }
.metadata dt { padding-top: 11px; border-top: 1px solid var(--line); color: #8390a1; font-size: 8px; font-weight: 750; text-transform: uppercase; }
.metadata dd { margin: 3px 0 11px; color: #425168; font-size: 10px; }
.metadata dd a { color: var(--blue); }
.photo-thumb-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.photo-thumb-grid a { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #f4f6f9; }
.photo-thumb-grid img { width: 100%; aspect-ratio: 4 / 3; display: block; object-fit: cover; }
.photo-thumb-grid span { padding: 6px; display: block; color: #65748a; font-size: 7px; text-align: center; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.15fr .85fr; background: white; }
.login-visual { min-height: 100vh; padding: 48px 7vw; display: flex; flex-direction: column; justify-content: space-between; color: white; background: radial-gradient(circle at 80% 70%, rgba(6,32,237,.4), transparent 32%), linear-gradient(135deg, #071426, #0b213d); }
.login-visual img { width: 210px; }
.login-visual > div { max-width: 620px; padding-bottom: 8vh; }
.login-visual p { color: #ff8643; font-size: 10px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.login-visual h1 { color: white; font-size: clamp(40px, 5vw, 70px); }
.login-visual span { color: #91a3bd; font-size: 12px; letter-spacing: .08em; }
.login-panel { padding: 40px; display: grid; place-items: center; background: #f7f9fc; }
.login-card { width: min(420px, 100%); padding: 40px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: var(--shadow); }
.login-card h2 { margin-bottom: 6px; font-size: 30px; }
.login-card > p:not(.overline) { margin-bottom: 27px; color: var(--muted); }
.login-card label { display: block; margin: 14px 0 7px; color: #536278; font-size: 9px; font-weight: 800; }
.login-card .button { margin-top: 22px; }
.login-card > small { display: block; margin-top: 16px; color: #8a96a7; font-size: 8px; text-align: center; }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-columns, .detail-grid { grid-template-columns: 1fr; }
  .line-fields { grid-template-columns: 65px minmax(220px, 1fr) 90px 100px; }
  .line-fields .field-unit_price { grid-column: 2 / -1; }
  .line-fields.photo-fields { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { width: 270px; position: fixed; left: -285px; transition: left .22s ease; box-shadow: 15px 0 50px rgba(0,0,0,.3); }
  .sidebar.open { left: 0; }
  .menu-button { display: block; }
  .topbar { padding: 0 18px; justify-content: flex-start; gap: 16px; }
  .site-link { margin-left: auto; }
  .page-content { padding: 27px 18px 60px; }
  .welcome-row, .page-heading, .detail-heading { display: grid; align-items: start; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .form-grid, .document-summary { grid-template-columns: 1fr; }
  .document-summary > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .document-summary > div:last-child { border-bottom: 0; }
  .line-item { grid-template-columns: 1fr; }
  .line-index, .delete-row { padding: 0; margin: 0; }
  .line-fields, .line-fields.scope-fields, .line-fields.photo-fields { grid-template-columns: 1fr 1fr; }
  .line-fields .field-description { grid-column: 1 / -1; }
  .sticky-actions { position: static; flex-wrap: wrap; }
  .sticky-actions > div { flex-basis: 100%; }
  .login-page { grid-template-columns: 1fr; }
  .login-visual { display: none; }
}

@media (max-width: 560px) {
  .metric-grid { grid-template-columns: 1fr; }
  .filterbar { flex-wrap: wrap; }
  .filterbar input, .filterbar select, .filterbar .button { width: 100%; }
  .line-fields, .line-fields.scope-fields, .line-fields.photo-fields { grid-template-columns: 1fr; }
  .line-fields .field-unit_price { grid-column: auto; }
  .form-panel, .detail-main { padding: 19px; }
  .detail-actions .button { flex: 1; }
  .login-panel { padding: 18px; }
  .login-card { padding: 26px 22px; }
}
