:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #1d6fd0;
  --primary-dark: #1658a6;
  --danger: #d64444;
  --success: #16835f;
  --warning: #b4690e;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

.login-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 34px 28px; box-shadow: var(--shadow); text-align: center; }
.login-logo { width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px; background: var(--primary); color: #fff; font-size: 24px; display: flex; align-items: center; justify-content: center; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-sub { color: var(--muted); margin: 0 0 24px; font-size: 13px; }
.login-card form { text-align: left; }
.login-hint { font-size: 12px; color: var(--muted); margin: 16px 0 0; }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=file], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,111,208,.12); }
textarea { min-height: 80px; resize: vertical; }

.btn { border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: 14px; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: #c9d2de; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: #fff; color: var(--danger); border-color: #f0c8c8; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; padding: 11px; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 22px; color: var(--muted); padding: 2px 8px; line-height: 1; }

.app-view { display: flex; min-height: 100vh; }
.sidebar { width: 208px; flex: 0 0 208px; background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { height: 60px; display: flex; align-items: center; gap: 10px; padding: 0 20px; font-weight: 600; border-bottom: 1px solid var(--border); }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; }
#sideNav { padding: 12px 10px; flex: 1; }
.nav-item { display: block; width: 100%; text-align: left; border: none; background: transparent; padding: 10px 14px; border-radius: 8px; cursor: pointer; color: #4b5563; margin-bottom: 2px; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: #e9f2fc; color: var(--primary); font-weight: 500; }
.sidebar-foot { padding: 16px 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }

.main-area { flex: 1; min-width: 0; }
.topbar { height: 60px; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 24px; position: sticky; top: 0; z-index: 5; }
.page-title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.top-user { color: var(--muted); font-size: 13px; }
.content { padding: 24px; max-width: 1200px; margin: 0 auto; }

.mobile-only, .bottom-nav { display: none; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.card-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 600; margin-top: 4px; }
.stat .value.blue { color: var(--primary); }
.stat .value.red { color: var(--danger); }
.stat .value.green { color: var(--success); }

.search-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.search-row input { flex: 1; min-width: 180px; }
.search-row select { width: auto; min-width: 120px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td .sub { color: var(--muted); font-size: 12px; display: block; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; background: var(--surface-2); color: var(--muted); }
.tag.pending { background: #fff4e0; color: var(--warning); }
.tag.working { background: #e9f2fc; color: var(--primary); }
.tag.done { background: #e5f6ee; color: var(--success); }
.tag.settled { background: #eef0f2; color: #4b5563; }
.tag.low { background: #fdeaea; color: var(--danger); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--muted); margin: -6px 0 12px; }

.modal-root { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); }
.modal-box { position: relative; background: #fff; width: 100%; max-width: 640px; max-height: 90vh; display: flex; flex-direction: column; border-radius: 12px; overflow: hidden; box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 16px; margin: 0; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.item-row { display: grid; grid-template-columns: 1fr 68px 80px 32px; gap: 8px; margin-bottom: 8px; align-items: center; }
.item-row input { padding: 7px 8px; }
.item-row .del { border: none; background: #fdeaea; color: var(--danger); border-radius: 6px; cursor: pointer; height: 32px; }
.photo-list { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.photo-list img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 18px; margin-bottom: 16px; }
.detail-grid .k { color: var(--muted); font-size: 12px; display: block; }

.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 50; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.2); }

@media (max-width: 800px) {
  .sidebar { display: none; position: fixed; z-index: 20; top: 0; left: 0; bottom: 0; box-shadow: 0 8px 30px rgba(0,0,0,.15); }
  .sidebar.open { display: flex; }
  .mobile-only { display: block; }
  .bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--border); display: flex; z-index: 10; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav button { flex: 1; border: none; background: transparent; padding: 10px 0; color: var(--muted); font-size: 12px; }
  .bottom-nav button.active { color: var(--primary); font-weight: 500; }
  .topbar { padding: 0 14px; height: 54px; }
  .content { padding: 14px; padding-bottom: 80px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 12px; }
  .stat .value { font-size: 22px; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-box { max-height: 88vh; }
  .top-user { display: none; }
}
