* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Segoe UI", Arial, sans-serif; font-size: 14px; color: #1d2733; background: #f2f5f8; }
a { color: #1663c7; text-decoration: none; }
a:hover { text-decoration: underline; }
.loading { padding: 40px; text-align: center; color: #5c6b7a; }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: #fff; border-radius: 10px; padding: 32px; width: 360px; box-shadow: 0 4px 24px rgba(20,40,70,.12); }
.login-box h1 { font-size: 20px; margin-bottom: 4px; }
.login-box .sub { color: #5c6b7a; margin-bottom: 18px; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: #16283d; color: #cdd9e5; flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar .brand { padding: 18px 16px; font-weight: 600; font-size: 16px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar nav a { display: block; padding: 9px 18px; color: #cdd9e5; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar nav a.active { background: #1663c7; color: #fff; }
.sidebar .userbox { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.sidebar .userbox .name { color: #fff; font-weight: 600; }
.sidebar .userbox .role { color: #8fa3b8; margin-bottom: 8px; }

.main { flex: 1; padding: 22px 26px; min-width: 0; }
.main-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.main-head h2 { font-size: 20px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }

input, select, textarea { font: inherit; padding: 7px 10px; border: 1px solid #c4cfda; border-radius: 6px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9ec2ec; border-color: #1663c7; }
textarea { width: 100%; min-height: 80px; resize: vertical; }

button { font: inherit; padding: 7px 14px; border: none; border-radius: 6px; background: #1663c7; color: #fff; cursor: pointer; }
button:hover { background: #114fa2; }
button.secondary { background: #e8edf3; color: #1d2733; }
button.secondary:hover { background: #d9e2ec; }
button.danger { background: #c0392b; }
button.danger:hover { background: #a53125; }
button.small { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.card { background: #fff; border-radius: 8px; padding: 14px 16px; box-shadow: 0 1px 4px rgba(20,40,70,.08); }
.card .num { font-size: 24px; font-weight: 700; }
.card .lbl { color: #5c6b7a; font-size: 12px; margin-top: 2px; }
.card.warn { border-left: 4px solid #e67e22; }
.card.bad { border-left: 4px solid #c0392b; }
.card.good { border-left: 4px solid #27ae60; }

.panel { background: #fff; border-radius: 8px; padding: 16px 18px; box-shadow: 0 1px 4px rgba(20,40,70,.08); margin-bottom: 16px; }
.panel h3 { font-size: 15px; margin-bottom: 10px; }

table.data { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 4px rgba(20,40,70,.08); }
table.data th { text-align: left; padding: 9px 12px; background: #eef2f7; color: #44576b; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
table.data td { padding: 8px 12px; border-top: 1px solid #eef1f5; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: #f4f8fd; }
td.money-plus { color: #1e7e34; }
td.money-minus { color: #c0392b; font-weight: 600; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #e8edf3; color: #44576b; }
.badge.new { background: #fdf1d7; color: #8a6d1a; }
.badge.in_progress { background: #dbeafe; color: #1c4f9c; }
.badge.waiting { background: #efe4fb; color: #6b3fa0; }
.badge.resolved, .badge.done, .badge.allocated, .badge.approved, .badge.sent, .badge.fulfilled { background: #dcf3e1; color: #1e7e34; }
.badge.closed, .badge.cancelled, .badge.void, .badge.broken, .badge.failed, .badge.rejected { background: #f7dcd8; color: #a53125; }
.badge.high, .badge.critical { background: #f7dcd8; color: #a53125; }
.badge.low { background: #eef1f5; color: #7a8a99; }

.priority-list .p-item { padding: 8px 12px; border-radius: 6px; margin-bottom: 6px; cursor: pointer; }
.priority-list .p-item.danger { background: #f7dcd8; color: #7a221a; }
.priority-list .p-item.warning { background: #fdf1d7; color: #6e5713; }
.priority-list .p-item.info { background: #dbeafe; color: #1c4f9c; }

.modal-overlay { position: fixed; inset: 0; background: rgba(15,30,50,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 100; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 640px; max-width: 100%; padding: 22px 24px; box-shadow: 0 8px 40px rgba(10,25,45,.3); }
.modal h3 { margin-bottom: 14px; font-size: 17px; }
.modal .form-row { margin-bottom: 12px; }
.modal .form-row label { display: block; font-size: 12px; color: #5c6b7a; margin-bottom: 4px; }
.modal .form-row input, .modal .form-row select, .modal .form-row textarea { width: 100%; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal .form-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

.tabs { display: flex; gap: 2px; border-bottom: 2px solid #e2e8ef; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: transparent; color: #44576b; border-radius: 6px 6px 0 0; padding: 8px 14px; }
.tabs button.active { background: #1663c7; color: #fff; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 20px; }
.detail-grid .item .lbl { font-size: 11px; color: #7a8a99; text-transform: uppercase; letter-spacing: .04em; }
.detail-grid .item .val { font-size: 14px; margin-top: 2px; }

.msg { padding: 8px 12px; border-radius: 6px; margin-bottom: 10px; }
.msg.ok { background: #dcf3e1; color: #1e7e34; }
.msg.err { background: #f7dcd8; color: #a53125; }
.msg.info { background: #dbeafe; color: #1c4f9c; }

.chat-box { background: #fff; border-radius: 8px; padding: 18px; box-shadow: 0 1px 4px rgba(20,40,70,.08); }
.chat-answer { margin-top: 14px; }
.chat-answer .summary { font-size: 15px; margin-bottom: 10px; }
.chat-answer .src { font-size: 12px; color: #5c6b7a; margin-top: 4px; }
.chat-answer .warn { background: #fdf1d7; padding: 6px 10px; border-radius: 6px; margin-top: 6px; font-size: 13px; }
.confidence { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.confidence.high { background: #dcf3e1; color: #1e7e34; }
.confidence.medium { background: #fdf1d7; color: #8a6d1a; }
.confidence.low { background: #f7dcd8; color: #a53125; }

.event-line { padding: 6px 0; border-bottom: 1px solid #eef1f5; font-size: 13px; }
.event-line .ts { color: #7a8a99; margin-right: 8px; font-size: 12px; }
.kv { font-size: 13px; color: #5c6b7a; }
.muted { color: #7a8a99; font-size: 12px; }
.actions-cell { white-space: nowrap; }

@media print {
    .sidebar, .toolbar, button, .tabs { display: none !important; }
    body { background: #fff; }
    .panel, table.data { box-shadow: none; }
}
