:root {
  --bg: #f3f6f8;
  --panel: #ffffff;
  --ink: #17232c;
  --muted: #6c7c87;
  --line: #dfe6ea;
  --brand: #08768a;
  --brand-dark: #0d3540;
  --brand-soft: #e3f3f5;
  --danger: #b9382e;
  --danger-soft: #fce8e6;
  --success: #238354;
  --success-soft: #e3f5eb;
  --warning: #b97011;
  --warning-soft: #fff2d9;
  --violet: #6956b5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(23, 35, 44, .04), 0 8px 24px rgba(23, 35, 44, .045);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: none; color: #055b6b; }
button, input, select, textarea { font: inherit; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 248px; display: flex; flex-direction: column; padding: 24px 16px 18px; color: #fff; background: linear-gradient(175deg, #102f38 0%, #0b242b 100%); z-index: 20; }
.brand, .login-brand { display: flex; align-items: center; gap: 12px; color: #fff; padding: 0 10px 25px; }
.brand:hover { color: #fff; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: linear-gradient(135deg, #16a2b7, #08768a); font-size: 21px; font-weight: 800; box-shadow: inset 0 0 0 1px #ffffff26; }
.brand strong, .login-brand strong { display: block; font-size: 18px; letter-spacing: .06em; line-height: 1.1; }
.brand small, .login-brand small { display: block; margin-top: 3px; color: #a8c3ca; font-size: 11px; letter-spacing: .02em; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { display: flex; align-items: center; gap: 11px; min-height: 43px; padding: 9px 11px; border-radius: 8px; color: #bdd0d5; font-weight: 550; transition: .16s ease; }
.sidebar nav a:hover { color: #fff; background: #ffffff0b; }
.sidebar nav a.active { color: #fff; background: #13849a; box-shadow: 0 5px 16px #001b2260; }
.nav-action-row { display: grid; grid-template-columns: minmax(0, 1fr) 34px; gap: 4px; }
.nav-action-row:not(:has(.nav-add)) { display: block; }
.nav-action-row > a:first-child { min-width: 0; }
.sidebar nav .nav-add { min-width: 34px; width: 34px; padding: 0; justify-content: center; color: #8ee2ed; border: 1px solid #ffffff18; font-size: 21px; }
.sidebar nav .nav-add:hover { color: #fff; border-color: #ffffff35; background: #13849a; }
.nav-icon { width: 24px; text-align: center; font-size: 19px; line-height: 1; }
.nav-label { margin: 22px 11px 6px; color: #6f929a; font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.sidebar-foot { display: flex; align-items: center; gap: 9px; margin-top: auto; padding: 14px 11px 0; border-top: 1px solid #ffffff12; color: #8eacb3; font-size: 11px; }
.system-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #47cb85; box-shadow: 0 0 0 4px #47cb8520; }

.workspace { grid-column: 2; min-width: 0; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 32px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 10; }
.topbar-title { display: flex; flex-direction: column; }
.topbar-title strong { font-size: 16px; }
.eyebrow, .overline { color: var(--brand); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; background: var(--brand-soft); color: var(--brand); font-weight: 800; }
.user-meta { display: flex; flex-direction: column; min-width: 130px; }
.user-meta strong { font-size: 13px; line-height: 1.2; }
.user-meta small { color: var(--muted); font-size: 11px; }
.user-menu form { margin: 0; }
.logout { width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); color: var(--muted); background: #fff; font-size: 18px; }

.container { width: 100%; max-width: 1480px; margin: 0 auto; padding: 30px 34px 45px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 2px 0 24px; }
.page-head h1 { margin: 5px 0 2px; font-size: clamp(25px, 3vw, 32px); line-height: 1.2; letter-spacing: -.025em; }
h1 { font-size: 30px; }
h2 { margin: 0 0 14px; font-size: 18px; letter-spacing: -.015em; }
p { margin-top: 0; }
.muted, small { color: var(--muted); }
.date-chip { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: #fff; font-size: 13px; }

.card, .asset-card { padding: 20px; margin-bottom: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.card > h2 { padding-bottom: 14px; border-bottom: 1px solid #edf1f3; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 16px; }
.cards .card { margin: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stats > a { min-height: 130px; display: flex; align-items: flex-start; gap: 14px; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: #fff; box-shadow: var(--shadow); transition: transform .16s, box-shadow .16s, border-color .16s; }
.stats > a:hover { transform: translateY(-2px); border-color: #b8d4da; box-shadow: 0 10px 30px #17333a12; }
.stat-icon { width: 40px; height: 40px; display: grid; flex: 0 0 auto; place-items: center; border-radius: 10px; font-size: 20px; }
.stat-icon.blue { color: var(--brand); background: var(--brand-soft); }
.stat-icon.amber { color: var(--warning); background: var(--warning-soft); }
.stat-icon.red { color: var(--danger); background: var(--danger-soft); }
.stat-icon.violet { color: var(--violet); background: #eeeafa; }
.stat-copy { min-width: 0; display: flex; flex-direction: column; }
.stat-copy small { font-size: 12px; font-weight: 650; }
.stat-copy strong { margin: 1px 0 7px; font-size: 30px; line-height: 1.1; }
.stat-copy em { color: var(--brand); font-size: 11px; font-style: normal; }

.asset-card { display: flex; justify-content: space-between; gap: 28px; color: var(--ink); transition: transform .16s, box-shadow .16s, border-color .16s; }
.asset-card:hover { transform: translateY(-2px); border-color: #acd0d7; box-shadow: 0 10px 30px #17333a12; color: var(--ink); }
.asset-card h2 { margin: 10px 0 2px; }
.asset-card dl { min-width: 145px; margin: 0; }
.asset-card dt { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.asset-card dd { margin: 1px 0 7px; }
.asset-path { margin: 12px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-head h2 { margin-bottom: 2px; padding: 0; border: 0; }
.count-chip { min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--brand); background: var(--brand-soft); font-weight: 800; }
.site-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 12px; }
.site-node { overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfd; }
.site-node > summary { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; padding: 14px; list-style: none; }
.site-node > summary::-webkit-details-marker { display: none; }
.site-node > summary::after { content: "+"; color: var(--brand); font-size: 18px; }
.site-node[open] > summary::after { content: "−"; }
.site-node > summary small { grid-column: 2; }
.site-type { grid-row: span 2; padding: 4px 7px; border-radius: 6px; color: var(--brand); background: var(--brand-soft); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.site-node-body { padding: 0 14px 14px; border-top: 1px solid var(--line); }
.sub-node { margin-top: 9px; overflow: hidden; border: 1px solid #e2e9ec; border-radius: 7px; background: #fff; }
.sub-node > summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 11px; list-style: none; }
.sub-node > summary::-webkit-details-marker { display: none; }
.sub-node > summary small { font-size: 10px; }
.asset-chip-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px; padding: 9px; border-top: 1px solid #edf1f3; background: #f8fafb; }
.asset-chip-list a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 9px; border: 1px solid #dbe5e8; border-radius: 6px; color: #334850; background: #fff; font-size: 11px; }
.asset-chip-list a:hover { color: var(--brand); border-color: #9ec8d0; }
.asset-chip-list small { font-size: 8px; }
.site-node-body h3 { margin: 14px 0 7px; color: var(--muted); font-size: 10px; letter-spacing: .07em; text-transform: uppercase; }
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-list a { padding: 5px 8px; border: 1px solid #d8e2e6; border-radius: 6px; color: #40545d; background: #fff; font-size: 10px; }
.chip-list a:hover { color: var(--brand); border-color: #9ec8d0; }
.chip-list.categories a { color: var(--brand); background: var(--brand-soft); }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.breadcrumb b { color: #a1afb6; }
.breadcrumb strong { color: var(--ink); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 18px; }
.stack { display: grid; gap: 16px; }
.span-2 { grid-column: span 2; }
label { display: grid; gap: 6px; color: #3f5059; font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 41px; padding: 9px 11px; border: 1px solid #cbd5da; border-radius: 7px; outline: none; color: var(--ink); background: #fff; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: #48a8b8; box-shadow: 0 0 0 3px #0d899e16; }
textarea { min-height: 88px; resize: vertical; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 9px 14px; border: 0; border-radius: 7px; cursor: pointer; color: #fff; background: var(--brand); font-size: 13px; font-weight: 700; transition: background .15s, transform .1s; }
button:hover, .button:hover { color: #fff; background: #075f70; }
button:active, .button:active { transform: translateY(1px); }
.secondary { background: #687983; }
.danger-button { background: var(--danger); }
.danger-button:hover { background: #922b23; }
.link { min-height: 0; padding: 0; color: inherit; background: none; text-decoration: underline; }
.actions, .inline, .row { display: flex; align-items: center; gap: 8px; }
.filter-bar { display: flex; align-items: center; gap: 8px; }
.filter-bar select { min-width: 170px; }
.actions { justify-content: flex-end; }
.inline select, .inline input { width: auto; }
.row { justify-content: space-between; align-items: flex-start; }
.check { display: flex; align-items: center; justify-content: flex-start; }
.check input { width: auto; min-height: 0; }

.badge { display: inline-block; padding: 4px 9px; border-radius: 999px; color: #4c616b; background: #eaf0f2; font-size: 10px; font-weight: 800; letter-spacing: .025em; }
.badge.danger { color: var(--danger); background: var(--danger-soft); }
.badge.success { color: var(--success); background: var(--success-soft); }
.due { border-left: 4px solid var(--danger); }
details > summary { cursor: pointer; color: #30454f; font-weight: 750; }
.card > summary { font-size: 16px; }
.card[open] > summary { margin-bottom: 8px; }
.create-entry, main.container > details.card { border-left: 4px solid var(--brand); }
.create-entry > summary, main.container > details.card > summary { display: flex; align-items: center; gap: 9px; }
main.container > details.card:not(.create-entry) > summary::before { width: 25px; height: 25px; display: inline-grid; place-items: center; content: "+"; border-radius: 7px; color: #fff; background: var(--brand); font-size: 18px; font-weight: 500; line-height: 1; }
.summary-icon { width: 25px; height: 25px; display: inline-grid; place-items: center; border-radius: 7px; color: #fff; background: var(--brand); font-size: 18px; line-height: 1; }

.timeline article { position: relative; display: grid; grid-template-columns: 92px 1fr; gap: 18px; padding: 0 0 22px 20px; border-left: 2px solid #dce6e9; }
.timeline article::before { position: absolute; top: 4px; left: -6px; width: 10px; height: 10px; content: ""; border: 2px solid #fff; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 1px #aad0d7; }
.timeline p { margin: 4px 0; }
.timeline time { color: var(--muted); font-size: 12px; font-weight: 700; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 11px; border-bottom: 1px solid #e7ecef; text-align: left; vertical-align: middle; }
th { color: var(--muted); background: #f8fafb; font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
tbody tr:hover, table tr:hover td { background: #f9fbfc; }
.file-list { padding: 0; list-style: none; }
.file-list li { display: flex; align-items: center; gap: 9px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.file-list li form { margin-left: auto; }
.details { display: grid; grid-template-columns: 160px 1fr; }
.details dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.details dd { margin: 0 0 12px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.alert { padding: 11px 13px; margin: 12px 0; border: 1px solid #f3c3bf; border-radius: 7px; color: var(--danger); background: var(--danger-soft); }
.order-list { grid-template-columns: 1fr; }
.photo-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 12px; margin: 18px 0 12px; }
.photo-gallery figure { position: relative; min-width: 0; margin: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #f7fafb; }
.photo-gallery a { display: block; overflow: hidden; background: #dfe8eb; }
.photo-gallery img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; transition: transform .2s ease; }
.photo-gallery a:hover img { transform: scale(1.035); }
.photo-gallery figcaption { position: relative; display: grid; gap: 1px; padding: 8px 32px 8px 9px; }
.photo-gallery figcaption > span { overflow: hidden; font-size: 11px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.photo-gallery figcaption small { font-size: 9px; }
.photo-delete { position: absolute; top: 7px; right: 7px; min-height: 24px; width: 24px; padding: 0; border-radius: 50%; background: var(--danger); font-size: 16px; }
.photo-upload { margin-top: 12px; padding: 11px 12px; border-radius: 8px; background: #f5f9fa; }
.photo-upload summary { font-size: 12px; }
.upload-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.upload-row input { flex: 1; }

.auth-page { background: #edf3f4; }
.auth-page > .container { max-width: none; min-height: 100vh; padding: 0; }
.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 46%) 1fr; }
.login-visual { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 42px 52px; color: #fff; background: linear-gradient(145deg, #123b46, #082229); }
.login-visual::before, .login-visual::after { position: absolute; content: ""; border: 1px solid #ffffff10; border-radius: 50%; }
.login-visual::before { width: 620px; height: 620px; right: -330px; bottom: -250px; box-shadow: 0 0 0 90px #ffffff05, 0 0 0 180px #ffffff03; }
.login-visual::after { width: 280px; height: 280px; right: 50px; top: 150px; background: radial-gradient(circle at 50% 50%, #1593a52b, transparent 65%); }
.login-brand { position: relative; z-index: 1; padding: 0; }
.login-visual > div { position: relative; z-index: 1; }
.login-visual .overline { color: #5cd0df; }
.login-visual h1 { max-width: 520px; margin: 12px 0 20px; font-size: clamp(40px, 5vw, 66px); line-height: 1.02; letter-spacing: -.045em; }
.login-visual p { max-width: 540px; color: #b9ced3; font-size: 17px; }
.visual-status { display: flex; align-items: center; gap: 10px; color: #92afb6; font-size: 12px; }
.login-panel { display: grid; place-items: center; padding: 30px; background: #f5f8f9; }
.login-card { width: min(410px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 20px 60px #17333a12; }
.login-card h2 { margin: 5px 0 3px; font-size: 30px; }
.login-card form { margin-top: 25px; }
.input-with-icon { position: relative; }
.input-with-icon span { position: absolute; top: 50%; left: 12px; color: #8a9aa3; transform: translateY(-50%); }
.input-with-icon input { padding-left: 37px; }
.login-button { justify-content: space-between; min-height: 46px; margin-top: 5px; padding-inline: 17px; }
.login-button span { font-size: 18px; }
.login-note { display: block; margin-top: 25px; text-align: center; font-size: 10px; }
.mobile-login-brand { display: none; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
  .app-shell { display: block; padding-bottom: 70px; }
  .workspace { width: 100%; }
  .sidebar { position: fixed; inset: auto 0 0; width: 100%; height: 66px; padding: 7px 8px; background: #102f38; }
  .sidebar .brand, .sidebar .nav-label, .sidebar-foot { display: none; }
  .sidebar nav { height: 100%; flex-direction: row; justify-content: flex-start; gap: 2px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar nav > a, .sidebar nav > .nav-action-row { flex: 0 0 68px; }
  .nav-action-row, .nav-action-row:not(:has(.nav-add)) { position: relative; display: block; }
  .sidebar nav .nav-add { display: none; }
  .sidebar nav a { min-width: 55px; min-height: 52px; flex-direction: column; justify-content: center; gap: 2px; padding: 4px; font-size: 9px; }
  .nav-icon { font-size: 17px; }
  .topbar { height: 62px; padding: 0 18px; }
  .topbar-title .eyebrow, .user-meta { display: none; }
  .container { padding: 22px 18px 35px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .asset-card { flex-direction: column; }
  .site-grid { grid-template-columns: 1fr; }
  .login-layout { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { min-height: 100vh; }
  .mobile-login-brand { display: block; margin-bottom: 30px; color: var(--brand-dark); font-weight: 800; }
}

@media (max-width: 540px) {
  .stats { grid-template-columns: 1fr; }
  .stats > a { min-height: 110px; }
  .inline { width: 100%; align-items: stretch; flex-direction: column; }
  .filter-bar { width: 100%; align-items: stretch; flex-direction: column; }
  .filter-bar select { width: 100%; }
  .inline select, .inline input { width: 100%; }
  .actions { flex-wrap: wrap; }
  .login-panel { padding: 16px; }
  .login-card { padding: 28px 22px; }
  .sidebar nav a span:last-child { max-width: 60px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .photo-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upload-row { align-items: stretch; flex-direction: column; }
}
